Slide 1

Slide 1 text

THE PHP INTEROPERABILITY THE PHP INTEROPERABILITY FRAMEWORK FRAMEWORK

Slide 2

Slide 2 text

PAUL DRAGOONIS PAUL DRAGOONIS QA and Developer Lead at and member @dr4goonis Kainos php.net PHP-FIG VÍTOR BRANDÃO VÍTOR BRANDÃO Bug Squasher at QA at Python2PHP ports @noiselabs Kainos Gentoo Linux AGENDA AGENDA 1. About PPI? 2. What's inside? - PPI nuts & bolts

Slide 3

Slide 3 text

3. Practical examples THANK YOU PHP COMMUNITY! THANK YOU PHP COMMUNITY! Evan Coury ( ) Matthew Weier O'Phinney ( ) Jakub Zalas ( ) Ben Tadiar ( ) Rob Allen ( ) Gary Hockin ( ) Ben Scholzen ( ) Paul M Jones ( ) Fabien Potencier ( ) Taylor Otwell ( ) EvanDotPro mwop jakub_zalas BenExile akrabat GeeH DASPRiD pmjones fabpot taylorotwell

Slide 4

Slide 4 text

WHAT PPI IS NOT WHAT PPI IS NOT It's *NOT* Payment Protection Insurance. It's *NOT* a framework introducing anything new to you.

Slide 5

Slide 5 text

P.P.I.? P.P.I.? Hmm... what does it stand for? I don't know! PHP Phramework Interoperability

Slide 6

Slide 6 text

Tonight: PPI V2 PPI V2

Slide 7

Slide 7 text

PPI PHP Meta Framework is the best PPI PHP Meta Framework!

Slide 8

Slide 8 text

WHY DOES PPI EXIST? WHY DOES PPI EXIST? WHAT PROBLEMS DOES IT SOLVE? WHAT PROBLEMS DOES IT SOLVE? Currently, existing frameworks impose a 1-to-1 relationship between your framework app and the framework vendor. What issues does this cause? Vendor lock-in!

Slide 9

Slide 9 text

VENDOR LOCK-IN VENDOR LOCK-IN

Slide 10

Slide 10 text

PROBLEMS WITH VENDOR PROBLEMS WITH VENDOR LOCK-IN LOCK-IN You are tightly coupled to the framework that your app was built on. You can't move your code between apps on di erent frameworks.

Slide 11

Slide 11 text

BENEFITS OF PPI BENEFITS OF PPI Re-usability of knowledge and community e ort! It’s using existing code from existing frameworks that you already know. Your app code belongs to you, not to your framework. As PHP grows, PPI will grow (Zend3, Aura3, Symfony3).

Slide 12

Slide 12 text

2. WHAT'S INSIDE? 2. WHAT'S INSIDE? PPI NUTS & BOLTS PPI NUTS & BOLTS

Slide 13

Slide 13 text

LEVERAGE PHP-FIG STANDARDS LEVERAGE PHP-FIG STANDARDS A friendly environment for swappable 3rd-party components. Components may be PSR-ready or potential candidates (Router). Spearhead PHP-FIG concepts and ideas with a real-life POC for these standards.

Slide 14

Slide 14 text

PSR - WHAT'S IN // WHAT'S PSR - WHAT'S IN // WHAT'S COMING? COMING?

Slide 15

Slide 15 text

