Skip to content

Commit 5e7493e

Browse files
committed
Initial commit
1 parent 289b3c2 commit 5e7493e

File tree

2 files changed

+140
-0
lines changed

2 files changed

+140
-0
lines changed

drupaler-learn-symfony.rst

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
Want to be a Drupal 8 Expert? Learn Symfony
2+
===========================================
3+
4+
I'm not a Drupal developer, but I *do* know **a lot** about Drupal 8. I know
5+
how the event system works, what a service is and how to work with them,
6+
and how the deepest and darkest of Drupal's request-response workflow looks.
7+
8+
How?
9+
10+
Because I'm a Symfony developer. And if you want to get a jumpstart on Drupal 8,
11+
you should be to. I'm *not* saying use Symfony instead of Drupal - they each
12+
solve very different problems.
13+
14+
Use both.
15+
16+
What you can Learn from Symfony
17+
-------------------------------
18+
19+
How about a list?
20+
21+
1) Code
22+
~~~~~~~
23+
24+
Simply put: Drupal 8 and Symfony share a lot of code called components (think,
25+
little PHP libraries). You can see these right inside the `Drupal core on GitHub`_
26+
and Symfony documents these individually (`Symfony Components`_). If you
27+
use Symfony right now, you're using a lot of code from Drupal 8.
28+
29+
2) Double your Weaponry
30+
~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
Symfony isn't always the right tool for a job, and neither is Drupal. But
33+
when you learn Symfony, you're doubling the number of tools that you can
34+
throw at any problem.
35+
36+
And because so much is share, you get these 2 tools at a discounted learning
37+
price. Nice!
38+
39+
3) PHP Namespaces
40+
~~~~~~~~~~~~~~~~~
41+
42+
Drupal 8 uses PHP namespaces. But great news! These aren't that hard, and
43+
after using Symfony for a bit (or any modern PHP framework or library), this
44+
learning curve will be a thing of the past.
45+
46+
And if you have 2 minutes, we have a screencast for you: `PHP Namespaces in 120 Seconds`_
47+
48+
4) Object-Oriented-ness
49+
~~~~~~~~~~~~~~~~~~~~~~~
50+
51+
Yay, objects! Interfaces! Flexibility!
52+
53+
Objects are everywhere in Symfony and Drupal (and again, in almost every PHP
54+
library these days). Use Symfony for a day and you'll be *way* ahead on this.
55+
56+
5) The Container
57+
~~~~~~~~~~~~~~~~
58+
59+
If you're a geek, one of the most exciting things about Drupal 8 is its use
60+
of a "dependency injection container". Quick, take 20 minutes and learn about
61+
dependency injection and containers: `Dependency Injection and the art of services and containers`_.
62+
I'll wait.
63+
64+
In Symfony, everything stops and starts with the container. And in Drupal 8,
65+
things will be much the same. Without going too far, the container (and good
66+
use of object-oriented principles) allows you to modify *any* part of the
67+
Drupal core without - as Larry Garfield puts it - killing any kittens (see
68+
`D8FTW: Hacking Core Without Killing Kittens`_).
69+
70+
Get into Symfony and you'll get right to the container. We even intro it
71+
early in our Symfony series (`Rendering a Template`_) cause it's just so
72+
darn important.
73+
74+
6) HttpKernel
75+
~~~~~~~~~~~~~
76+
77+
This is the beating heart of Symfony2 and Drupal 8.
78+
79+
It's a Symfony component (little PHP library!) and I'd tell you what it does,
80+
but then I'd have to kill you.
81+
82+
Actually, it's just a bit complex: it's the code that starts with request
83+
information and transforms it into a response. It involves dispatching Symfony
84+
events (another concept!), executing a controller and returning a Response.
85+
Geek out here: `The HttpKernel Component`_.
86+
87+
The code-sharing between Symfony and Drupal 8 doesn't include frivolous pieces:
88+
they share the most fundamental code that makes things go. No matter how
89+
different 2 different cars are, under the hood, they move using the same
90+
basic mechanics. (Bad pun:) So take Symfony for a drive.
91+
92+
Start using Symfony!
93+
--------------------
94+
95+
If you want to step through a real project, I of course highly recommend
96+
our Symfony2 series. I've listed the 4 episodes, with highlights that directly
97+
affect Drupalers:
98+
99+
* `Symfony2 Ep1`_ (install, bundles, routing, controller, services, Composer)
100+
* `Symfony2 Ep2`_ (a lot more controllers)
101+
* `Symfony2 Ep3`_ (JSON, dependency injection container, services, DI tags)
102+
* `Symfony2 Ep4`_ (Assetic, Deployment)
103+
104+
And for an even lower barrier to entry, try `Silex`_! Here's a Silex app::
105+
106+
require_once __DIR__.'/../vendor/autoload.php';
107+
108+
$app = new Silex\Application();
109+
110+
$app->get('/drupal/{version}', function($version) use($app) {
111+
return 'You\'re using Drupal '.$name;
112+
});
113+
114+
$app->run();
115+
116+
That's it. And this *still* uses all the most important components used in
117+
Drupal 8 - HttpKernel, EventDispatcher and a dependency injection container.
118+
119+
So start kicking butt in Drupal 8 right now and add another tool to your
120+
arsenal.
121+
122+
Happy Drupal-Symfonying!
123+
124+
.. _`Drupal core on GitHub`: https://github.com/drupal/drupal/tree/8.x/core/vendor/symfony
125+
.. _`Symfony Components`: http://symfony.com/doc/current/components/index.html
126+
.. _`PHP Namespaces in 120 Seconds`: knpuniversity.com/screencast/php-namespaces-in-120-seconds
127+
.. _`Dependency Injection and the art of services and containers`: http://knpuniversity.com/screencast/dependency-injection
128+
.. _`D8FTW: Hacking Core Without Killing Kittens`: http://www.palantir.net/blog/d8ftw-hacking-core-without-killing-kittens
129+
.. _`The HttpKernel Component`: http://symfony.com/doc/current/components/http_kernel/introduction.html

metadata.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,14 @@ blogs:
8888
from writing tutorials and collaborating.
8989
author: weaverryan
9090
category: news
91+
92+
"drupaler-learn-symfony":
93+
title: Want to be a Drupal 8 Expert? Start with Symfony
94+
published: 2014-02-04
95+
preview: |
96+
Drupal 8 changes a lot under the hood and those will make you
97+
a happier and more productive developer. But don't wait for its
98+
release to kick butt in the new world. That's right, just learn
99+
Symfony.
100+
author: weaverryan
101+
category: news

0 commit comments

Comments
 (0)