Easily extend your existing PHP app with an API in it2PROFESSIONAL PHP SERVICES
Michelangelo van Dam! ! PHP Consultant Community Leader President of PHPBenelux Contributor to PHP projects ! T @DragonBe | F DragonBe 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
Legacy applications
Example Zend Framework1 app
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!
Get started!
Create new API
Create new API
Create new API
Create new API
Provide a name
Provide a name
Create new REST Service
Create new REST Service
Name the REST service
Name the REST service
Name the REST service
There you go: user API
Modify the user API
Modify the user API
We need the resource class
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
https://www.flickr.com/photos/lwr/13442542235
Contact us in it2PROFESSIONAL PHP SERVICES Michelangelo van Dam michelangelo@in2it.be ! www.in2it.be PHP Consulting - Training - QA
Join the fun! PHPBENELUX phpbenelux.eu
https://www.flickr.com/photos/drewm/3191870083

Easily extend your existing php app with an api