Jump to content

PW 3.0.11: Composer, Google, Calendars and More


Recommended Posts

This week we've been focused on one of the major 3.x roadmap items, which is to have strong Composer support in ProcessWire. In this post, we now have an outlined process and a full proof-of-concept module built to demonstrate it all, plus info on how other module authors can support Composer as an alternative installation method. To add to that, we get into Google's Client API with a new 3.x specific module and how to connect Google's Calendar services with ProcessWire.


  • Like 18
Link to comment
Share on other sites

I have some problems with composer...the biggest is this:composer require processwire/google-client-api

this gave me this error:

Problem 1 ....processwire/google-client-api 2.0.0 requires google/apiclient ^2.0.0.RC... no matching package found....

Link to comment
Share on other sites

@gunter I'm not seeing that issue here. Double check the following:

  • Your composer version is up-to-date.
  • Your PW version is 3.0.11 (or newer).
  • Your /index.php file is up to date with the core version.
  • Your /composer.json file is up to date with the core version.

Here's what I get when I run composer from a fresh installation: 

Ryans-MacBook-Pro:xyz ryan$ composer require processwire/google-client-api
Using version dev-master for processwire/google-client-api
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing hari/pw-module (1.0.0)
    Downloading: 100%         

  - Installing psr/http-message (dev-master 85d6369)
    Cloning 85d63699f0dbedb190bbd4b0d2b9dc707ea4c298

  - Installing guzzlehttp/psr7 (1.2.3)
    Loading from cache

  - Installing guzzlehttp/promises (1.1.0)
    Loading from cache

  - Installing guzzlehttp/guzzle (dev-master 6a173dd)
    Cloning 6a173ddae1a8e58be871f6d010e88c029eaf5cae

  - Installing phpseclib/phpseclib (2.0.x-dev 9e586e7)
    Cloning 9e586e79f1fadced93cea6b8dfa09c1bde7904c2

  - Installing psr/log (dev-master d8e60a5)
    Cloning d8e60a5619fff77f9669da8997697443ef1a1d7e

  - Installing monolog/monolog (1.x-dev a9ccae2)
    Cloning a9ccae25cbb5c0af6f2a549e4cc3ee6628c253ab

  - Installing firebase/php-jwt (v3.0.0)
    Loading from cache

  - Installing google/auth (v0.7)
    Loading from cache

  - Installing google/apiclient (dev-master 87dff99)
    Cloning 87dff9908464b150334283cd092d7d96e0dcc5bf

  - Installing processwire/google-client-api (dev-master 6d66c53)
    Cloning 6d66c53187a330669bd96ebeb5ea14e80d2c6897

phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.)
phpseclib/phpseclib suggests installing ext-mcrypt (Install the Mcrypt extension in order to speed up a few other cryptographic operations.)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing videlalvaro/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
Writing lock file
Generating autoload files

Anybody else seeing an error when trying to run the composer require command?

Link to comment
Share on other sites

So, in the near future it will be possible to have a composer.json file that allows to bootstrap Processwire with all the extra module awesomeness?

If I've understood the question correctly, the answer is I don't know. :) But my guess so far is: I'm not sure you'll want Composer for this, as PW is still a system that needs to be installed and connected with a database, etc. Meaning, you can't use PW's API unless you've installed it, and that installation involves a few screens of configuring the DB, creating admin account, etc. Whereas, it seems that most of the things one pulls in with Composer are more PHP library specific. But it's a good question because we are going to be making the ProcessWire core available on Packagist, so it'll be interesting to find out exactly what one would do with it from there because ProcessWire is not something that will run out of a /vendor/ directory or just start working because one of its classes was autoloaded. I suspect we'll have some trial and error and things to discover here as we go through the process. 

  • Like 3
Link to comment
Share on other sites

@gunter: update composer.json file, you are missing: 

 "minimum-stability": "dev"

If you see this:

  - Installing psr/http-message (dev-master 85d6369)
    Cloning 85d63699f0dbedb190bbd4b0d2b9dc707ea4c298
    Failed to download psr/http-message from source: Failed to clone https://git
hub.com/php-fig/http-message.git, git was not found, check that it is installedand in your PATH env. 

install git.

Link to comment
Share on other sites

Composer is a package manager. If the package is a framework, a library or just a code snippet is not really relevant so much.

And here you go about what things to use/do with composer. My goto libraries: Carbon, Nette/Forms, kahlan, faker, any of those when needed; As soon as I've more time to put into CI I'll certainly look into using phpdotenv. Probably every third party service integration like Mail / Calender / Paying Gateway should be managed by composer. Any finally if you ever need to use non-php software on your server like redis or elastic-search or others you can find php libraries to use those as well.

  • Like 4
Link to comment
Share on other sites


I'd suggest you taking a look into flarum. It's fully installable by composer and does also use composer to install plugins into it's own folder structure. 

They way they handle it is mentioned about a third of the way down this page: http://flarum.org/docs/installation/

I think this sort of "installation" really is just getting the files to the right place, then running the normal installer, a bit like grabbing a copy straight to the server from Github, but different :)

Link to comment
Share on other sites

I think this sort of "installation" really is just getting the files to the right place, then running the normal installer, a bit like grabbing a copy straight to the server from Github, but different 

Actually this was all I had in mind :) I guess it could be the same as just having a site profile for yourself? Though one simple json file seems very convenient.

Link to comment
Share on other sites

I got a little consern about multisite installations of PW (a better support for which are on the roadmap for 3.0 as I remember). Should not we have separate composer files for eash site? And therefore, shouldn't we place composer in the site/ folder. Or maybe we should have 2 composer.json files: one for installing PW core, and one for modules, which are specific to each site?

Link to comment
Share on other sites

  • 2 weeks later...

thanks for trying to help me (I had problems with composer)

The solution was to completely reinstall windows.. :-)

And now it works...

A small question I have...
Is this the correct way to use the GoogleAPI module to retrieve the calendar list? (from within a module)

$google = $this->wire('modules')->get('GoogleClientAPI');
$service = new \Google_Service_Calendar($google->getClient());
$calendarList = $service->calendarList->listCalendarList();

  foreach ($calendarList->getItems() as $calendarListEntry) {
    $out.= "	<p><a href='../'>".$calendarListEntry->getSummary()."</a></p>"; //dummy code ;-)
    $out.= $calendarListEntry[id];

	$calendarTest = $service->calendarList->get($calendarListEntry->getID());

	//echo $calendarTest->getSummary();
Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...

trying this module for the first time, i downloaded the module from github and installed it to my pw,

also downloaded the google packages but i don't get where to add the autoload.php.

i got this error message on the module settings screen :

GoogleClientAPI requires that the Google API PHP Client be added to your /composer.json file - See README


Link to comment
Share on other sites

I haven't used the module, but because it's not an autoload module, you can include autoloader before you call the module, or in your config file it doesn't matter, as long as it's before module instantiation. 

But, after PW 3.0, there's composer support, so if you have composer installed, you can:

- cd into root directory of your pw setup

- Run

composer require google/apiclient:^2.0

PW will pick up the library and autoload it for you. 


Then, in your template file, say, events.php, you can use the module as it's documented in the blog post. 

$google = $modules->GoogleClientApi;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...