SlideShare a Scribd company logo
APIGILITY ReloadedAPIGILITY Reloaded
Ein frischer Blick auf Apigility 1.1

Repository: https://github.com/RalfEggert/ipc2015-apigility
1 / 44
Über michÜber mich
2 / 44www.RalfEggert.dewww.RalfEggert.de
Fragen ans PublikumFragen ans Publikum
3 / 44
[b01][b01]
[B00][B00]
Apigility 1.0Apigility 1.0
4 / 44
Performance LastigPerformance Lastig
5 / 44
[b02][b02]
Bug lastigBug lastig
6 / 44
[b03]
KonfigurationsLastigKonfigurationsLastig
7 / 44
[b00]
Code lastigCode lastig
8 / 44
[b00]
[B04]
9 / 44
Apigility 1.0Apigility 1.0
War mir zuWar mir zu
AufwändigAufwändig
[B05]
10 / 44
Dann schau dirDann schau dir
Apigility 1.1 an!Apigility 1.1 an!
[B06]
Apigility 1.1Apigility 1.1
In a NutshellIn a Nutshell
11 / 44
Restful Web ServicesRestful Web Services
12 / 44
CLIENT
WebBrowser
PHP
Javascript
RUBY
PYTHON
REST SERVER
/api/user/123
/api/user
/api/user
/api/user/123
/api/user/123
USER DOMAIN
getUserEntity()
getUserCollection()
addUserEntity()
updateUserEntity()
deleteUserEntity()
GET Request
JSON Response
GET Request
JSON Response
POST Request
JSON Response
PUT Request
JSON Response
DELETE Request
JSON Response
Integer
UserEntity
void
UserCollection
Array
Boolean
Integer, Array
Boolean
Integer
Boolean
RPC Web ServicesRPC Web Services
13 / 44
Local
CLIENT
javascript
RPC
Client
JSON
Method:getUser
Params:id
USER DOMAIN
getUserEntity()
GET Request
JSON Result
Integer
UserEntity
RPC
Server
/json-rpc.php
Remote Call
JSON Result
javascript
JSON
Method:addUser
Params:name
addUserEntity()
POST Request
JSON Result
Array
Boolean
/json-rpc.php
Remote Call
JSON Result
javascript
XML
Method:getUser
Params:id
getUserEntity()
GET Request
XML Result
Integer
UserEntity
/xml-rpc.php
Remote Call
XML Result
javascript
XML
Method:addUser
Params:name
addUserEntity()
POST Request
XML Result
Array
Boolean
/xml-rpc.php
Remote Call
XML Result
VersionierungVersionierung
14 / 44
default Version per URLdefault Version per URL
Version 1 per URLVersion 1 per URL
Version 2 per URLVersion 2 per URL
default Version per Content Negotiationdefault Version per Content Negotiation
Version 1 per Content NegotiationVersion 1 per Content Negotiation
Version 2 per Content NegotiationVersion 2 per Content Negotiation
JSON / HAL / ProblemJSON / HAL / Problem
15 / 44
WEITERE FEATURESWEITERE FEATURES
Datenbank-basiertDatenbank-basiert Code-basiertCode-basiert AuthentifizierungAuthentifizierung
API DokumentationAPI Dokumentation DatenvalidierungDatenvalidierung DeploymentDeployment
16 / 44
[B09]
[B08][B08][B07]
[B12][B12][B11][B10]
[b07]
DB-ConnectedDB-Connected
ServiceService
17 / 44
DatenbankmodellDatenbankmodell
18 / 44
InstallationInstallation
19 / 44
// Konsole
// Projekt anlegen
$ cd /home/devhost/
$ composer create-project --dev zfcampus/zf-apigility-skeleton apigility.local
$ cd apigility.local/
// ggf. Schreibrechte setzen
$ sudo chmod 777 -R /home/devhost/apigility.local/
// Development Modus
$ php public/index.php development enable
// Composer besorgen (falls benötigt)
$ curl -s https://getcomposer.org/installer | php --
// Passwort Datei erstellen
$ htpasswd -cs data/users.htpasswd ipc2015
UI: DB-connectedUI: DB-connected
Auth AdapterAuth Adapter Datenbank AdapterDatenbank Adapter Neue User APINeue User API
AuthentifizierungAuthentifizierung Profile ServiceProfile Service User ServiceUser Service
#step1 20 / 44
Testen mit POSTMANTesten mit POSTMAN
2121 // 4444
[b13][b13]
[B00]
Doctrine-Doctrine-
ConnectedConnected
ServiceService
22 / 44
DatenbankmodellDatenbankmodell
23 / 44
UI: DOCTRINE-connectedUI: DOCTRINE-connected
Neue User APINeue User API AuthentifizierungAuthentifizierung
24 / 44
Doctrine InstallationDoctrine Installation
25 / 44
// Konsole
// Apigility Modul für Doctrine installieren
$ php composer.phar require zfcampus/zf-apigility-doctrine "~0.3"
// DoctrineORMModule installieren (falls noch nicht installiert)
$ php composer.phar require doctrine/doctrine-orm-module "~0.8"
Module aktivierenModule aktivieren
26 / 44
// Datei /config/application.config.php
return array(
'modules' => array(
[...]
'DoctrineModule',
'DoctrineORMModule',
'PhproDoctrineHydrationModule',
'ZFApigilityDoctrineServer',
),
);
// Datei /config/development.config.php
return array(
'modules' => array(
[...]
'ZFApigilityDoctrineAdmin',
),
);
Doctrine ConnectionDoctrine Connection
27 / 44
// Datei /config/autoload/user.global.php
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver',
'params' => array(
'host' => 'localhost',
'user' => 'ipc2015',
'password' => 'ipc2015',
'dbname' => 'ipc2015.shop',
'charset' => 'utf8',
),
),
),
),
);
Doctrine DriverDoctrine Driver
28 / 44
// Datei /module/Shop/config/module.config.php
return array(
'doctrine' => array(
'driver' => array(
'shop_driver' => array(
'class' => 'DoctrineORMMappingDriverAnnotationDriver',
'cache' => 'array',
'paths' => array(
0 => __DIR__ . '/../src/Shop/V1/Entity',
),
),
'orm_default' => array(
'drivers' => array(
'ShopV1Entity' => 'shop_driver',
),
),
),
),
);
ENUM Doctrine TYPEENUM Doctrine TYPE
29 / 44
// Datei /module/Application/Module.php
[...]
use DoctrineORMEntityManager;
class Module
{
public function onBootstrap(MvcEvent $e)
{
[...]
$serviceManager = $e->getApplication()->getServiceManager();
$entityManager = $serviceManager->get('DoctrineORMEntityManager');
$platform = $entityManager->getConnection()->getDatabasePlatform();
try {
$result = $platform->getDoctrineTypeMapping('enum');
} catch (DBALException $e) {
$platform->registerDoctrineTypeMapping('enum', 'string');
}
}
}
Entities erstellenEntities erstellen
30 / 44
// Entities aus Datenbank generieren
$ php public/index.php orm:convert-mapping --namespace="ShopV1Entity"
--force --from-database annotation ./module/Shop/src
Processing entity "ShopV1EntityAddress"
Processing entity "ShopV1EntityBooking"
Processing entity "ShopV1EntityBookingposition"
Processing entity "ShopV1EntityCustomer"
Processing entity "ShopV1EntityProduct"
Exporting "annotation" mapping information to
"/home/devhost/apigility.local/module/Shop/src"
// Setter und Getter für Entities generieren
$ php public/index.php orm:generate-entities ./module/Shop/src
--generate-annotations=true
Processing entity "ShopV1EntityBookingposition"
Processing entity "ShopV1EntityBooking"
Processing entity "ShopV1EntityAddress"
Processing entity "ShopV1EntityProduct"
Processing entity "ShopV1EntityCustomer"
Entity classes generated to "/home/devhost/apigility.local/module/Shop/src"
UI: Doctrine-connectedUI: Doctrine-connected
Address ServiceAddress Service Customer ServiceCustomer Service Product ServiceProduct Service
Booking ServiceBooking Service Bookingpos. ServiceBookingpos. Service
#step2 31 / 44
Testen mit POSTMANTesten mit POSTMAN
3232 // 4444
[b13][b13]
Speichern (cascade)Speichern (cascade)
// Datei /module/Shop/src/Shop/V1/Entity/Customer.php
/**
* @var ShopV1EntityAddress
*
* @ORMManyToOne(targetEntity="ShopV1EntityAddress", cascade={"persist"})
* @ORMJoinColumns({
* @ORMJoinColumn(name="invoice_address", referencedColumnName="id")
* })
*/
private $invoiceAddress;
/**
* @var ShopV1EntityAddress
*
* @ORMManyToOne(targetEntity="ShopV1EntityAddress", cascade={"persist"})
* @ORMJoinColumns({
* @ORMJoinColumn(name="delivery_address", referencedColumnName="id")
* })
*/
private $deliveryAddress;
#step3 33 / 44
[B14]
Many-to-ManyMany-to-Many
34 / 44
Testen mit POSTMANTesten mit POSTMAN
3535 // 4444
[b13][b13]
Positionen für BookingPositionen für Booking
36 / 44
// Datei /module/Shop/src/Shop/V1/Entity/Booking.php
/**
* @var ArrayCollection
*
* @ORMManyToMany(targetEntity="Bookingposition")
* @ORMJoinTable(name="bookingposition",
* joinColumns={@ORMJoinColumn(name="booking", referencedColumnName="id")},
* inverseJoinColumns={@ORMJoinColumn(name="product", referencedColumnName="id")}
* )
**/
private $positions;
BookingHydratorBookingHydrator
37 / 44
// Datei /module/Shop/config/module.config.php
return array(
'doctrine-hydrator' => array(
[...]
'ShopV1RestBookingBookingHydrator' => array(
[...]
'strategies' => array(
'positions' => 'ZFApigilityDoctrineServer
HydratorStrategyCollectionExtract',
),
[...]
),
[...]
),
);
Max_Depth setzenMax_Depth setzen
38 / 44
// Datei /module/Shop/config/module.config.php
return array(
'zf-hal' => array(
'metadata_map' => array(
'ShopV1EntityBooking' => array(
[...]
'max_depth' => 3,
),
[...]
'ShopV1EntityBookingposition' => array(
[...]
'max_depth' => 2,
),
),
),
);
Entities aktualisierenEntities aktualisieren
39 / 44
// Setter und Getter für Entities aktualisieren
$ php public/index.php orm:generate-entities ./module/Shop/src
--generate-annotations=true
Processing entity "ShopV1EntityBookingposition"
Processing entity "ShopV1EntityBooking"
Processing entity "ShopV1EntityAddress"
Processing entity "ShopV1EntityProduct"
Processing entity "ShopV1EntityCustomer"
Entity classes generated to "/home/devhost/apigility.local/module/Shop/src"
// Schreibrechte für module/ Verzeichnis neu setzen
$ sudo chmod 777 -R /home/devhost/apigility.local/
Testen mit POSTMANTesten mit POSTMAN
4040 // 4444
[b13][b13]
[B15]
41 / 44
Fazit:Fazit:
Apigility 1.1Apigility 1.1
ist (fast)ist (fast)
kinderleichtkinderleicht
Fragen vom Publikum?Fragen vom Publikum?
42 / 44
[b16]
DANKEDANKE
Für Ihre / Eure Aufmerksamkeit!

