1
2
3
A yaml version of hook_menu()
A page callback.
Same thing as page callbacks. They perform some fancy logic (invented by you) and return markup, render arrays, etc.*
They translate and sanitize text, create links, log messages, query the database, etc. They depend on the services provided by functions such as: t(), l(), watchdog(), db_*(), etc.
"But," you say, "most of those old functional programming tools are gone! What are we to do?"
Well, the services they provided to us (translation, sanitization, link handling, logging etc.) are replaced with objects whose methods do the same thing.
Two types of classes...
Actions vs. Data
(_________ vs. _________)
It’s a useful object. Collections of related methods* to accomplish tasks that we all use a regular basis.
So far, we know that our controllers depend on these new things called Services… how do we go about using them?
We reach into a big bag of all the available Services (aka the Service Container) and select it by name.
The Service Container is just collection of the useful objects we need to do our job.
In the Controller’s create() method, we accept the Service Container as an argument. We use it to grab all the services we will need later on (in the actual page callback) and assign to class variables for later use.
Guess what you just did: You took your Controller and injected some of Services (useful objects) that it depends on. Dependency Injection isn’t so scary!
Why go through the hassle of injecting?
Why not just query the Services Container directly in our Controller's page callback when it’s time to use a given Service?
// Dump emails to text files. $conf['mail_system'] = array( 'default-system' => 'DevelMailLog', ); // Use memcache instead of database cache. $conf['cache_default_class'] = 'MemCacheDrupal';
The Drupal Console is a suite of tools that you run on a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation.
composer install vs. update
Update just one dependency instead of the whole project:
composer update symfony/symfony
To add a project easily:
composer require guzzlehttp/guzzle
~2.6.2 vs. 2.6.*
Does the work formerly handled by the Libraries module (sort of).
I challenge you to install the latest version of Drush via Composer.
Makes our life easier, and adds more magic into IDEs like PHPStorm.