Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Silex, desarrollo web ágil y profesional con PHP

19.320 Aufrufe

Veröffentlicht am

Silex es el microframework de moda en el mundo PHP. Silex te permite desarrollar aplicaciones web profesionales con una agilidad sin precedentes. Su aprendizaje es tan rápido y sencillo que podrás dominarlo en menos de una hora.

Veröffentlicht in: Technologie
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Silex, desarrollo web ágil y profesional con PHP

  1. 1. Silex desarrollo web ágil y profesional con PHPBILBOSTACK JAVIER EGUILUZ26 ENERO 2013
  2. 2. Gracias a la organización.Asier Fran Ibon Vicenç
  3. 3. Agenda 1. Introducción 2. Programando aplicaciones 3. DEMO 4. Buenas prácticas 5. Puntos débiles
  4. 4. Introducción
  5. 5. ¿Por qué?
  6. 6. En el mundo de los negocios...1. Rápido2. Barato3. Bueno
  7. 7. En el mundo de los negocios...1. Rápido ELIGE DOS2. Barato3. Bueno
  8. 8. En el mundo de la programación...1. Bien hecho2. Terminado a tiempo3. Barato
  9. 9. En el mundo de la programación...1. Bien hecho ELIGE UNA2. Terminado a tiempo3. Barato
  10. 10. En el mundo de la programación...✔ Bien1. hecho✔ Terminado a tiempo2.✔ Barato3. Con Silex puedes tenerlo todo
  11. 11. ¡no tengo¡quiero hacerlo bien! tiempo!
  12. 12. ¿Qué es Silex?
  13. 13. Foto: Wikipedia
  14. 14. Curiosity (2012) Sojourner (2007)Foto: Wikipedia
  15. 15. Sojourner Curiosity (2007) (2012)Masa 11 kg 900 kgCoste ($) 150 M 1.800 MMemoria RAM 64 KB 256 MBCPU 2 MHz 200 MHz
  16. 16. Es importante tener en cuenta que...• El grande jamás podrá ser tan ágil como el pequeño.• El pequeño jamás podrá competir en potencia y funcionalidad con el grande.
  17. 17. SilexThe PHP micro-frameworkbased on the Symfony2Components el logo de Silex
  18. 18. los dos son frameworks y usan los mismos componentes, pero...
  19. 19. ...Symfony es un framework muy grande y Silex es un framework muy pequeño
  20. 20. Silex Symfony2Peso 5 MB 8 MBArchivos 3.366 6.578Nivel dificultadFlexibilidad
  21. 21. Los creadores de SilexIgor Wiedler Fabien Potencier@igorw @fabpot
  22. 22. + fácil + calidad- calidad - facil
  23. 23. + fácil + calidad- calidad - facil
  24. 24. Programando aplicaciones
  25. 25. Funciones anónimas y closures
  26. 26. Función normalfunction suma($a, $b) { return $a + $b;}
  27. 27. Función anónimafunction ($a, $b) { return $a + $b;}
  28. 28. Usando una función anónima$app->get(..., function ($a, $b) { return $a + $b;});
  29. 29. Closure$a = 3;function ($b) { return $a + $b;}
  30. 30. Closure$a = 3; NO FUNCIONAfunction ($b) { return $a + $b;}
  31. 31. Closure$a = 3;function ($b) use ($a) { return $a + $b;}
  32. 32. El código más común de Silex$app->get(..., function ($var) use ($app) { // ...});
  33. 33. El primer ejemplo
  34. 34. Holamundo.
  35. 35. http://bilbostack.com/hola
  36. 36. Hola Mundo en Silexrequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  37. 37. Cargar clases automáticamenterequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  38. 38. Crear la aplicación Silexrequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  39. 39. Ejecutar código para una URLrequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  40. 40. Arrancar la aplicaciónrequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  41. 41. Hola Mundo en Silexrequire_once __DIR__./../vendor/autoload.php;$app = new SilexApplication();$app->get(/hola, function() { return Hola mundo;});$app->run();
  42. 42. Sinatra / Rubyrequire sinatraget /hola do "Hola mundo."end
  43. 43. node.js / JavaScriptvar http = require(http);http.createServer(function (request, response) { response.writeHead( 200, { Content-Type: text/plain } ); response.end(Hola mundon);}).listen(80);
  44. 44. Un ejemplo real
  45. 45. Fo rk m eo ngithub.com/ Gi tH ubjaviereguiluz/bilbostack
  46. 46. Enrutamiento
  47. 47. Ruta de la portada$app->get(/, function () use ($app) { // ...});
  48. 48. Ruta básica$app->get(/agenda, function () use ($app) { // ...});
  49. 49. Ruta con partes variables$app->get(/speakers/{slug}, function () use ($app) { // ...});
  50. 50. Ruta con partes variables$app->get(/speakers/{slug}, function () use ($app) { // ...});
  51. 51. Ruta con partes variables$app->get(/speakers/{slug}, function () use ($app) { // ...});/speakers/pablo-garaizar/speakers/carlos-sanchez/speakers/esto-esta-mal
  52. 52. Otros métodos HTTP$app->post(/registro, function () use ($app) { // ...});
  53. 53. Otros métodos HTTP$app->post(/registro, function () use ($app) { // ...});$app->put( );$app->delete( );
  54. 54. Ruta para todos los métodos HTTP$app->match(/registro, function () use ($app) { // ...});
  55. 55. Ruta para algunos métodos HTTP$app->match(/registro, function () use ($app) { // ...})->method(GET|POST);
  56. 56. Rutas con variables$app->get(/speakers/{slug}, function ($slug) { // ...});
  57. 57. Rutas con variables$app->get(/speakers/{track}/{slug}, function ($track, $slug) use ($app) { // ...});
  58. 58. Variables especialesuse SymfonyComponentHttpFoundationRequest;$app->get(/speakers/{slug}, function (Request $request, $slug) { // ...});
  59. 59. Variables especialesuse SymfonyComponentHttpFoundationRequest;$app->get(/speakers/{slug}, function (Request $request, $slug) { // ...});
  60. 60. Variables especialesuse SymfonyComponentHttpFoundationRequest;$app->get(/speakers/{slug}, function (Request $request, $slug) { // ...});$request->server->get(HTTP_USER_AGENT)$request->get(slug)
  61. 61. Modificando las variables de la ruta$app->get(/schedule/{slug}, function ($slug) use ($app) { // ...})->convert(slug, function ($slug) { return strtolower($slug);});
  62. 62. Modificando las variables de la ruta$app->get(/schedule/{slug}, function ($slug) use ($app) { // ...})->convert(slug, function ($slug) { return str_replace(-, _, $slug);});
  63. 63. Restringiendo las variables de la ruta$app->get(/schedule/{track}, function ($track){ // ...})->assert(track, d+);
  64. 64. Restringiendo las variables de la ruta$app->get(/schedule/{track}, function ($track){ // ...})->assert(track, trackd+);
  65. 65. Restringiendo las variables de la ruta$app->get(/schedule/{track}, function ($track){ // ...})->assert(track, 1|2);
  66. 66. Valores por defecto$app->get(/schedule/{track}, function ($track){ // ...})->value(track, 1);
  67. 67. Valores por defecto$app->get(/schedule/{track}, function ($track){ // ...})->value(track, 1);/schedule/schedule/1
  68. 68. Rutas con nombre$app->get(/, function () use ($app) { // ...})->bind(portada);
  69. 69. Controladores
  70. 70. Controlador básico$app->get(/donde-comer, function () use ($app) { return $app[twig]->render(comer.twig);})->bind(comer);
  71. 71. Controlador típico$app->get(/, function () use ($app) { $ponentes = $app[ponentes]; return $app[twig]->render(portada.twig, array(ponentes => $ponentes) );})->bind(portada);
  72. 72. Controlador típico$app->get(/, function () use ($app) { $ponentes = $app[ponentes]; return $app[twig]->render(portada.twig, array(ponentes => $ponentes) );})->bind(portada);
  73. 73. Gestión de errores$app->get(/speakers/{slug}, function ($slug) use ($app) { if (...) { $app->abort(404, "No existe el ponente."); } // ... return $app[twig]->render(ponente.twig,...);})->bind(ponente);
  74. 74. Gestión de errores$app->get(/speakers/{slug}, function ($slug) use ($app) { if (...) { $app->abort(404, "No existe el ponente."); } // ... return $app[twig]->render(ponente.twig,...);})->bind(ponente);
  75. 75. Controlador especial para errores$app->error(function (Exception $e, $code) use ($app) { // ...});
  76. 76. Controlador especial para errores$app->error(function (Exception $e, $code) use ($app) { // ...});
  77. 77. Esqueleto de una aplicación Silex$app->get(/, ...)->bind(portada);$app->get(/agenda, ...)->bind(agenda);$app->get(/speakers/{slug}, ...)->bind(ponente);$app->get(/schedule/{slug}, ...)->bind(ponencia);
  78. 78. 1 aplicación = 1 archivo$app->get(/, ...)->bind(portada);$app->get(/agenda, ...)->bind(agenda);$app->get(/speakers/{slug}, ...)->bind(ponente);$app->get(/schedule/{slug}, ...)->bind(ponencia); controllers.php
  79. 79. 1 aplicación = 1 archivo EL ORDEN$app->get(/, ...)->bind(portada);$app->get(/agenda, ...)->bind(agenda); IMPORTA$app->get(/speakers/{slug}, ...)->bind(ponente);$app->get(/schedule/{slug}, ...)->bind(ponencia); controllers.php
  80. 80. Middlewares (filtros)
  81. 81. Petición HTTP Objeto Request Silex Tu aplicaciónPágina HTML Silex Objeto Response
  82. 82. Petición HTTP Objeto Request ! Silex Tu aplicación ! !Página HTML Silex Objeto Response
  83. 83. Filtro before$app->before(function (Request $request) { // ...});
  84. 84. Secuencia de ejecución• Buscar la ruta que pide el usuario.• Comprobar la seguridad.• Ejecutar filtro before()• Ejecutar controlador de la ruta
  85. 85. Ejemplo de filtro before$app->before(function (Request $request) { if (...) { return new RedirectResponse(/login); }});
  86. 86. Filtro after$app->after(function (Request $request, Response $response) { // ...});
  87. 87. Secuencia de ejecución• Buscar la ruta que pide el usuario.• Comprobar la seguridad.• Ejecutar filtro before( )• Ejecutar controlador de la ruta.• Ejecutar filtro after( )• Enviar respuesta al usuario.
  88. 88. Ejemplo de filtro after$app->after(function (Request $request) { log(...);});
  89. 89. Ejemplo de filtro after$app->after(function (Request $request) { log(...);}); ¿Dónde está mi respuesta?
  90. 90. Filtro finish$app->finish(function (Request $request, Response $response) { // ...});
  91. 91. Cada ruta con su filtro$app->get(/, ...)->bind(portada)->before(...);$app->get(/agenda, ...)->bind(agenda)->before(...)->after(...);$app->get(/speakers/{slug}, ...)->bind(ponente)->before(...);$app->get(/schedule/{slug}, ...)->bind(ponencia)->before(...);
  92. 92. Proveedores de servicios
  93. 93. Bases de datos FormulariosNúcleo Plantillasde Silex Caché HTTP Envío de emails proveedores
  94. 94. Bases de datos FormulariosNúcleo Plantillasde Silex Caché HTTP Envío de emails proveedores
  95. 95. Bases de datos FormulariosNúcleo Plantillasde Silex Caché HTTP Envío de emails proveedores
  96. 96. Bases de datos FormulariosNúcleo Plantillasde Silex Caché HTTP Envío de emails
  97. 97. Bases de datos Serializador SeguridadFormularios Logger SesionesValidación Emails PlantillasCaché HTTP URL
  98. 98. Usar formularios de Symfony2use SilexProviderFormServiceProvider;// ...$app->register(new FormServiceProvider());
  99. 99. Acceder a BBDD con Doctrine2use SilexProviderDoctrineServiceProvider;// ...$app->register(new DoctrineServiceProvider());
  100. 100. Utilizar las plantillas de Twiguse SilexProviderTwigServiceProvider;// ...$app->register(new TwigServiceProvider(), array( twig.path => array(__DIR__./../templates), twig.options => array(...),));
  101. 101. DEMO
  102. 102. github.com/javiereguiluz/bilbostack ub G itH e on k m F or
  103. 103. Instalación
  104. 104. Descargar archivo comprimido silex.sensiolabs.org
  105. 105. Descargar archivo comprimido
  106. 106. Descargar archivo comprimido
  107. 107. Descargar archivo comprimido
  108. 108. Instalación via composer.json{ "require": { "silex/silex": "1.0.*" }, "minimum-stability": "dev"}
  109. 109. Instalación via composer.json{ "require": { "fabpot/silex-skeleton": "*" }, "minimum-stability": "dev"}
  110. 110. Instalación recomendada$ composer create-project fabpot/silex-skeleton --stability=dev
  111. 111. web/ src/ src/index.php app.php controllers.php
  112. 112. web/ src/ src/index.php app.php controllers.phpNo tocar
  113. 113. web/ src/ src/index.php app.php controllers.phpNo tocar Activas servicios
  114. 114. web/ src/ src/index.php app.php controllers.phpNo tocar Activas $app servicios ->get(/, ...});
  115. 115. Buenasprácticas
  116. 116. Organizandolos controladores
  117. 117. $app->get(/, ...); // ... controllers.php$app->get(/, ...); $app->get(/, ...); blog.php backend.php
  118. 118. Importando controladores$app->mount(/blog, include blog.php);$app->mount(/admin, include backend.php);
  119. 119. Importando controladores$app->mount(/blog, include blog.php);$app->mount(/admin, include backend.php);
  120. 120. Importando controladores$app->mount(/blog, include blog.php);$app->mount(/admin, include backend.php);PORTADA: /PORTADA DE BLOG: /blog/PORTADA DE BACKEND: /admin/
  121. 121. 1 aplicación = 1 archivo$app->get(/, ...)->bind(portada);$app->get(/agenda, ...)->bind(agenda);$app->get(/speakers/{slug}, ...)->bind(ponente);$app->get(/schedule/{slug}, ...)->bind(ponencia); controllers.php
  122. 122. 1 aplicación pequeña = 1 archivo$app->get(/, ...)->bind(portada);$app->get(/agenda, ...)->bind(agenda);$app->get(/speakers/{slug}, ...)->bind(ponente);$app->get(/schedule/{slug}, ...)->bind(ponencia); controllers.php
  123. 123. 1 aplicación mediana = N archivos$app->get(/, ...)->bind(portada); $app->get(/, ...);$app->get(/agenda, ...)- $app->get(/ver, ...);>bind(agenda); $app->get(/listar, ...);$app->get(/speakers/{slug}, ...)->bind(ponente); blog.php$app->get(/schedule/{slug}, ...)->bind(ponencia); $app->get(/, ...); controllers.php backend.php
  124. 124. Escalando unaaplicación Silex
  125. 125. Controladores como clasesnamespace IgorwShopController;use SilexApplication;use SymfonyComponentHttpFoundationRequest;class ShopController{ public function indexAction(Request $request, Application $app) { ... }}
  126. 126. Controladores como clases$app->get(/, controller(shop/index));$app->match(/login, controller(shop/login));$app->get(/product, controller(shop/product));
  127. 127. http://igor.io/2012/11/09/scaling-silex.html
  128. 128. Puntosdébiles
  129. 129. i18n DepuraciónORM DocumentaciónESI
  130. 130. i18n (internacionalización)• Fácil traducir contenidos {{ "Hola Mundo"|trans }}• No es cómodo traducir rutas y contenidos de la base de datos.
  131. 131. ORM• No hay soporte oficial del ORM completo (Doctrine2).• No hay ORM alternativos ligeros.• Si tu aplicación necesita un ORM, puede ser demasiado grande para Silex.
  132. 132. Depuración// activar el modo debug$app[debug] = true;// activar el loguse SilexProviderMonologServiceProvider;$app->register(new MonologServiceProvider(),array( monolog.logfile => __DIR__./../logs/dev.log,));
  133. 133. Mensajes de error
  134. 134. ESI• Silex incluye soporte de ESI.• Su uso es bastante incómodo (comparado con Symfony2).
  135. 135. Documentación• Todas las características de Silex están documentadas.• No es tan abundante como la de Symfony2.
  136. 136. Documentación• Oficial silex.sensiolabs.org/documentation• Traducción librosweb.es/silex
  137. 137. Conclusiones
  138. 138. Conclusiones• Silex es un microframework, pero no es un juguete.
  139. 139. Conclusiones• Silex es un microframework, pero no es un juguete.• Silex sirve para cualquier aplicación web que no sea enorme.
  140. 140. Conclusiones• Silex es un microframework, pero no es un juguete.• Silex sirve para cualquier aplicación web que no sea enorme.• Silex reduce a “horas” el tiempo de desarrollo de aplicaciones enteras.
  141. 141. Conclusiones• Silex es un microframework, pero no es un juguete.• Silex sirve para cualquier aplicación web que no sea enorme.• Silex reduce a “horas” el tiempo de desarrollo de aplicaciones enteras.• Silex combina la agilidad de PHP con la profesionalidad de Symfony.
  142. 142. GRACIAS.
  143. 143. Contacto • javier.eguiluz@gmail.com • twitter.com/javiereguiluz • github.com/javiereguiluz • linkedin.com/in/javiereguiluzdomingo, 27 de enero de 13

×