Repository: https://github.com/RalfEggert/ipc2015-apigility
43 / 44
BildnachweisBildnachweis
[B00] Fotos von Ralf Eggert
[B01] Frontiers 2011 - Day 2 https://www.flickr.com/photos/frontiersofinteraction/5866676276/ von Frontiersofinteraction - CC-BY https://creativecommons.org/licenses/by/2.0/
[B02] Slow poke - bush gardens https://www.flickr.com/photos/hyku/421609299 von Josh Hallett - CC-BY https://creativecommons.org/licenses/by/2.0/
[B03] Thirsty lady bugs https://www.flickr.com/photos/snowpeak/5897430351/ von John Fowler - CC-BY https://creativecommons.org/licenses/by/2.0/
[B04] Still here https://www.flickr.com/photos/thenovys/3784261365 von Abe Novy - CC-BY https://creativecommons.org/licenses/by/2.0/
[B05] Young student https://www.flickr.com/photos/audiolucistore/14159712431/ von www.audio-luci-store.it - CC-BY https://creativecommons.org/licenses/by/2.0/
[B06] My nuts https://www.flickr.com/photos/lucasincas/6517703315/ von Lucas Incas - CC-BY https://creativecommons.org/licenses/by/2.0/
[B07] Fixing the database https://www.flickr.com/photos/dahlstroms/4140461901 von Håkan Dahlström - CC-BY https://creativecommons.org/licenses/by/2.0/
[B08] Monaco 14pt https://www.flickr.com/photos/polarity/3138680190 von Robert Agthe - CC-BY https://creativecommons.org/licenses/by/2.0/
[B09] RSA Securid Token - Credit Card Style https://www.flickr.com/photos/purpleslog/265657780 von Purple Slog - CC-BY https://creativecommons.org/licenses/by/2.0/
[B10] Shelf of Used Books https://www.flickr.com/photos/thedarkthing/5363586197 von William Ross - CC-BY https://creativecommons.org/licenses/by/2.0/
[B11] Ticket validator at Nice train station https://www.flickr.com/photos/traveleden/3797157077 von Simon - CC-BY https://creativecommons.org/licenses/by/2.0/
[B12] Test Lab - Supermicro Storage https://www.flickr.com/photos/jemimus/8533890844 von Robert - CC-BY https://creativecommons.org/licenses/by/2.0/
[B13] Busy Postmen https://www.flickr.com/photos/wheatfields/4253690499 von Christian Guthier - CC-BY https://creativecommons.org/licenses/by/2.0/
[B14] Network switch and cables https://www.flickr.com/photos/nayukim/3827776580 von Nayu Kim - CC-BY https://creativecommons.org/licenses/by/2.0/
[B15] We are all fan of laptops. https://www.flickr.com/photos/scottvanderchijs/4493248747 von Scott & Elaine van der Chijs - CC-BY https://creativecommons.org/licenses/by/2.0/
[B16] Etech05: Audience https://www.flickr.com/photos/oreilly/6648470 von James Duncan Davidson - CC-BY https://creativecommons.org/licenses/by/2.0/
Alle weiteren Screenshots wurden von Ralf Eggert erstellt.
44 / 44

