PHP Frameworks in 2015 - The rise of middleware
-
Upload
emmanuel-ide -
Category
Software
-
view
81 -
download
0
Transcript of PHP Frameworks in 2015 - The rise of middleware
![Page 1: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/1.jpg)
the rise of middleware PHP FrameworksEmmanuel Idé
![Page 2: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/2.jpg)
PHP FrameworksPhase IDecouple!OO / MVC
![Page 3: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/3.jpg)
PHP FrameworksPhase IIDecouple!!IoC / Dependency Injection
![Page 4: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/4.jpg)
PHP FrameworksPhase IIIDecouple!!!MiddleWare
![Page 5: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/5.jpg)
What is middlewarehttps://mattstauffer.co/blog/laravel-5.0-middleware-filter-style
The way this works is that middleware implements a decorator pattern: it takes the request, does something, and returns another request object to the next layer of the stack.
![Page 6: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/6.jpg)
What is middlewarehttp://stackoverflow.com/questions/2256569/what-is-rack-middleware
Middleware is a dreadful term which refers to any software component/library which assists with but is not directly involved in the execution of some task.
![Page 7: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/7.jpg)
Decorator Pattern
Attach additional responsibilities to an object dynamically, without using subclassing.
![Page 8: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/8.jpg)
Pipes-and-Filters Pattern
The Pipes and Filters architectural pattern provides a structure for systems, having components that process a stream of data (filters) and connections that transmit data between adjacent components (pipes).
![Page 9: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/9.jpg)
HTP Interfaces1997: Java Servlet2003: Python WSGI2007: Ruby Rack2010: Node Express2011: Symfony2 HttpKernelInterface
![Page 10: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/10.jpg)
HTP Interfaces1997: Java Servlet2003: Python WSGI2007: Ruby Rack2010: Node Express2011: Symfony2 HttpKernelInterface
![Page 11: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/11.jpg)
Rack definitionsEnvironment Environment variables representing the HTTP request. Mostly taken from CGI, but has additional Rack-specific variables.
Response The response format. It is an array with three elements: The status code, a hash of headers and a list of strings for the body.
ApplicationAn app is an object with a call method. The input argument is an env hash, the return value a response array.
![Page 12: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/12.jpg)
Rubyclass HelloWorld def call(env) [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] endend
class HelloWorld def call(env) [200, {"Content-Type" => "text/plain"}, ["Hello world!"]] end end
![Page 13: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/13.jpg)
Why shall we care, we have SAPI
$_SERVER, $_ENV, $_GET, $_POST, $_COOKIE, $_FILES and $_REQUEST
![Page 14: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/14.jpg)
stackphp.com
Stack is a convention for composing HttpKernelInterface middlewares.
![Page 15: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/15.jpg)
Symfony 2HttpKernelInterface
- No specification
- coupled to the framework
![Page 16: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/16.jpg)
Symfony 3
the HttpKernel is going to be split into several smaller ones
![Page 17: PHP Frameworks in 2015 - The rise of middleware](https://reader035.fdocuments.net/reader035/viewer/2022071823/55bdba74bb61eb8a768b46af/html5/thumbnails/17.jpg)
Who supports stack?
Laravel, Symfony, Drupal, etc.. (ZF3 roadmap announces alternative to stack)