SlideShare una empresa de Scribd logo
PHP Tutorial Screencasts
Silex 



Microframework y
camino fácil de aprender
Symfony
!
!
!
!
!
!
• Husband of the much more
talented @leannapelham
PHP Tutorial Screencasts
knplabs.com
github.com/weaverryan
• Lead contributor to the Symfony documentation
!
• KnpLabs US - Symfony consulting, training, Kumbaya
!
• Writer for KnpUniversity.com
screencasts
Buenos Dias!
PHP Tutorial Screencasts
knplabs.com
github.com/weaverryan
• Viví en Querétaro en 2003 para cuatro meses

• Hablé casi 5 palabras en español.

• Este gringo estaba *sorprendido* por

el costumbre de besar para

saludar a las mujeres
Querétaro
Capítulo 1
!
La anatomía de cualquier
web framework
@weaverryan
@weaverryan
Una aplicación
compleja que nos
da saludos!
Configure Apache
O usen al web server
nativo de PHP!
php -S localhost:8000
@weaverryan
*Se puede usar este web server para Drupal también
Request -> Response Framework
Request:
GET /hello/drupalmx
Routing:
determina una función que puede
crear esta página (el controller)
El Controller:
nuestro código: construye la pagina
Response:
Hello drupalmx!@weaverryan
Una ruta que coincide
cuando el URI es
/hello/*@weaverryan
Si el URI coincide la ruta,
Silex ejecuta esta
función (el controller)
@weaverryan
El valor de {name} se
pasa como argumento
al controller
@weaverryan
Construimos la pagina
y celebrar!
@weaverryan
Request -> Response Framework
Request:
GET /hello/drupalmx
Routing:
determina una función que puede
crear esta página (el controller)
El Controller:
nuestro código: construye la pagina
Response:
Hello drupalmx!@weaverryan
Capítulo 2
!
Request-Response
Nuestro Trabajo:
Entender el “request” y
crear un “response”
@weaverryan
El Request
@weaverryan
GET /hello/drupalmx?page=5 HTTP/1.1!
Host: localhost:8000!
Connection: keep-alive!
Cache-Control: max-age=0!
Accept: text/html,application/xhtml+xml!
User-Agent: Mozilla/5.0!
Cookie: PHPSESSID=abcdefg; has_js=1;
El cliente nos da un mensaje sencillo que
describe qué quiere
El Request
@weaverryan
GET /hello/drupalmx?page=5 HTTP/1.1!
Host: localhost:8000!
Connection: keep-alive!
Cache-Control: max-age=0!
Accept: text/html,application/xhtml+xml!
User-Agent: Mozilla/5.0!
Cookie: PHPSESSID=abcdefg; has_js=1;
El cliente nos da un mensaje sencillo que
describe qué quiere
El método HTTP
El URI
El Request
@weaverryan
GET /hello/drupalmx?page=5 HTTP/1.1!
Host: localhost:8000!
Connection: keep-alive!
Cache-Control: max-age=0!
Accept: text/html,application/xhtml+xml!
User-Agent: Mozilla/5.0!
Cookie: PHPSESSID=abcdefg; has_js=1;
El cliente nos da un mensaje sencillo que
describe qué quiere
Los Request headers
El Response
@weaverryan
HTTP/1.1 200 OK!
Host: localhost:8000!
Cache-Control: no-cache!
Date: Wed, 23 Apr 2014 16:25:03 GMT!
Content-Type: text/html;!
!
Hello drupalmx
El Response
@weaverryan
El código del response
Los Response headersHTTP/1.1 200 OK!
Host: localhost:8000!
Cache-Control: no-cache!
Date: Wed, 23 Apr 2014 16:25:03 GMT!
Content-Type: text/html;!
!
<h1>Hello drupalmx</h1>
El cuerpo
En PHP, el “request”
mensaje se deconstruye
a los “superglobals”
@weaverryan
Para crear el response,
usamos “header” y echo
content
@weaverryan
@weaverryan
El Request en Silex
@weaverryan
El Response en Silex
Capítulo 3
!
Namespaces & Autoloading
https://www.flickr.com/photos/chrisjeriko/8599248142
El controller puede ser
cualquier función
Controller como método en clase
@weaverryan
Controller como método en clase
@weaverryan
PHP Namespaces
@weaverryan
Namespaces nos da nombres max largos	

nombre: DrupalacmeControllerDemoController
PHP Namespaces
@weaverryan
Autoloading
@weaverryan
No se necesita usar
require/include si:
!
A. El namespace es igual

al directorio
!
B. La clase es igual al

nombre de archivo
(+.php)
Se llama PSR-0
Capítulo 4:
!
Servicios y el “container”
Servicios: Objetos útiles
@weaverryan
El container: el objeto que
contiene todos los servicios
@weaverryan
En Silex, Symfony y Drupal 8,
existe un “container”.
!
Si lo tienes, puede usar los
servicios (objetos útiles)
Podemos usar el servicio
de Twig para
render un template?
@weaverryan
El “container” in SilexEl servicio “twig”
Request -> Response Framework
Request:
GET /hello/drupalmx
Routing:
determina una función que puede
crear esta página (el controller)
El Controller:
nuestro código: construye la pagina
Response:
Hello drupalmx!@weaverryan
Container	

(con servicios)
Capítulo 5:
!
Eventos
https://www.flickr.com/photos/bmp_creep/8064779382
Como Drupal “hooks”,
Silex tiene eventos
@weaverryan
Puede decir a Silex:

“Por favor, cuando
ocurra el evento XXXXX,
ejecute esa función”
@weaverryan
Request -> Response Framework
Request:
GET /hello/drupalmx
Routing:
determina una función que puede
crear esta página (el controller)
El Controller:
nuestro código: construye la pagina
Response:
Hello drupalmx!@weaverryan
Container	

(con servicios)
Evento:
kernel.request
Evento:
kernel.controller
Eventos:
kernel.view
kernel.response
@weaverryan
@weaverryan
Capítulo 6:
!
El Profiler
https://www.flickr.com/photos/fukagawa/415772853
Silex (por Symfony)
tiene un “profiler”
@weaverryan
@weaverryan
Contiene muchísimo
información, incluyendo
el “timeline”
@weaverryan
@weaverryan
1) kernel.request evento
2) Routing
3) Ejecuta el controller
4) Nuestro “listener” en kernel.view
Capítulo 7:
!
Todo lo mismo en Drupal 8
Cómo podemos crear
esto en Drupal 8?
Gracias a mi amigo Jesus
Olivas por ya tener blog
posts muy buenos
@jmolivas
jmolivas.com
http://bit.ly/d8-hello
1) Crear un module “acme”
@jmolivas http://bit.ly/d8-hello
2) Crear routing
@jmolivas http://bit.ly/d8-hello
Nombre del controller
3) Crear el controller
@jmolivas http://bit.ly/d8-hello
Module, Routing, Controller
@jmolivas http://bit.ly/d8-hello
@weaverryan
Tiene Drupal 8 un
container con servicios?
@weaverryan
El Container
Donde se debe encuentra
el container puede cambiar
antes del fin de Drpual 8
@weaverryan
@weaverryan
Pero sí hay un container
!
Y sí continue todos los
objetos útiles (servicios) de
Drupal
Hay eventos como Silex?
@weaverryan
¡Sí! Existen los mismos
eventos y más
1) Crear una clase “listener”
Silex: Microframework y camino fácil de aprender Symfony
Se ejecuta al fin del request	

!
Añadimos JavaScript a cada	

pagina en el sitio
2) Añadir un nuevo servicio
al container
@weaverryan
Ahora, el container tiene un servicio	

que se llama “acme.view_subscriber”
El event_subscriber tag dice al Drupal	

que este servicio quiere ser un “listener”	

para algunos eventos
@weaverryan
Y existe el profiler?
@weaverryan
https://drupal.org/project/webprofiler
@weaverryan
https://drupal.org/project/webprofiler
@weaverryan
https://drupal.org/project/webprofiler
@weaverryan
https://drupal.org/project/webprofiler
@weaverryan
https://drupal.org/project/webprofiler
@weaverryan
https://drupal.org/project/webprofiler
Capítulo 8
!
!
, y
Temas Principales
• Request/Response	

!
• Routing/Controller	

!
• PHP Namespaces/Autoloading	

!
• Services/Container

• Events/Listeners

• Profiler
@weaverryan
Todos son iguales en Silex, Drupal y Symfony
Se puede usar Silex
para aprender Drupal
Se puede usar Silex
para aprender Symfony
Se puede usar Symfony
para aprender Drupal
Al fin, tienen mas
herramientas para
cualquier problema
PHP Tutorial Screencasts
Ryan Weaver
@weaverryan
¡Gracias!
@weaveryan
@KnpUniversity

Más contenido relacionado

PDF
DeSymfony 2017 - Symfony en OpenSky
PPTX
HTML5 Web Workers
PDF
Ataque masivo a WordPress con ILLOWP
PDF
Convierte tu WordPress en una app con React Native
PDF
Garbage Collection en el JVM
PDF
Carlos Pascual #WPvalladolid 2014
PDF
Magallanes, Herramienta de despliegue PHP sencilla y poderosa
PDF
deSymfony 2017: Symfony 4, Symfony Flex y el futuro de Symfony
DeSymfony 2017 - Symfony en OpenSky
HTML5 Web Workers
Ataque masivo a WordPress con ILLOWP
Convierte tu WordPress en una app con React Native
Garbage Collection en el JVM
Carlos Pascual #WPvalladolid 2014
Magallanes, Herramienta de despliegue PHP sencilla y poderosa
deSymfony 2017: Symfony 4, Symfony Flex y el futuro de Symfony

La actualidad más candente (14)

PDF
Control de dos led's via Web en tiempo real con Raspberry y Firebase
PDF
Progressive Web Apps
PDF
Codemotion Madrid 2020 - Serverless con Micronaut
PDF
Webperf wordpress
PPTX
Azure functions
PPTX
Node-webkit
PDF
Distributed Task Processing with Celery - PyZH
PDF
La seguridad en WordPress de la A a la Z
PDF
Progressive Web Apps (español - spanish)
PDF
02practica completa
PDF
Windows PowerShell para Desarrolladores SharePoint | SolidQ Summit 2012
PPTX
PowerShell para administradores
PDF
Progressive Web Apps - .NET Conf CO 2017
PPT
Manos a la obra con Yupp PHP Framework
Control de dos led's via Web en tiempo real con Raspberry y Firebase
Progressive Web Apps
Codemotion Madrid 2020 - Serverless con Micronaut
Webperf wordpress
Azure functions
Node-webkit
Distributed Task Processing with Celery - PyZH
La seguridad en WordPress de la A a la Z
Progressive Web Apps (español - spanish)
02practica completa
Windows PowerShell para Desarrolladores SharePoint | SolidQ Summit 2012
PowerShell para administradores
Progressive Web Apps - .NET Conf CO 2017
Manos a la obra con Yupp PHP Framework
Publicidad

Similar a Silex: Microframework y camino fácil de aprender Symfony (20)

PDF
PDF
5 servidor web
PPTX
BilboStack - Php en el 2012
PDF
M1 introduccion a php
PPT
PHP IUTE
PDF
Webinar - Radiografía actual del lenguaje PHP
PDF
Rendimiento extremo en php
PDF
Cherokee
PDF
PHP.pdf PHP.pdf PHP.pdf PHP.pdf PHP.pdf PHP.pdf
PDF
La Caja de Herramientas del Desarrollador Moderno PHPConferenceAR
PPT
Curso TIC de PHP y MSQL
PDF
Desarrollo_web_con_PHP_y_MySQL.pdf
PPTX
Desarrollo responsivo con CakePHP y Foundation
PDF
Gestión Remota de Equipos con Python
PPT
Nodejs.introduccion
PDF
Curso php-my sql-clase-2
PPTX
Presentation OWASP Day @ FIUBA.AR
PPTX
PROCESAMIENTO DE TEXTO A SEÑALES DE VOZ.pptx
PDF
Curso php desde_cero
PDF
Tutorial mysqlphp
5 servidor web
BilboStack - Php en el 2012
M1 introduccion a php
PHP IUTE
Webinar - Radiografía actual del lenguaje PHP
Rendimiento extremo en php
Cherokee
PHP.pdf PHP.pdf PHP.pdf PHP.pdf PHP.pdf PHP.pdf
La Caja de Herramientas del Desarrollador Moderno PHPConferenceAR
Curso TIC de PHP y MSQL
Desarrollo_web_con_PHP_y_MySQL.pdf
Desarrollo responsivo con CakePHP y Foundation
Gestión Remota de Equipos con Python
Nodejs.introduccion
Curso php-my sql-clase-2
Presentation OWASP Day @ FIUBA.AR
PROCESAMIENTO DE TEXTO A SEÑALES DE VOZ.pptx
Curso php desde_cero
Tutorial mysqlphp
Publicidad

Más de Ryan Weaver (20)

PDF
Webpack Encore Symfony Live 2017 San Francisco
PDF
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
PDF
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
PDF
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
PDF
Symfony: Your Next Microframework (SymfonyCon 2015)
PDF
Guard Authentication: Powerful, Beautiful Security
PDF
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
PDF
Twig: Friendly Curly Braces Invade Your Templates!
PDF
Master the New Core of Drupal 8 Now: with Symfony and Silex
PDF
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
PDF
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
PDF
The Wonderful World of Symfony Components
PDF
A PHP Christmas Miracle - 3 Frameworks, 1 app
PDF
Symfony2: Get your project started
PDF
Symony2 A Next Generation PHP Framework
PDF
Hands-on with the Symfony2 Framework
PDF
Being Dangerous with Twig (Symfony Live Paris)
PDF
Being Dangerous with Twig
PDF
Doctrine2 In 10 Minutes
PDF
Dependency Injection: Make your enemies fear you
Webpack Encore Symfony Live 2017 San Francisco
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony: Your Next Microframework (SymfonyCon 2015)
Guard Authentication: Powerful, Beautiful Security
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Twig: Friendly Curly Braces Invade Your Templates!
Master the New Core of Drupal 8 Now: with Symfony and Silex
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Cool like a Frontend Developer: Grunt, RequireJS, Bower and other Tools
The Wonderful World of Symfony Components
A PHP Christmas Miracle - 3 Frameworks, 1 app
Symfony2: Get your project started
Symony2 A Next Generation PHP Framework
Hands-on with the Symfony2 Framework
Being Dangerous with Twig (Symfony Live Paris)
Being Dangerous with Twig
Doctrine2 In 10 Minutes
Dependency Injection: Make your enemies fear you

Último (20)

PPTX
Curso de generación de energía mediante sistemas solares
PPTX
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
DOCX
TRABAJO GRUPAL (5) (1).docxjesjssjsjjskss
PDF
MANUAL de recursos humanos para ODOO.pdf
PPTX
Sesion 1 de microsoft power point - Clase 1
PDF
Documental Beyond the Code (Dossier Presentación - 2.0)
PDF
ADMINISTRACIÓN DE ARCHIVOS - TICS (SENA).pdf
PDF
Diapositiva proyecto de vida, materia catedra
PDF
Influencia-del-uso-de-redes-sociales.pdf
PPTX
CLAASIFICACIÓN DE LOS ROBOTS POR UTILIDAD
PPTX
la-historia-de-la-medicina Edna Silva.pptx
PDF
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
PDF
TRABAJO DE TECNOLOGIA.pdf...........................
PDF
PRESENTACIÓN GENERAL MIPIG - MODELO INTEGRADO DE PLANEACIÓN
PDF
CONTABILIDAD Y TRIBUTACION, EJERCICIO PRACTICO
PDF
informe_fichas1y2_corregido.docx (2) (1).pdf
PPTX
sa-cs-82-powerpoint-hardware-y-software_ver_4.pptx
PDF
Estrategia de Apoyo de Daylin Castaño (5).pdf
DOCX
Trabajo grupal.docxjsjsjsksjsjsskksjsjsjsj
PPTX
Power Point Nicolás Carrasco (disertación Roblox).pptx
Curso de generación de energía mediante sistemas solares
ANCASH-CRITERIOS DE EVALUACIÓN-FORMA-10-10 (2).pptx
TRABAJO GRUPAL (5) (1).docxjesjssjsjjskss
MANUAL de recursos humanos para ODOO.pdf
Sesion 1 de microsoft power point - Clase 1
Documental Beyond the Code (Dossier Presentación - 2.0)
ADMINISTRACIÓN DE ARCHIVOS - TICS (SENA).pdf
Diapositiva proyecto de vida, materia catedra
Influencia-del-uso-de-redes-sociales.pdf
CLAASIFICACIÓN DE LOS ROBOTS POR UTILIDAD
la-historia-de-la-medicina Edna Silva.pptx
programa-de-estudios-2011-guc3ada-para-el-maestro-secundarias-tecnicas-tecnol...
TRABAJO DE TECNOLOGIA.pdf...........................
PRESENTACIÓN GENERAL MIPIG - MODELO INTEGRADO DE PLANEACIÓN
CONTABILIDAD Y TRIBUTACION, EJERCICIO PRACTICO
informe_fichas1y2_corregido.docx (2) (1).pdf
sa-cs-82-powerpoint-hardware-y-software_ver_4.pptx
Estrategia de Apoyo de Daylin Castaño (5).pdf
Trabajo grupal.docxjsjsjsksjsjsskksjsjsjsj
Power Point Nicolás Carrasco (disertación Roblox).pptx

Silex: Microframework y camino fácil de aprender Symfony