easily extend your existing php app with an api
TRANSCRIPT
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
http
s://w
ww.
flick
r.com
/pho
tos/
akra
bat/8
7843
1881
3
How do you build them?
http
s://w
ww.
flick
r.com
/pho
tos/
floria
nric
/726
3382
550
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
http
s://w
ww.
flick
r.com
/pho
tos/
sim
onov
/362
9246
570
http
s://w
ww.
flick
r.com
/pho
tos/
npob
re/2
6015
8225
6
Requirements
• Apigility
• A ZF1 project
• Composer
• Some coding experience
http
s://w
ww.
flick
r.com
/pho
tos/
ades
igna
/409
0782
772
ApproachVanilla 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!
http
s://w
ww.
flick
r.com
/pho
tos/
rast
er/3
5631
3580
4
http
s://w
ww.
flick
r.com
/pho
tos/
leve
ndis
/474
8478
31
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
Thank you MWOP & Team!
http
s://w
ww.
flick
r.com
/pho
tos/
juok
az/4
7025
7723
3
Resources
• The Apgility site: http://apigility.org
• My blog article: http://in2.se/1fVZ2sI
• My github zfdemo: http://in2.se/1pu7R9b
http
s://w
ww.
flick
r.com
/pho
tos/
lwr/1
3442
5422
35
Contact us
in it2PROFESSIONAL PHP SERVICES
Michelangelo van Dam [email protected] !www.in2it.be
PHP Consulting - Training - QA
http
s://w
ww.
flick
r.com
/pho
tos/
drew
m/3
1918
7008
3