Symfony 2 Best Practices
Speaker: Bao Nguyen
bao.nguyen@semantics.vn
10/13/2013
10/13/2013
Why Symfony
2.3?
Why best
practices?

10/13/2013
Code Standard
• PSR-0, PSR-1, PSR-2
• Bundle Structure Best Practices
• Bundle namespace:
• SmvnSomeCoolBundle
• SmvnBundl...
Only commit your own code
•
•
•
•
•
•
•
•
•
•
•

/.idea
/nbproject
/composer.phar
/vendor
/app/config/parameters.yml
/app/...
Tools
• Manage Assets (js+css) with Assetic
• Sensio Framework Extra
• Security Component (Firewall, Users, ACL …)
• Twig
...
Reusability
• Template inheritance
• Template macro
• Twig Extension
• Base Controller / Embed Controller
• Service
• Form...
Pitfall
• Security Context: isGranted() vs. hasRole()
• Event Listener vs. Event Subscriber
• Doctrine Schema Update vs. D...
Thank you for
listening!
bao.nguyen@semantics.vn

10/13/2013
Upcoming SlideShare
Loading in …5
×

Symfony 2 Best Practices

3,781 views

Published on

This is my slide for Drupal 8 Meetup. The practices are collected from my working and managing experience on Symfony 2 throughout my projects.

Published in: Technology
0 Comments
8 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,781
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
40
Comments
0
Likes
8
Embeds 0
No embeds

No notes for slide

Symfony 2 Best Practices

  1. 1. Symfony 2 Best Practices Speaker: Bao Nguyen bao.nguyen@semantics.vn 10/13/2013
  2. 2. 10/13/2013
  3. 3. Why Symfony 2.3? Why best practices? 10/13/2013
  4. 4. Code Standard • PSR-0, PSR-1, PSR-2 • Bundle Structure Best Practices • Bundle namespace: • SmvnSomeCoolBundle • SmvnBundleSomeCoolBundle • SmvnBundleSmvnSomeCoolBundle • Service naming, Route naming • Prefix with bundle name and vendor name (for reusable bundle) • Use service alias (image_resizer vs. smvn_image_resizer) 10/13/2013
  5. 5. Only commit your own code • • • • • • • • • • • /.idea /nbproject /composer.phar /vendor /app/config/parameters.yml /app/cache /app/logs /app/phpunit.xml *.php~ /web/bundles /web/uploads 10/13/2013
  6. 6. Tools • Manage Assets (js+css) with Assetic • Sensio Framework Extra • Security Component (Firewall, Users, ACL …) • Twig • Doctrine Extension • Console component • PHPUnit / Behat • Configuration system (DI & Parameters) • Jenkins Jobs for PHP (http://jenkins-php.org/) 10/13/2013
  7. 7. Reusability • Template inheritance • Template macro • Twig Extension • Base Controller / Embed Controller • Service • Form Type • Bundle (try knpbundles.com) • Extract bundle from project for reusability 10/13/2013
  8. 8. Pitfall • Security Context: isGranted() vs. hasRole() • Event Listener vs. Event Subscriber • Doctrine Schema Update vs. Doctrine Schema Migration • app/cache, app/logs write-permission: Never use umask • Nesting limit in xdebug • Case sensitive Annotation name (@Entity vs @entity) • Avoid using dev-master in composer.json • Update vendor  Clear cache  Clear Assetics  Update schema 10/13/2013
  9. 9. Thank you for listening! bao.nguyen@semantics.vn 10/13/2013

×