More Related Content

PDF
IPC 2015 ZF2rapid
PDF
Zend\Expressive - höher, schneller, weiter
PPTX
New in php 7
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
PDF
Unit testing after Zend Framework 1.8
PDF
Continuous Quality Assurance
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
PDF
Rich Model And Layered Architecture in SF2 Application
IPC 2015 ZF2rapid
Zend\Expressive - höher, schneller, weiter
New in php 7
Kicking off with Zend Expressive and Doctrine ORM (PHPNW2016)
Unit testing after Zend Framework 1.8
Continuous Quality Assurance
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Rich Model And Layered Architecture in SF2 Application

What's hot (20)

PPT
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
PDF
関西PHP勉強会 php5.4つまみぐい
PDF
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
KEY
Php Unit With Zend Framework Zendcon09
PDF
QA for PHP projects
PDF
Diving into HHVM Extensions (PHPNW Conference 2015)
PDF
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
PDF
深入淺出 MVC
PDF
What's new with PHP7
PDF
Symfony without the framework
KEY
Zend Framework Study@Tokyo vol1
PDF
Zend Framework 2 Components
KEY
Zend Framework Study@Tokyo #2
PPTX
A Functional Guide to Cat Herding with PHP Generators
PDF
Codeigniter4の比較と検証
PDF
Flask SQLAlchemy
PDF
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
PDF
PHP: 4 Design Patterns to Make Better Code
PDF
Forget about Index.php and build you applications around HTTP - PHPers Cracow
PDF
Quality Assurance for PHP projects - ZendCon 2012
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
関西PHP勉強会 php5.4つまみぐい
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Php Unit With Zend Framework Zendcon09
QA for PHP projects
Diving into HHVM Extensions (PHPNW Conference 2015)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
深入淺出 MVC
What's new with PHP7
Symfony without the framework
Zend Framework Study@Tokyo vol1
Zend Framework 2 Components
Zend Framework Study@Tokyo #2
A Functional Guide to Cat Herding with PHP Generators
Codeigniter4の比較と検証
Flask SQLAlchemy
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
PHP: 4 Design Patterns to Make Better Code
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Quality Assurance for PHP projects - ZendCon 2012
Ad

