Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Best Practices in Symfony2

Best Practices in Symfony2

Given at International PHP Conference 2013

Andreas Hucks

June 04, 2013

Transcript

71 slides
  1. Naming Things in Symphony • Follow PSR-0, PSR-1, PSR-2 •

    Find a common scheme for your team • Be explicit • Be consistent
  2. Care about your coding style • Again - follow PSR-0,

    PSR-1, PSR-2 • Use PHPCSFixer http://goo.gl/tEK4y
  3. FAIL a.k.a. „because I can“ • MyCompleteAppBundle (ok for small

    projects) • MyAppNeedingGlobalResourcesBundle • MyBundleInsideAnotherBundleBundle
  4. What should go into a Bundle • Bundles should be

    self-contained • Sets of Features • Examples: Forum, AdminPanel... • Configured in /app/config
  5. Your config options • YAML • XML • Annotations •

    INI • PHP Routing, Bundle Config, Parameters Services Validators, ORM/ODM
  6. Miscellaneous • Use XML for Service Definitions • Remember you

    can use Environment Variables (Apache, Nginx, ...) • Use %kernel.root_dir% as a reference
  7. Doctrine • Activate Metadata Cache • Activate Query Cache •

    Use factory-service to register Repositories & ObjectManagers as Services
  8. Security • Make sure there are no leaks in the

    security.yml access_control section! • Better: Check Authorization in Controller, possibly use SecurityExtraBundle

More Decks by Andreas Hucks

Other Decks in Programming