pimp legacy php apps with apigility - truenorthphp 2014
TRANSCRIPT
Pimp legacy PHP apps with Apigility
TrueNorthPHP 2014
in it2
Michelangelo van DamConsultant, Community Leader, Contributor
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
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!
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
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
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
http
s://w
ww.
flick
r.com
/pho
tos/
drew
m/3
1918
7008
3