Viewers also liked (7)

PDF
Easily extend your existing php app with an api
PDF
Deprecated: Foundations of Zend Framework 2
PDF
PHPunconf14: Apigility Einführung
PDF
IPC 2015 Zend Framework 3 Reloaded
PDF
Decouple your framework now, thank me later
PDF
The road to php 7.1
PDF
reveal.js 3.0.0
Easily extend your existing php app with an api
Deprecated: Foundations of Zend Framework 2
PHPunconf14: Apigility Einführung
IPC 2015 Zend Framework 3 Reloaded
Decouple your framework now, thank me later
The road to php 7.1
reveal.js 3.0.0
Ad

Similar to Apigility reloaded (20)

PDF
Mobyle administrator workshop
PPT
PDF
Symfony tips and tricks
PPTX
Fiware cloud capabilities_and_setting_up_your_environment
PPTX
Custom Buildpacks and Data Services
PDF
Building Mobile Friendly APIs in Rails
PDF
Docker presentasjon java bin
PDF
Folio3 - An Introduction to PHP Yii
PPTX
Microsoft Windows Server AppFabric
PPTX
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
PPTX
WordPress Hardening
PDF
Quanto è sicuro il tuo wordpress?
PDF
Minimum Viable Docker: our journey towards orchestration
PDF
Behavior & Specification Driven Development in PHP - #OpenWest
ODP
CodeIgniter PHP MVC Framework
PPTX
Python from zero to hero (Twitter Explorer)
PPTX
Scale Your Data Tier With Windows Server App Fabric
PDF
Write your first WordPress plugin
PDF
Oracle business intelligence enterprise edition 11g
PDF
Creating Scalable JVM/Java Apps on Heroku
Mobyle administrator workshop
Symfony tips and tricks
Fiware cloud capabilities_and_setting_up_your_environment
Custom Buildpacks and Data Services
Building Mobile Friendly APIs in Rails
Docker presentasjon java bin
Folio3 - An Introduction to PHP Yii
Microsoft Windows Server AppFabric
TechDays 2010 Portugal - Scaling your data tier with app fabric 16x9
WordPress Hardening
Quanto è sicuro il tuo wordpress?
Minimum Viable Docker: our journey towards orchestration
Behavior & Specification Driven Development in PHP - #OpenWest
CodeIgniter PHP MVC Framework
Python from zero to hero (Twitter Explorer)
Scale Your Data Tier With Windows Server App Fabric
Write your first WordPress plugin
Oracle business intelligence enterprise edition 11g
Creating Scalable JVM/Java Apps on Heroku

