easily extend your existing php app with an api

58
Easily extend your existing PHP app with an API in it 2 PROFESSIONAL PHP SERVICES

Upload: michelangelo-van-dam

Post on 14-Jul-2015

265 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Easily extend your existing php app with an api

Easily extend your existing PHP app with an API

in it2PROFESSIONAL PHP SERVICES

Page 2: Easily extend your existing php app with an api

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

Page 3: Easily extend your existing php app with an api

Who builds API’s?

http

://ap

igee

.com

/abo

ut/

Page 4: Easily extend your existing php app with an api

How do you build them?

http

s://w

ww.

flick

r.com

/pho

tos/

floria

nric

/726

3382

550

Page 5: Easily extend your existing php app with an api

October 8, 2013

• ZendCon keynote

• MWOP announces Apigility

• REST API Management Tool

Page 8: Easily extend your existing php app with an api

Apigility in a nutshell• Full-features REST mgmt tool

• Versioning

• Authentication

• Validation

• Hypertext Application Language (HAL) supported

• API Documentation

Page 9: Easily extend your existing php app with an api

Legacy applications

Page 10: Easily extend your existing php app with an api

Example Zend Framework1 app

Page 11: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

sim

onov

/362

9246

570

Page 13: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

npob

re/2

6015

8225

6

Page 14: Easily extend your existing php app with an api

Requirements

• Apigility

• A ZF1 project

• Composer

• Some coding experience

http

s://w

ww.

flick

r.com

/pho

tos/

ades

igna

/409

0782

772

Page 15: Easily extend your existing php app with an api

ApproachVanilla Apigility!

Skeleton

Your ZF1 App Your ZF1 Libraries

Page 16: Easily extend your existing php app with an api

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

Page 17: Easily extend your existing php app with an api

Add Zend Framework 1

vi composer.json

"require": {! ...! "zendframework/zendframework1": "~1.12"!}

php composer.phar update

Page 18: Easily extend your existing php app with an api

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

Page 19: Easily extend your existing php app with an api

Symlink into your app

cd vendor/zfdemo/library

ln -s ../../zendframework/zendframework1/library/Zend Zend

ln -s ../../In2it/library/In2it In2it

cd ../../..

Page 20: Easily extend your existing php app with an api

Update index.php

sed -i ’s/APPLICATION_PATH/ZF2APP_PATH/g' public/index.php

Page 21: Easily extend your existing php app with an api

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!

Page 22: Easily extend your existing php app with an api

Welcome!

Page 23: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

rast

er/3

5631

3580

4

Page 24: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

leve

ndis

/474

8478

31

Page 25: Easily extend your existing php app with an api

Get started!

Page 26: Easily extend your existing php app with an api

Get started!

Page 27: Easily extend your existing php app with an api

Create new API

Page 28: Easily extend your existing php app with an api

Create new API

Page 29: Easily extend your existing php app with an api

Create new API

Page 30: Easily extend your existing php app with an api

Create new API

Page 31: Easily extend your existing php app with an api

Provide a name

Page 32: Easily extend your existing php app with an api

Provide a name

Page 33: Easily extend your existing php app with an api
Page 34: Easily extend your existing php app with an api
Page 35: Easily extend your existing php app with an api

Create new REST Service

Page 36: Easily extend your existing php app with an api

Create new REST Service

Page 37: Easily extend your existing php app with an api

Name the REST service

Page 38: Easily extend your existing php app with an api

Name the REST service

Page 39: Easily extend your existing php app with an api

Name the REST service

Page 40: Easily extend your existing php app with an api

There you go: user API

Page 41: Easily extend your existing php app with an api
Page 42: Easily extend your existing php app with an api

Modify the user API

Page 43: Easily extend your existing php app with an api

Modify the user API

Page 44: Easily extend your existing php app with an api

We need the resource class

Page 45: Easily extend your existing php app with an api

We need the resource class

Page 46: Easily extend your existing php app with an api
Page 47: Easily extend your existing php app with an api
Page 48: Easily extend your existing php app with an api
Page 49: Easily extend your existing php app with an api
Page 50: Easily extend your existing php app with an api

Get ZF1for2.php

in2.se/zf1for2

Page 51: Easily extend your existing php app with an api
Page 52: Easily extend your existing php app with an api
Page 53: Easily extend your existing php app with an api

Thank you MWOP & Team!

http

s://w

ww.

flick

r.com

/pho

tos/

juok

az/4

7025

7723

3

Page 54: Easily extend your existing php app with an api

Resources

• The Apgility site: http://apigility.org

• My blog article: http://in2.se/1fVZ2sI

• My github zfdemo: http://in2.se/1pu7R9b

Page 55: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

lwr/1

3442

5422

35

Page 56: Easily extend your existing php app with an api

Contact us

in it2PROFESSIONAL PHP SERVICES

Michelangelo van Dam [email protected] !www.in2it.be

PHP Consulting - Training - QA

Page 57: Easily extend your existing php app with an api

Join the fun!

PHPB ENELUX

phpbenelux.eu

Page 58: Easily extend your existing php app with an api

http

s://w

ww.

flick

r.com

/pho

tos/

drew

m/3

1918

7008

3