Symfony is not scaryValeriy TuzInuits
Is it scary?..
Is it scary?.. No! Let me try it!!!- Interior- Driving- Engine- Assembly- Service- etc
Symfony is not scary → Why I love Symfony2
Just try it!$ curl -s http://getcomposer.org/installer | php$ php composer.phar create-projectsymfony/framework-standard-e...
Get Symfony using Composer
Composer — dependency managerfor PHP
Composer.json{autoload: {psr-0: {}}name: My Projectdescription: Very cool onerequire: {php: >=5.3.3,symfony/class-loader: ...
Composer: run your PHP script
Time to look what weve got
Some demo included
Symfony is both:Full-stack frameworkSet of decoupled and standalone components
What are the Symfony components?Symfony components are:– Set of independent components– Each can be used separately– High ...
The list of Symfony2 componentsClass loaderConfigConsoleCssSelectorDependency InjectionFormEvent DispatcherHttp Foundation...
What is bundleBundle — set of files which implement singlefeatureGenerate bundle skeleton$ php app/console generate:bundle...
What is bundleTemplates go thereDatabase mappersRequest → Response
Controller: all together
Controller: routeURL and name of route
Controller: templateLook for template in:./Resources/views/Account/index.html.twig
Controller: get data from DBFetch Doctrinedata managerGet data from repository
TwigSyntax is very simple:{{ something }} - «Print something»{% something %} - «Do something»
TwigPrint var:{{ var }}«var» can be even an object. With __toString() methodpublic function __toString(){return $this->nam...
TwigConcise:<?php echo $var ?> → {{ var }}<?php echo htmlspecialchars($var, ENT_QUOTES, UTF-8 ?>{{ var |e }}
Twig: base template example
Twig: inheritance
Twig: documentation
Need smth Twig doesnt provide?Just do it!
Symfony and inspirationHow to rescue your PHP project with Symfony2componentshttp://habrahabr.ru/post/146521/http://www.sl...
Create your own framework on topof Symfony componentsRecipe from Fabien Potencierhttp://fabien.potencier.org/article/50/cr...
Symfony2 components: ConsoleSome examples of usage$ php app/console doctrine:generate:entitiesName/MyBundle/Entity/SomeEnt...
Symfony2 components: Console
Http FoundationRequest Response
Http Foundation: Request
Http Foundation: Response
Routing component
Services: Dependency Injection
Benefits:Only one instance of Mailer which can be usedin entire applicationCentralized configuration of MailerIt can be re...
Services container (DIC)Step 1: Create classStep 2: Register it as service by adding to theservice containerStep 3 ... n: ...
Create class
Register as service
Lets make example more complicatedStep 1: Create one more classStep 2: Inject service to itStep 3: Register it as service ...
Create class and inject service
Register new class as service
Use it
Lets improve it. Load services from file
Service.yml become a config file
Http Kernel
Request → Response flow
Events and listenersEvent 1 in HttpKernel->handle(): kernel.requestI.e. Security listener can throw Response objectwith 40...
Symfony2 is very kind:For visitorsFor developers
Symfony2 is very fastResponse class to manage HTTP cache:$response = new Response();$response->setMaxAge(600);$date = new ...
Symfony2 dev mode
Symfony2 dev mode
Symfony2 dev mode
Symfony2 follows standards...Autoloading standard: PSR-0Basic coding style: PSR-1Coding style: PSR-2http://www.php-fig.org/
… which means:It heavily uses namespaces, OOP, SOA, designpatterns, etchttp://php.net/manual/en/language.namespaces.phphtt...
Im almost finishedYellow: developmentBlue: stableGreen: maintenanceSince 3 June 2013 –long time supportfor v. 2.3
Symfony2 bundles
Try Symfony2But be careful — it can becomeaddictive from the very firstencounter :)
Questionsvalery@inuits.euvaleriy.tuz@gmail.com+380 67 505 42 76
Drupal symfony
Drupal symfony
Drupal symfony
Upcoming SlideShare
Loading in …5
×

Drupal symfony

350 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
350
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
15
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Drupal symfony

  1. 1. Symfony is not scaryValeriy TuzInuits
  2. 2. Is it scary?..
  3. 3. Is it scary?.. No! Let me try it!!!- Interior- Driving- Engine- Assembly- Service- etc
  4. 4. Symfony is not scary → Why I love Symfony2
  5. 5. Just try it!$ curl -s http://getcomposer.org/installer | php$ php composer.phar create-projectsymfony/framework-standard-edition/var/www/symfony/$ cd /var/www/symfony/$ php app/check.php (PHP >= 5.3.2, etc)
  6. 6. Get Symfony using Composer
  7. 7. Composer — dependency managerfor PHP
  8. 8. Composer.json{autoload: {psr-0: {}}name: My Projectdescription: Very cool onerequire: {php: >=5.3.3,symfony/class-loader: 2.2.*,}}
  9. 9. Composer: run your PHP script
  10. 10. Time to look what weve got
  11. 11. Some demo included
  12. 12. Symfony is both:Full-stack frameworkSet of decoupled and standalone components
  13. 13. What are the Symfony components?Symfony components are:– Set of independent components– Each can be used separately– High quality coded, tested and documentedSymfony components are just bricks but yourecompletely responsible to glue them
  14. 14. The list of Symfony2 componentsClass loaderConfigConsoleCssSelectorDependency InjectionFormEvent DispatcherHttp FoundationHttp KernelRoutingSecurityYaml
  15. 15. What is bundleBundle — set of files which implement singlefeatureGenerate bundle skeleton$ php app/console generate:bundle--namespace=BundleFolder/NameBundle--format=annotation
  16. 16. What is bundleTemplates go thereDatabase mappersRequest → Response
  17. 17. Controller: all together
  18. 18. Controller: routeURL and name of route
  19. 19. Controller: templateLook for template in:./Resources/views/Account/index.html.twig
  20. 20. Controller: get data from DBFetch Doctrinedata managerGet data from repository
  21. 21. TwigSyntax is very simple:{{ something }} - «Print something»{% something %} - «Do something»
  22. 22. TwigPrint var:{{ var }}«var» can be even an object. With __toString() methodpublic function __toString(){return $this->name;}
  23. 23. TwigConcise:<?php echo $var ?> → {{ var }}<?php echo htmlspecialchars($var, ENT_QUOTES, UTF-8 ?>{{ var |e }}
  24. 24. Twig: base template example
  25. 25. Twig: inheritance
  26. 26. Twig: documentation
  27. 27. Need smth Twig doesnt provide?Just do it!
  28. 28. Symfony and inspirationHow to rescue your PHP project with Symfony2componentshttp://habrahabr.ru/post/146521/http://www.slideshare.net/xavierlacot/symfony2-components-to-the-rescue-of-your-php-projects
  29. 29. Create your own framework on topof Symfony componentsRecipe from Fabien Potencierhttp://fabien.potencier.org/article/50/create-your-own-framework-on-top-of-the-symfony2-components-part-1
  30. 30. Symfony2 components: ConsoleSome examples of usage$ php app/console doctrine:generate:entitiesName/MyBundle/Entity/SomeEntity- generates getters and setters for SomeEntity$ php app/console container:debuglist of all available services
  31. 31. Symfony2 components: Console
  32. 32. Http FoundationRequest Response
  33. 33. Http Foundation: Request
  34. 34. Http Foundation: Response
  35. 35. Routing component
  36. 36. Services: Dependency Injection
  37. 37. Benefits:Only one instance of Mailer which can be usedin entire applicationCentralized configuration of MailerIt can be replaced by another service
  38. 38. Services container (DIC)Step 1: Create classStep 2: Register it as service by adding to theservice containerStep 3 ... n: Use it
  39. 39. Create class
  40. 40. Register as service
  41. 41. Lets make example more complicatedStep 1: Create one more classStep 2: Inject service to itStep 3: Register it as service as well
  42. 42. Create class and inject service
  43. 43. Register new class as service
  44. 44. Use it
  45. 45. Lets improve it. Load services from file
  46. 46. Service.yml become a config file
  47. 47. Http Kernel
  48. 48. Request → Response flow
  49. 49. Events and listenersEvent 1 in HttpKernel->handle(): kernel.requestI.e. Security listener can throw Response objectwith 403 Access denied response
  50. 50. Symfony2 is very kind:For visitorsFor developers
  51. 51. Symfony2 is very fastResponse class to manage HTTP cache:$response = new Response();$response->setMaxAge(600);$date = new DateTime();$date->modify(+600 seconds);$response->setExpires($date);
  52. 52. Symfony2 dev mode
  53. 53. Symfony2 dev mode
  54. 54. Symfony2 dev mode
  55. 55. Symfony2 follows standards...Autoloading standard: PSR-0Basic coding style: PSR-1Coding style: PSR-2http://www.php-fig.org/
  56. 56. … which means:It heavily uses namespaces, OOP, SOA, designpatterns, etchttp://php.net/manual/en/language.namespaces.phphttp://en.wikipedia.org/wiki/Software_design_patternhttp://en.wikipedia.org/wiki/Service-oriented_architecture
  57. 57. Im almost finishedYellow: developmentBlue: stableGreen: maintenanceSince 3 June 2013 –long time supportfor v. 2.3
  58. 58. Symfony2 bundles
  59. 59. Try Symfony2But be careful — it can becomeaddictive from the very firstencounter :)
  60. 60. Questionsvalery@inuits.euvaleriy.tuz@gmail.com+380 67 505 42 76

×