More from Ralf Eggert (20)

PDF
PHP Frameworks: I want to break free (IPC Berlin 2024)
PDF
PHP Rewrite: Do the right thing (IPC Berlin 2024)
PDF
ChatGPT: unser täglich' Bot gib uns heute
PDF
Der ultimative PHP Framework Vergleich 2023 Edition
PDF
PHP Module als Rundum-Sorglos-Pakete entwickeln
PDF
Alexa, what's next?
PDF
Alexa, wohin geht die Reise
PDF
8. Hamburg Voice Interface Meetup
PDF
Welcome Bixby
PDF
Alexa Skill Maintenance
PDF
Vom Zend Framework zu Laminas
PDF
Alexa Skills und PHP? Passt das zusammen?
PDF
Mit Jovo von 0 auf 100
PDF
Vom Zend Framework zu Laminas
PDF
Alexa for Hospitality
PDF
Alexa, lass uns Geld verdienen – fünf Geschäftsmodelle, die wirklich funktion...
PDF
Fortgeschrittene Techniken für erfolgreiche Sprachanwendungen
PDF
Die sieben Projektphasen für Voice Projekte
PDF
Künstliche Intelligenz – Traum und Wirklichkeit
PDF
Multi-Modal Voice Development with Amazon Alexa
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Rewrite: Do the right thing (IPC Berlin 2024)
ChatGPT: unser täglich' Bot gib uns heute
Der ultimative PHP Framework Vergleich 2023 Edition
PHP Module als Rundum-Sorglos-Pakete entwickeln
Alexa, what's next?
Alexa, wohin geht die Reise
8. Hamburg Voice Interface Meetup
Welcome Bixby
Alexa Skill Maintenance
Vom Zend Framework zu Laminas
Alexa Skills und PHP? Passt das zusammen?
Mit Jovo von 0 auf 100
Vom Zend Framework zu Laminas
Alexa for Hospitality
Alexa, lass uns Geld verdienen – fünf Geschäftsmodelle, die wirklich funktion...
Fortgeschrittene Techniken für erfolgreiche Sprachanwendungen
Die sieben Projektphasen für Voice Projekte
Künstliche Intelligenz – Traum und Wirklichkeit
Multi-Modal Voice Development with Amazon Alexa

Recently uploaded (20)

PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Tartificialntelligence_presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Mushroom cultivation and it's methods.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
Teaching material agriculture food technology
PPTX
Machine Learning_overview_presentation.pptx
PPTX
1. Introduction to Computer Programming.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Heart disease approach using modified random forest and particle swarm optimi...
Reach Out and Touch Someone: Haptics and Empathic Computing
OMC Textile Division Presentation 2021.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
Tartificialntelligence_presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf
Mushroom cultivation and it's methods.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Programs and apps: productivity, graphics, security and other tools
Teaching material agriculture food technology
Machine Learning_overview_presentation.pptx
1. Introduction to Computer Programming.pptx

