This is the hands-on part of the Develop RESTful API in PHP using Apigility workshop presented by Julien Guittard and Matthew Weier O'Phinney at the ZendCon 2015 conference in Las Vegas (NV).
The (in-progress) slides for the workshop are available online
-
Install VMWare Fusion for Mac or VMWare Workstation for Windows/Linux. OR
-
Install the latest version of VirtualBox.
-
Install Vagrant.
-
Install Chef DK.
-
Install Berkshelf:
$ gem install berkshelf
Depending on how you have ruby and rubygems installed, you may have to do this as root:
$ sudo gem install berkshelf
-
Install the following Vagrant plugins:
$ vagrant plugin install vagrant-hostmanager $ vagrant plugin install vagrant-omnibus $ vagrant plugin install vagrant-berkshelf
-
If you are using VMWare, you will need to install the plugin and register your license:
$ vagrant plugin install vagrant-vmware-fusion $ vagrant plugin license vagrant-vmware-fusion ~/license.lic
or
$ vagrant plugin install vagrant-vmware-workstation $ vagrant plugin license vagrant-vmware-workstation ~/license.lic
Depending on your distribution, you may get an error indicating that your version of Ruby is not recent enough. Make sure you have a Ruby v2 installed, and check for a
gem2
,gem2.1
, or similarly named executable on your path, and use that in place ofgem
in the above instructions.If you do not see a
get2
or similar, this may be an indication that you need to install a v2 version of Ruby. Check to see if one is available in your distribution package repository.
CD to your project folder and launch Vagrant:
$ vagrant up
Once te box is setup and provisioned, login in via ssh:
$ vagrant ssh
Your project folder is synchronised with the /vagrant
folder in the virtual
machine. CD to this folder and launch Phing:
$ cd /vagrant && phing init
Sometimes this will error, due to hitting API rate limits on GitHub. If this occurs, try running:
$ /usr/local/bin/composer installUsing this directly will give you information on setting up a GitHub token, and prompt you for its sha1, allowing the install to proceed normally.
Next, set the application into development mode:
$ cd /vagrant && php public/index.php development enable
Open your browser at http://localhost:8888 and start using Apigility!
Now get started on the first exercise of the workshop.