PSR-6: CACHING INTERFACE PSR-6: CACHING INTERFACE In production for over 2 years now, but PSR-6 still not nished. namespace PPI\CacheModule\Cache\Driver; use PPI\CacheModule\Cache\CacheItem; use PPI\CacheModule\Cache\CacheInterface; class RedisCache implements CacheInterface { // ... } Other implementations: APC, Disk, Memcached, Memory, Xcache.

Slide 16

Slide 16 text

PSR-7: HTTP MESSAGE PSR-7: HTTP MESSAGE INTERFACE INTERFACE PPI is PSR-7 ready! You can easily adding more libraries into the mix when they implement PSR-7. When consuming frameworks like (ZF2, SF2, Aura2) - that don't support PSR-7 yet - PPI bridges the gap for you.

Slide 17

Slide 17 text

PSR-7: CAN WE HAZ QUORUM? PSR-7: CAN WE HAZ QUORUM? \o/

Slide 18

Slide 18 text

PSR-7: REQUEST INTERFACE PSR-7: REQUEST INTERFACE composer.json: "require": { "psr/http-message": "^0.11" } PPI/Framework/Http/Request.php use Psr\Http\Message\RequestInterface; use Symfony\Component\HttpFoundation\Request as SymfonyHttpRequest; /** * HTTP messages consist of requests from a client to a server and * responses from a server to a client. This interface defines the * methods common to each. */ class Request extends SymfonyHttpRequest implements RequestInterface { // ... }

Slide 19

Slide 19 text

PSR-7: WANT TO KNOW MORE? PSR-7: WANT TO KNOW MORE? Don't ask us. Ask this guy!

Slide 20

Slide 20 text

PPI MODULE EXTENDS ZF2 MODULE PPI MODULE EXTENDS ZF2 MODULE

Slide 21

Slide 21 text

PPI MODULE WITH ROUTERS PPI MODULE WITH ROUTERS

Slide 22

Slide 22 text

PPI MODULE WITH TEMPLATING ENGINES PPI MODULE WITH TEMPLATING ENGINES

Slide 23

Slide 23 text

OBJECT MEDIATION - NO ABSTRACTION! :-) OBJECT MEDIATION - NO ABSTRACTION! :-) No added abstraction on top of existing framework.

Slide 24

Slide 24 text

MODULE1 REST API MODULE MODULE1 REST API MODULE

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

MODULE2 MVC FULL STACK APP MODULE2 MVC FULL STACK APP

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

MODULE3 MVC FULL STACK APP MODULE3 MVC FULL STACK APP

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

PPI ROUTER PPI ROUTER We made a routing interoperability layer (Routing PSR?). Mediate routing and request information from PPI to Aura (for example). If a Routing PSR is created, we get to throw away a lot of code

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

3. PRACTICAL EXAMPLES 3. PRACTICAL EXAMPLES USING PPI USING PPI

Slide 33

Slide 33 text

INSTALLATION INSTALLATION 21st century. Use composer: Step 1: $ composer create-project -sdev --no-interaction \ ppi/skeleton-app /var/www/skeleton and for your convenience: Step 2 $ vagrant up ppi-lamp and now...

Slide 34

Slide 34 text

SKELETON APP SKELETON APP

Slide 35

Slide 35 text

APPLICATION STRUCTURE APPLICATION STRUCTURE public/index.php $env, 'debug' => $debug, 'rootDir' => realpath(__DIR__.'/../app') )); $app->loadConfig($app->getEnvironment().'/app.php'); // Handle requests $app->run();

Slide 36

Slide 36 text

MODULE STRUCTURE MODULE STRUCTURE Application | ├── Module.php ├── resources │ ├── config │ │ └── config.yml │ ├── routes │ │ ├── aura.php │ │ └── symfony.yml │ └── views │ └── index │ ├── index.html.mustache │ ├── index.html.php │ ├── index.html.smarty │ └── index.html.twig └── src ├── Classes │ └── CommunityHelper.php ├── Controller │ ├── Index.php │ └── Shared.php

Slide 37

Slide 37 text

MODULE CODE MODULE CODE class Module extends AbstractModule implements ModuleInterface { public function getRoutes() { return $this->getSymfonyRoutes(); // or return $this->getAuraRoutes(); } public function getAuraRoutes() { return $this->loadAuraRoutes(__DIR__ . '/resources/routes/aura.php'); } public function getSymfonyRoutes() { return $this->loadYamlRoutes(__DIR__ . '/resources/routes/symfony.yml'); } public function getConfig() { return $this->loadConfig(__DIR__ . '/resources/config/config.yml'); }

Slide 38

Slide 38 text

LET'S CHAT? LET'S CHAT? Gitter: Good ol'IRC: gitter.im/ppi/chat freenode#ppi @ppi_framework @dr4goonis @noiselabs

Slide 39

Slide 39 text

@ppi_framework THANKS. THANKS. Questions?