in 2 it 
Pimp legacy PHP 
apps with Apigility 
TrueNorthPHP 2014
Michelangelo van Dam 
Consultant, Community Leader, Contributor 
https://www.flickr.com/photos/akrabat/8784318813
Who builds API’s? 
http://apigee.com/about/
How do you build them? 
https://www.flickr.com/photos/florianric/7263382550
October 8, 2013 
• ZendCon keynote 
• MWOP announces Apigility 
• REST API Management Tool
Apigility in a nutshell 
• Full-features REST mgmt tool 
• Versioning 
• Authentication 
• Validation 
• Hypertext Application 
Language (HAL) supported 
• API Documentation
https://www.flickr.com/photos/simonov/3629246570
https://www.flickr.com/photos/npobre/2601582256
Requirements 
• Apigility 
• A ZF1 project 
• Composer 
• Some coding experience 
https://www.flickr.com/photos/adesigna/4090782772
Approach 
Vanilla Apigility! 
Skeleton 
Your ZF1 App Your ZF1 Libraries
Download Apigility 
git clone https://github.com/zfcampus/zf-apigility-skeleton.git zfdemo-api 
cd zfdemo-api 
php composer.phar self-update! 
php composer.phar install
Add Zend Framework 1 
vi composer.json 
"require": {! 
...! 
"zendframework/zendframework1": "~1.12"! 
} 
php composer.phar update
Add your app and lib 
git submodule add -f https://github.com/in2it/zfdemo.git vendor/zfdemo 
git submodule add -f https://github.com/in2it/In2it.git vendor/In2it
Symlink into your app 
cd vendor/zfdemo/library 
ln -s ../../zendframework/zendframework1/library/Zend Zend 
ln -s ../../In2it/library/In2it In2it 
cd ../../..
Update index.php 
sed -i ’s/APPLICATION_PATH/ZF2APP_PATH/g' public/index.php
Run Apigility 
php public/index.php development enable 
php -S 0.0.0.0:8888 -t public public/index.php 
DO NOT RUN IT LIKE THIS IN PRODUCTION!
Welcome!
https://www.flickr.com/photos/raster/3563135804
https://www.flickr.com/photos/levendis/474847831
Get started!
Create new API
Create new API
Provide a name
Create new REST Service
Name the REST service
There you go: user API
Modify the user API
We need the resource class
Get ZF1for2.php 
in2.se/zf1for2
Thank you MWOP & Team! 
https://www.flickr.com/photos/juokaz/4702577233
Resources 
• The Apgility site: http://apigility.org 
• My blog article: http://in2.se/1fVZ2sI 
• My github zfdemo: http://in2.se/1pu7R9b
joind.in/12722 
Slides will be made available there. 
! 
If you enjoyed this talk, thanks! 
If not, let me know how I could improve it
https://www.flickr.com/photos/drewm/3191870083

Pimp legacy PHP apps with Apigility - TrueNorthPHP 2014