- Senior Architect, Palantir.net
- Drupal 8 Web Services Lead
- Drupal Representative, PHP-FIG
- Advisor, Drupal Association
- implements Huggable
Symfony 2
- Tier-1 PHP framework
- Loosely coupled
- Helped inspire PHP 5.3-era revolution
- Incubator for Composer
You
- Know Drupal 7
- Kind of Know Drupal 8
- Want to move down-stack
Do I need to learn Symfony to use Drupal 8?
No!
SF family tree graphic, Drupal is sibling
- Drupal sibling of SF
- Only uses < 1/3 of Components
- Very different to work with
Assumption: You know Drupal (version?)
Want to learn Symfony
Read the docs!
Gotchas that are different, so you know not to trip
Audience
- No expectation of UI config; all config is direct YAML.
-- parameters.yml compiled into container
-- other config is compiled out to separate PHP file from container, but one big file.
- Single dev/prod toggle.
- Enable module by editing code.
- Code scaffolding from CLI is a big thing. (Will be in D8, too.)
- Most dev tools are CLI commands.
- Sonata Admin bundle? Still not the same.
- Organic Groups: It's Not a Thing
Architecture
- No functions! (capes)
- Theme whole page at once, with one Twig template/inheritance.
- Services, shallow access.
- Always 4 ways of doing everything: YAML, XML, Annotation, PHP (at least)
-- "Drupal way" is much stricter than "Symfony way".
-- May even vary by 3rd party bundle within a single project. Stick to one for your own code.
- Metaprogramming via YAML/Annotations rather than user config. Both metaprogramming.
Extending
- "You're supposed to hack core". (Or at least anything outside vendor.)
- Bundles vs modules: Not huge difference.
- AppBundle ~ custom module
- Listeners vs. Hooks
-- See KNP videos "Journey to the center of Symfony"
-- Symfony limits use of view listener; Drupal uses it heavily.
- Composer all the things.
-- Deployment changes, need to produce prod artifact or similar.
-- Need to manually regen more (assetic, etc.). Doctrine migrations, run yourself.
-- Drupal has more tools to help here (auto-detect out of sync DB, clear cache from UI, etc.)
- Nested routes in Symfony, not in Drupal.
- No URL aliases. Use lookup slugs instead, manually.
Data
- Doctrine
-- All entities in code
-- All fields single-value; need separate Entity for multi-value.
-- Many differences between SQL and Mongo, mostly in service names.
-- Different event listeners from core. :-(
- File handling is even more primitive than Drupal (if you believe that...)
- Something about forms? Need to use Symfony forms first...
Security
- Authentication/authorization is totally weird, hard, different.
-- Security bundle is odd, easy to get wrong.
-- See alternative: https://packagist.org/packages/knpuniversity/guard
-- security.yml: regex on path to determine needed role.
-- Recently added expressions on route def
-- Annotations on controller method (http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/security.html)
Similarities:
- Container and services, yo!
- HttpKernel, Request/response, kernel listeners
- Twig, although used a bit differently (nesting templates)
- Hook ~ Listener
-
Symfony
(For Drupal Developers)
Presented by Larry Garfield (@Crell)