Apigility reloaded

  • 1. APIGILITY ReloadedAPIGILITY Reloaded Ein frischer Blick auf Apigility 1.1  Repository: https://github.com/RalfEggert/ipc2015-apigility 1 / 44
  • 2. Über michÜber mich 2 / 44www.RalfEggert.dewww.RalfEggert.de
  • 3. Fragen ans PublikumFragen ans Publikum 3 / 44 [b01][b01]
  • 9. [B04] 9 / 44 Apigility 1.0Apigility 1.0 War mir zuWar mir zu AufwändigAufwändig
  • 10. [B05] 10 / 44 Dann schau dirDann schau dir Apigility 1.1 an!Apigility 1.1 an!
  • 11. [B06] Apigility 1.1Apigility 1.1 In a NutshellIn a Nutshell 11 / 44
  • 12. Restful Web ServicesRestful Web Services 12 / 44 CLIENT WebBrowser PHP Javascript RUBY PYTHON REST SERVER /api/user/123 /api/user /api/user /api/user/123 /api/user/123 USER DOMAIN getUserEntity() getUserCollection() addUserEntity() updateUserEntity() deleteUserEntity() GET Request JSON Response GET Request JSON Response POST Request JSON Response PUT Request JSON Response DELETE Request JSON Response Integer UserEntity void UserCollection Array Boolean Integer, Array Boolean Integer Boolean
  • 13. RPC Web ServicesRPC Web Services 13 / 44 Local CLIENT javascript RPC Client JSON Method:getUser Params:id USER DOMAIN getUserEntity() GET Request JSON Result Integer UserEntity RPC Server /json-rpc.php Remote Call JSON Result javascript JSON Method:addUser Params:name addUserEntity() POST Request JSON Result Array Boolean /json-rpc.php Remote Call JSON Result javascript XML Method:getUser Params:id getUserEntity() GET Request XML Result Integer UserEntity /xml-rpc.php Remote Call XML Result javascript XML Method:addUser Params:name addUserEntity() POST Request XML Result Array Boolean /xml-rpc.php Remote Call XML Result
  • 14. VersionierungVersionierung 14 / 44 default Version per URLdefault Version per URL Version 1 per URLVersion 1 per URL Version 2 per URLVersion 2 per URL default Version per Content Negotiationdefault Version per Content Negotiation Version 1 per Content NegotiationVersion 1 per Content Negotiation Version 2 per Content NegotiationVersion 2 per Content Negotiation
  • 15. JSON / HAL / ProblemJSON / HAL / Problem 15 / 44
  • 16. WEITERE FEATURESWEITERE FEATURES Datenbank-basiertDatenbank-basiert Code-basiertCode-basiert AuthentifizierungAuthentifizierung API DokumentationAPI Dokumentation DatenvalidierungDatenvalidierung DeploymentDeployment 16 / 44 [B09] [B08][B08][B07] [B12][B12][B11][B10]
  • 19. InstallationInstallation 19 / 44 // Konsole // Projekt anlegen $ cd /home/devhost/ $ composer create-project --dev zfcampus/zf-apigility-skeleton apigility.local $ cd apigility.local/ // ggf. Schreibrechte setzen $ sudo chmod 777 -R /home/devhost/apigility.local/ // Development Modus $ php public/index.php development enable // Composer besorgen (falls benötigt) $ curl -s https://getcomposer.org/installer | php -- // Passwort Datei erstellen $ htpasswd -cs data/users.htpasswd ipc2015
  • 20. UI: DB-connectedUI: DB-connected Auth AdapterAuth Adapter Datenbank AdapterDatenbank Adapter Neue User APINeue User API AuthentifizierungAuthentifizierung Profile ServiceProfile Service User ServiceUser Service #step1 20 / 44
  • 21. Testen mit POSTMANTesten mit POSTMAN 2121 // 4444 [b13][b13]
  • 24. UI: DOCTRINE-connectedUI: DOCTRINE-connected Neue User APINeue User API AuthentifizierungAuthentifizierung 24 / 44
  • 25. Doctrine InstallationDoctrine Installation 25 / 44 // Konsole // Apigility Modul für Doctrine installieren $ php composer.phar require zfcampus/zf-apigility-doctrine "~0.3" // DoctrineORMModule installieren (falls noch nicht installiert) $ php composer.phar require doctrine/doctrine-orm-module "~0.8"
  • 26. Module aktivierenModule aktivieren 26 / 44 // Datei /config/application.config.php return array( 'modules' => array( [...] 'DoctrineModule', 'DoctrineORMModule', 'PhproDoctrineHydrationModule', 'ZFApigilityDoctrineServer', ), ); // Datei /config/development.config.php return array( 'modules' => array( [...] 'ZFApigilityDoctrineAdmin', ), );
  • 27. Doctrine ConnectionDoctrine Connection 27 / 44 // Datei /config/autoload/user.global.php return array( 'doctrine' => array( 'connection' => array( 'orm_default' => array( 'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver', 'params' => array( 'host' => 'localhost', 'user' => 'ipc2015', 'password' => 'ipc2015', 'dbname' => 'ipc2015.shop', 'charset' => 'utf8', ), ), ), ), );
  • 28. Doctrine DriverDoctrine Driver 28 / 44 // Datei /module/Shop/config/module.config.php return array( 'doctrine' => array( 'driver' => array( 'shop_driver' => array( 'class' => 'DoctrineORMMappingDriverAnnotationDriver', 'cache' => 'array', 'paths' => array( 0 => __DIR__ . '/../src/Shop/V1/Entity', ), ), 'orm_default' => array( 'drivers' => array( 'ShopV1Entity' => 'shop_driver', ), ), ), ), );
  • 29. ENUM Doctrine TYPEENUM Doctrine TYPE 29 / 44 // Datei /module/Application/Module.php [...] use DoctrineORMEntityManager; class Module { public function onBootstrap(MvcEvent $e) { [...] $serviceManager = $e->getApplication()->getServiceManager(); $entityManager = $serviceManager->get('DoctrineORMEntityManager'); $platform = $entityManager->getConnection()->getDatabasePlatform(); try { $result = $platform->getDoctrineTypeMapping('enum'); } catch (DBALException $e) { $platform->registerDoctrineTypeMapping('enum', 'string'); } } }
  • 30. Entities erstellenEntities erstellen 30 / 44 // Entities aus Datenbank generieren $ php public/index.php orm:convert-mapping --namespace="ShopV1Entity" --force --from-database annotation ./module/Shop/src Processing entity "ShopV1EntityAddress" Processing entity "ShopV1EntityBooking" Processing entity "ShopV1EntityBookingposition" Processing entity "ShopV1EntityCustomer" Processing entity "ShopV1EntityProduct" Exporting "annotation" mapping information to "/home/devhost/apigility.local/module/Shop/src" // Setter und Getter für Entities generieren $ php public/index.php orm:generate-entities ./module/Shop/src --generate-annotations=true Processing entity "ShopV1EntityBookingposition" Processing entity "ShopV1EntityBooking" Processing entity "ShopV1EntityAddress" Processing entity "ShopV1EntityProduct" Processing entity "ShopV1EntityCustomer" Entity classes generated to "/home/devhost/apigility.local/module/Shop/src"
  • 31. UI: Doctrine-connectedUI: Doctrine-connected Address ServiceAddress Service Customer ServiceCustomer Service Product ServiceProduct Service Booking ServiceBooking Service Bookingpos. ServiceBookingpos. Service #step2 31 / 44
  • 32. Testen mit POSTMANTesten mit POSTMAN 3232 // 4444 [b13][b13]
  • 33. Speichern (cascade)Speichern (cascade) // Datei /module/Shop/src/Shop/V1/Entity/Customer.php /** * @var ShopV1EntityAddress * * @ORMManyToOne(targetEntity="ShopV1EntityAddress", cascade={"persist"}) * @ORMJoinColumns({ * @ORMJoinColumn(name="invoice_address", referencedColumnName="id") * }) */ private $invoiceAddress; /** * @var ShopV1EntityAddress * * @ORMManyToOne(targetEntity="ShopV1EntityAddress", cascade={"persist"}) * @ORMJoinColumns({ * @ORMJoinColumn(name="delivery_address", referencedColumnName="id") * }) */ private $deliveryAddress; #step3 33 / 44
  • 35. Testen mit POSTMANTesten mit POSTMAN 3535 // 4444 [b13][b13]
  • 36. Positionen für BookingPositionen für Booking 36 / 44 // Datei /module/Shop/src/Shop/V1/Entity/Booking.php /** * @var ArrayCollection * * @ORMManyToMany(targetEntity="Bookingposition") * @ORMJoinTable(name="bookingposition", * joinColumns={@ORMJoinColumn(name="booking", referencedColumnName="id")}, * inverseJoinColumns={@ORMJoinColumn(name="product", referencedColumnName="id")} * ) **/ private $positions;
  • 37. BookingHydratorBookingHydrator 37 / 44 // Datei /module/Shop/config/module.config.php return array( 'doctrine-hydrator' => array( [...] 'ShopV1RestBookingBookingHydrator' => array( [...] 'strategies' => array( 'positions' => 'ZFApigilityDoctrineServer HydratorStrategyCollectionExtract', ), [...] ), [...] ), );
  • 38. Max_Depth setzenMax_Depth setzen 38 / 44 // Datei /module/Shop/config/module.config.php return array( 'zf-hal' => array( 'metadata_map' => array( 'ShopV1EntityBooking' => array( [...] 'max_depth' => 3, ), [...] 'ShopV1EntityBookingposition' => array( [...] 'max_depth' => 2, ), ), ), );
  • 39. Entities aktualisierenEntities aktualisieren 39 / 44 // Setter und Getter für Entities aktualisieren $ php public/index.php orm:generate-entities ./module/Shop/src --generate-annotations=true Processing entity "ShopV1EntityBookingposition" Processing entity "ShopV1EntityBooking" Processing entity "ShopV1EntityAddress" Processing entity "ShopV1EntityProduct" Processing entity "ShopV1EntityCustomer" Entity classes generated to "/home/devhost/apigility.local/module/Shop/src" // Schreibrechte für module/ Verzeichnis neu setzen $ sudo chmod 777 -R /home/devhost/apigility.local/
  • 40. Testen mit POSTMANTesten mit POSTMAN 4040 // 4444 [b13][b13]
  • 41. [B15] 41 / 44 Fazit:Fazit: Apigility 1.1Apigility 1.1 ist (fast)ist (fast) kinderleichtkinderleicht
  • 42. Fragen vom Publikum?Fragen vom Publikum? 42 / 44 [b16]
  • 43. DANKEDANKE Für Ihre / Eure Aufmerksamkeit!  Repository: https://github.com/RalfEggert/ipc2015-apigility 43 / 44
  • 44. BildnachweisBildnachweis [B00] Fotos von Ralf Eggert [B01] Frontiers 2011 - Day 2 https://www.flickr.com/photos/frontiersofinteraction/5866676276/ von Frontiersofinteraction - CC-BY https://creativecommons.org/licenses/by/2.0/ [B02] Slow poke - bush gardens https://www.flickr.com/photos/hyku/421609299 von Josh Hallett - CC-BY https://creativecommons.org/licenses/by/2.0/ [B03] Thirsty lady bugs https://www.flickr.com/photos/snowpeak/5897430351/ von John Fowler - CC-BY https://creativecommons.org/licenses/by/2.0/ [B04] Still here https://www.flickr.com/photos/thenovys/3784261365 von Abe Novy - CC-BY https://creativecommons.org/licenses/by/2.0/ [B05] Young student https://www.flickr.com/photos/audiolucistore/14159712431/ von www.audio-luci-store.it - CC-BY https://creativecommons.org/licenses/by/2.0/ [B06] My nuts https://www.flickr.com/photos/lucasincas/6517703315/ von Lucas Incas - CC-BY https://creativecommons.org/licenses/by/2.0/ [B07] Fixing the database https://www.flickr.com/photos/dahlstroms/4140461901 von Håkan Dahlström - CC-BY https://creativecommons.org/licenses/by/2.0/ [B08] Monaco 14pt https://www.flickr.com/photos/polarity/3138680190 von Robert Agthe - CC-BY https://creativecommons.org/licenses/by/2.0/ [B09] RSA Securid Token - Credit Card Style https://www.flickr.com/photos/purpleslog/265657780 von Purple Slog - CC-BY https://creativecommons.org/licenses/by/2.0/ [B10] Shelf of Used Books https://www.flickr.com/photos/thedarkthing/5363586197 von William Ross - CC-BY https://creativecommons.org/licenses/by/2.0/ [B11] Ticket validator at Nice train station https://www.flickr.com/photos/traveleden/3797157077 von Simon - CC-BY https://creativecommons.org/licenses/by/2.0/ [B12] Test Lab - Supermicro Storage https://www.flickr.com/photos/jemimus/8533890844 von Robert - CC-BY https://creativecommons.org/licenses/by/2.0/ [B13] Busy Postmen https://www.flickr.com/photos/wheatfields/4253690499 von Christian Guthier - CC-BY https://creativecommons.org/licenses/by/2.0/ [B14] Network switch and cables https://www.flickr.com/photos/nayukim/3827776580 von Nayu Kim - CC-BY https://creativecommons.org/licenses/by/2.0/ [B15] We are all fan of laptops. https://www.flickr.com/photos/scottvanderchijs/4493248747 von Scott & Elaine van der Chijs - CC-BY https://creativecommons.org/licenses/by/2.0/ [B16] Etech05: Audience https://www.flickr.com/photos/oreilly/6648470 von James Duncan Davidson - CC-BY https://creativecommons.org/licenses/by/2.0/ Alle weiteren Screenshots wurden von Ralf Eggert erstellt. 44 / 44