SlideShare una empresa de Scribd logo
1 de 129
Descargar para leer sin conexión
Drupal8 for Symfony
Developers
Antonio Perić-Mažar

12.05.2017 @ #phpday
@antonioperic
About me
• Antonio Perić-Mažar, mag. ing. comp.
• CEO, Co-Founder @ Locastic
• Co-Founder @ Shift Conference
• Software developer, Symfony2
• Open Source Contributor
• SFUGCRO

• www.locastic.com
• antonio@locastic.com
• @antonioperic
@antonioperic
Locastic
• We help clients create amazing web and mobile apps (since 2011)
• design and development agency
• mobile development
• web development
• UX/UI
• Training and Consulting
• Shift Conference, Symfony Croatia
• www.locastic.com
• @locastic
@antonioperic
Almost 25% of our
team are women
@antonioperic
Questions?
• Any Drupal experts/developers here?
• Symfony developers?
• Symfony developers without Drupal knowledge
@antonioperic
Drupal 101 for SF
developers
@antonioperic
Before we start, small
disclaimer
@antonioperic
My world is Symfony (still)
@antonioperic
♥
@antonioperic
@antonioperic
What this means
• Drupal8 doesn’t use full stack Symfony, it uses components (maybe in future)
• Moving Drupal to modern stack
• Building powerful CMS on top of Symfony components
• More learning for Drupal developers (OOP, Symfony, new concepts)
• Connecting two big communities
@antonioperic
Who is it for?
• Content strategist
• Site Administrators
• Content editors
• “Build stuff without writing code”
• v8.3.2
• Professional developers
• Bespoke applications
• “Make writing code easier”
@antonioperic
In Drupal 8 there's three different types of
knowledge that you're going to be using in
order to work with it effectively.
@antonioperic
@antonioperic
@antonioperic
@antonioperic
@antonioperic
Symfony2
Framework
Bundle
Symfony2
Bundles
Symfony2
CMF Bundles
Symfony2
Components
Partnered Libs
(twig, etc.)
CMF
Components
Symfony fullstack Drupal 8
Distribution
Drupal Core
Modules
Drupal Contrib
Modules
Drupal Core Libraries
Symfony2
Components
Partnered Libs
(twig, etc.)
Drupal
Components
@antonioperic
Symfony Components
• ClassLoader
• Console
• CssSelector
• DependencyInjection
• EventDispatcher
• HttpFoundation
• HttpKernel
• Process
• Routing
• Serializer
• Translation
• Validator
• Yaml
@antonioperic
• HTTP Kernel
• Request / Response
• Controllers
• Event Dispatching
• Listeners / Subscribers
Dependencyinjectioncontainer
@antonioperic
Development environment
@antonioperic
Or just use your Symfony
development environment
• PHP built-in server
• Vagrant
• Docker
• …
@antonioperic
Tools
@antonioperic
Drush
• update core and contrib
• download modules
• enable modules
• clear cache
• update db
• run cron
• import config
• export config
• create user
• change password
• one time login
• backup drupal
• restore drupal
• compile twig templates
*Type “drush” to get full list - www.drushcommands.com
@antonioperic
Drupal Console
• update core and contrib
• download modules
• enable modules
• clear cache
• update db
• run cron
• import config
• export config
• generate console command
• generate entity
• generate content type
• generate modules
• run unit test
*Type “drupal list” to get full list - drupalconsole.com/docs
@antonioperic
Installation
@antonioperic
How to install Drupal8
• Drush
• drush dl drupal
• Composer
• Download zip file
@antonioperic
Lets use composer
• drupal/drupal.
• This uses Drupal itself as a template for the new site. It is the simplest
solution but lacks additional configuration that can be helpful.



• drupal-composer/drupal-project.
• This open source project acts as a kickstarter for Composer-based Drupal
sites. It provides default configuration that otherwise needs to be added
manually.
@antonioperic
Let’s use composer
@antonioperic
Let’s use composer
composer create-project drupal/drupal
@antonioperic
Let’s use composer
composer require drupal/<modulename>
for example:
composer require drupal/token
@antonioperic
Run in browser
@antonioperic
Add some content
drupal create:nodes
@antonioperic
We have content but
something is missing
@antonioperic
WebProfiler
@antonioperic
composer require drupal/devel
@antonioperic
Under the Hood
@antonioperic
Request -> Response
@antonioperic
What happens when request
enters Drupal
1. Bootstrap configuration:
◦Read the settings.php file, generate some other settings dynamically, and store
them both in global variables and the DrupalComponentUtilitySettings singleton
object.
◦Start the class loader, that takes care of loading classes.
◦Set the Drupal error handler.
◦Detect if Drupal is actually installed. If it is not, redirect to the installer script.
2. Create the Drupal kernel.
3. Initialize the service container (either from cache or from rebuild).
4. Add the container to the Drupal static class.
5. Attempt to serve page from static page cache (just like Drupal 7).
6. Load all variables (variable_get).
@antonioperic
What happens when request
enters Drupal
7. Load other necessary (procedural) include files.
8. Register stream wrappers (public://, private://, temp:// and custom
wrappers).
9. Create the HTTP Request object (using the Symfony HttpFoundation
component).
10. Let the DrupalKernel handle it and return a response.
11. Send the response.
12. Terminate the request (modules can act upon this event).
Deeper in Drupal
End of Request
@antonioperic
Pipeline
1. After the controller returned a render array, the VIEW will be triggered by the HttpKernel, because
the controller result is not a Response, but a render array.
2. MainContentViewSubscriber is subscribed to the VIEW event. It checks whether the controller
result is an array, and if so, it guarantees to generate a Response.
3. Next, MainContentViewSubscriber checks whether the negotiated request format is supported:
1. Any format for which a main content renderer service exists (an implementation of
MainContentRendererInterface is supported.
2. If the negotiated request format is not supported, a 406 JSON response is generated, which lists
the supported formats in a machine-readable way (as per RFC 2616, section 10.4.7).
4. Otherwise, when the negotiated request format is supported, the corresponding main content
renderer service is initialized. A response is generated by calling
MainContentRendererInterface::renderResponse() on the service. That's it
@antonioperic
Main Content Renderes
• HTML: HtmlRenderer (text/html)
• AJAX: AjaxRenderer (application/vnd.drupal-ajax)
• Dialog: DialogRenderer (application/vnd.drupal-dialog)
• Modal: ModalRenderer (application/vnd.drupal-modal
@antonioperic
Routing
@antonioperic
Available “defaults” keys
• _controller

The specified method is simply called with the specified route parameters, and is
expected to return a response.
• _content

If specified, the _controller is set based on the request's mime type, and fills the
content of the response with the result of the specified method (usually a string or
render array).
• _form

If specified, the _controller is set to HtmlFormController::content, which responds with
the specified form. This form must be a fully qualified class name (or service id) that
implements FormInterface and usually extends FormBase. Indeed, form building has
also become object oriented!
• _entity_form

If specified, the _controller is set to HtmlEntityFormController::content, which
responds with the specified entity form (specified as {entity_type}.{add|edit|delete}).
@antonioperic
Available “defaults” keys
• _controller

The specified method is simply called with the specified route parameters, and is
expected to return a response.
• _content

If specified, the _controller is set based on the request's mime type, and fills the
content of the response with the result of the specified method (usually a string or
render array).
• _form

If specified, the _controller is set to HtmlFormController::content, which responds with
the specified form. This form must be a fully qualified class name (or service id) that
implements FormInterface and usually extends FormBase. Indeed, form building has
also become object oriented!
• _entity_form

If specified, the _controller is set to HtmlEntityFormController::content, which
responds with the specified entity form (specified as {entity_type}.{add|edit|delete}).
@antonioperic
Available “requirements” keys
• _permission

The current user must have the specified permission.
• _role

The current user must have the specified role.
• _method

The allowed HTTP methods (GET, POST, etc).
• _scheme

Set to https or http. The request scheme must be the same as the specified scheme. This
property is also taken into account when generating urls (Drupal::url(..)) rather than routing.
If set, urls will have this scheme set fixed.
• _node_add_access

A custom access check for adding new nodes of some node type.
• _entity_access

A generic access checker for entities.
• _format

Mime type formats
@antonioperic
Controllers
@antonioperic
Services
@antonioperic
Events / Listeners
@antonioperic
@antonioperic
Registering event subscribers
Here are the steps to register an event subscriber:
Define a service in your module, tagged with 'event_subscriber' (see the Services topic for instructions).
Define a class for your subscriber service that implements SymfonyComponentEventDispatcherEventSubscriberInterface
In your class, the getSubscribedEvents method returns a list of the events this class is subscribed to, and which methods on the class
should be called for each one. Example:
public static function getSubscribedEvents() {
// Subscribe to kernel terminate with priority 100.
$events[KernelEvents::TERMINATE][] = array('onTerminate', 100);
// Subscribe to kernel request with default priority of 0.
$events[KernelEvents::REQUEST][] = array('onRequest');
return $events;
}
@antonioperic
Building Custom Module

HelloPHPUK (HelloPHPDAY)
@antonioperic
Recap
• Symfony components are main building tool for D8
• DIC is backbone of Drupal
• DI for controllers is very easy
• Events are replacing hooks
• Building custom module is easy
• Hardest thing is to start
• This is just beginning there is a lot to learn about and from D8
@antonioperic
Thank you!
antonio@locastic.com
@antonioperic
www.locastic.com
Please rate my talk
https://joind.in/talk/2c50e

Más contenido relacionado

La actualidad más candente

Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedGil Fink
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnitWO Community
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful ControllersWO Community
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java DevelopersYakov Fain
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsYakov Fain
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium Zoe Gilbert
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11Smita B Kumar
 
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSShekhar Gulati
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerWO Community
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web ApplicationYakov Fain
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedGil Fink
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objectsRobert Bossek
 
25 Real Life Tips In Ruby on Rails Development
25 Real Life Tips In Ruby on Rails Development25 Real Life Tips In Ruby on Rails Development
25 Real Life Tips In Ruby on Rails DevelopmentBelighted
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Fabien Potencier
 

La actualidad más candente (20)

Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
 
Rails Best Practices
Rails Best PracticesRails Best Practices
Rails Best Practices
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
Dart for Java Developers
Dart for Java DevelopersDart for Java Developers
Dart for Java Developers
 
Speed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSocketsSpeed up your Web applications with HTML5 WebSockets
Speed up your Web applications with HTML5 WebSockets
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11
 
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJS
 
D2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRollerD2W Branding Using jQuery ThemeRoller
D2W Branding Using jQuery ThemeRoller
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
Seven Versions of One Web Application
Seven Versions of One Web ApplicationSeven Versions of One Web Application
Seven Versions of One Web Application
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objects
 
25 Real Life Tips In Ruby on Rails Development
25 Real Life Tips In Ruby on Rails Development25 Real Life Tips In Ruby on Rails Development
25 Real Life Tips In Ruby on Rails Development
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
 

Similar a Drupal8 for Symfony Developers (PHP Day Verona 2017)

A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonLuca Lusso
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To DrupalLauren Roth
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architectureHai Vo Hoang
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8Alkuvoima
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & DatabasesMuhammad Sajid
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Gaurav Varshney
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven developmentGil Fink
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 

Similar a Drupal8 for Symfony Developers (PHP Day Verona 2017) (20)

Drupal8 for Symfony Developers
Drupal8 for Symfony DevelopersDrupal8 for Symfony Developers
Drupal8 for Symfony Developers
 
A new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp LondonA new tool for measuring performance in Drupal 8 - DrupalCamp London
A new tool for measuring performance in Drupal 8 - DrupalCamp London
 
Introduction To Drupal
Introduction To DrupalIntroduction To Drupal
Introduction To Drupal
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Migrate to Drupal 8
Migrate to Drupal 8Migrate to Drupal 8
Migrate to Drupal 8
 
Migrating to Drupal 8
Migrating to Drupal 8Migrating to Drupal 8
Migrating to Drupal 8
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02Migrate 140123161042-phpapp02
Migrate 140123161042-phpapp02
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 

Más de Antonio Peric-Mazar

You call yourself a Senior Developer?
You call yourself a Senior Developer?You call yourself a Senior Developer?
You call yourself a Senior Developer?Antonio Peric-Mazar
 
Using API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconUsing API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconAntonio Peric-Mazar
 
Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Antonio Peric-Mazar
 
Are you failing at being agile? #digitallabin
Are you failing at being agile? #digitallabinAre you failing at being agile? #digitallabin
Are you failing at being agile? #digitallabinAntonio Peric-Mazar
 
Symfony 4: A new way to develop applications #ipc19
Symfony 4: A new way to develop applications #ipc19Symfony 4: A new way to develop applications #ipc19
Symfony 4: A new way to develop applications #ipc19Antonio Peric-Mazar
 
A year with progressive web apps! #webinale
A year with progressive web apps! #webinaleA year with progressive web apps! #webinale
A year with progressive web apps! #webinaleAntonio Peric-Mazar
 
The UI is the THE application #dpc19
The UI is the THE application #dpc19The UI is the THE application #dpc19
The UI is the THE application #dpc19Antonio Peric-Mazar
 
Symfony 4: A new way to develop applications #phpsrb
 Symfony 4: A new way to develop applications #phpsrb Symfony 4: A new way to develop applications #phpsrb
Symfony 4: A new way to develop applications #phpsrbAntonio Peric-Mazar
 
A year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUA year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUAntonio Peric-Mazar
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friendsAntonio Peric-Mazar
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Symfony4 - A new way of developing web applications
Symfony4 - A new way of developing web applicationsSymfony4 - A new way of developing web applications
Symfony4 - A new way of developing web applicationsAntonio Peric-Mazar
 
Build your business on top of Open Source
Build your business on top of Open SourceBuild your business on top of Open Source
Build your business on top of Open SourceAntonio Peric-Mazar
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Lessons learned while developing with Sylius
Lessons learned while developing with SyliusLessons learned while developing with Sylius
Lessons learned while developing with SyliusAntonio Peric-Mazar
 
Maintainable + Extensible = Clean ... yes, Code!
Maintainable + Extensible = Clean ... yes, Code! Maintainable + Extensible = Clean ... yes, Code!
Maintainable + Extensible = Clean ... yes, Code! Antonio Peric-Mazar
 
A recipe for effective leadership
A recipe for effective leadershipA recipe for effective leadership
A recipe for effective leadershipAntonio Peric-Mazar
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2Antonio Peric-Mazar
 

Más de Antonio Peric-Mazar (20)

You call yourself a Senior Developer?
You call yourself a Senior Developer?You call yourself a Senior Developer?
You call yourself a Senior Developer?
 
Using API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonyconUsing API Platform to build ticketing system #symfonycon
Using API Platform to build ticketing system #symfonycon
 
Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...Using API platform to build ticketing system (translations, time zones, ...) ...
Using API platform to build ticketing system (translations, time zones, ...) ...
 
Are you failing at being agile? #digitallabin
Are you failing at being agile? #digitallabinAre you failing at being agile? #digitallabin
Are you failing at being agile? #digitallabin
 
Symfony 4: A new way to develop applications #ipc19
Symfony 4: A new way to develop applications #ipc19Symfony 4: A new way to develop applications #ipc19
Symfony 4: A new way to develop applications #ipc19
 
A year with progressive web apps! #webinale
A year with progressive web apps! #webinaleA year with progressive web apps! #webinale
A year with progressive web apps! #webinale
 
The UI is the THE application #dpc19
The UI is the THE application #dpc19The UI is the THE application #dpc19
The UI is the THE application #dpc19
 
Symfony 4: A new way to develop applications #phpsrb
 Symfony 4: A new way to develop applications #phpsrb Symfony 4: A new way to develop applications #phpsrb
Symfony 4: A new way to develop applications #phpsrb
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
A year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMUA year with progressive web apps! #DevConMU
A year with progressive web apps! #DevConMU
 
Service workers are your best friends
Service workers are your best friendsService workers are your best friends
Service workers are your best friends
 
Progressive Web Apps are here!
Progressive Web Apps are here!Progressive Web Apps are here!
Progressive Web Apps are here!
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Symfony4 - A new way of developing web applications
Symfony4 - A new way of developing web applicationsSymfony4 - A new way of developing web applications
Symfony4 - A new way of developing web applications
 
Build your business on top of Open Source
Build your business on top of Open SourceBuild your business on top of Open Source
Build your business on top of Open Source
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Lessons learned while developing with Sylius
Lessons learned while developing with SyliusLessons learned while developing with Sylius
Lessons learned while developing with Sylius
 
Maintainable + Extensible = Clean ... yes, Code!
Maintainable + Extensible = Clean ... yes, Code! Maintainable + Extensible = Clean ... yes, Code!
Maintainable + Extensible = Clean ... yes, Code!
 
A recipe for effective leadership
A recipe for effective leadershipA recipe for effective leadership
A recipe for effective leadership
 
Building real time applications with Symfony2
Building real time applications with Symfony2Building real time applications with Symfony2
Building real time applications with Symfony2
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 

Último (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 

Drupal8 for Symfony Developers (PHP Day Verona 2017)

  • 1. Drupal8 for Symfony Developers Antonio Perić-Mažar
 12.05.2017 @ #phpday
  • 2. @antonioperic About me • Antonio Perić-Mažar, mag. ing. comp. • CEO, Co-Founder @ Locastic • Co-Founder @ Shift Conference • Software developer, Symfony2 • Open Source Contributor • SFUGCRO
 • www.locastic.com • antonio@locastic.com • @antonioperic
  • 3. @antonioperic Locastic • We help clients create amazing web and mobile apps (since 2011) • design and development agency • mobile development • web development • UX/UI • Training and Consulting • Shift Conference, Symfony Croatia • www.locastic.com • @locastic
  • 4. @antonioperic Almost 25% of our team are women
  • 5. @antonioperic Questions? • Any Drupal experts/developers here? • Symfony developers? • Symfony developers without Drupal knowledge
  • 8. @antonioperic My world is Symfony (still)
  • 11. @antonioperic What this means • Drupal8 doesn’t use full stack Symfony, it uses components (maybe in future) • Moving Drupal to modern stack • Building powerful CMS on top of Symfony components • More learning for Drupal developers (OOP, Symfony, new concepts) • Connecting two big communities
  • 12.
  • 13. @antonioperic Who is it for? • Content strategist • Site Administrators • Content editors • “Build stuff without writing code” • v8.3.2 • Professional developers • Bespoke applications • “Make writing code easier”
  • 14. @antonioperic In Drupal 8 there's three different types of knowledge that you're going to be using in order to work with it effectively.
  • 19. @antonioperic Symfony2 Framework Bundle Symfony2 Bundles Symfony2 CMF Bundles Symfony2 Components Partnered Libs (twig, etc.) CMF Components Symfony fullstack Drupal 8 Distribution Drupal Core Modules Drupal Contrib Modules Drupal Core Libraries Symfony2 Components Partnered Libs (twig, etc.) Drupal Components
  • 20. @antonioperic Symfony Components • ClassLoader • Console • CssSelector • DependencyInjection • EventDispatcher • HttpFoundation • HttpKernel • Process • Routing • Serializer • Translation • Validator • Yaml
  • 21. @antonioperic • HTTP Kernel • Request / Response • Controllers • Event Dispatching • Listeners / Subscribers Dependencyinjectioncontainer
  • 23.
  • 24.
  • 25. @antonioperic Or just use your Symfony development environment • PHP built-in server • Vagrant • Docker • …
  • 27. @antonioperic Drush • update core and contrib • download modules • enable modules • clear cache • update db • run cron • import config • export config • create user • change password • one time login • backup drupal • restore drupal • compile twig templates *Type “drush” to get full list - www.drushcommands.com
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. @antonioperic Drupal Console • update core and contrib • download modules • enable modules • clear cache • update db • run cron • import config • export config • generate console command • generate entity • generate content type • generate modules • run unit test *Type “drupal list” to get full list - drupalconsole.com/docs
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 40. @antonioperic How to install Drupal8 • Drush • drush dl drupal • Composer • Download zip file
  • 41. @antonioperic Lets use composer • drupal/drupal. • This uses Drupal itself as a template for the new site. It is the simplest solution but lacks additional configuration that can be helpful.
 
 • drupal-composer/drupal-project. • This open source project acts as a kickstarter for Composer-based Drupal sites. It provides default configuration that otherwise needs to be added manually.
  • 43. @antonioperic Let’s use composer composer create-project drupal/drupal
  • 44.
  • 45. @antonioperic Let’s use composer composer require drupal/<modulename> for example: composer require drupal/token
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 54.
  • 56.
  • 57. @antonioperic We have content but something is missing
  • 58.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 79.
  • 80. @antonioperic What happens when request enters Drupal 1. Bootstrap configuration: ◦Read the settings.php file, generate some other settings dynamically, and store them both in global variables and the DrupalComponentUtilitySettings singleton object. ◦Start the class loader, that takes care of loading classes. ◦Set the Drupal error handler. ◦Detect if Drupal is actually installed. If it is not, redirect to the installer script. 2. Create the Drupal kernel. 3. Initialize the service container (either from cache or from rebuild). 4. Add the container to the Drupal static class. 5. Attempt to serve page from static page cache (just like Drupal 7). 6. Load all variables (variable_get).
  • 81. @antonioperic What happens when request enters Drupal 7. Load other necessary (procedural) include files. 8. Register stream wrappers (public://, private://, temp:// and custom wrappers). 9. Create the HTTP Request object (using the Symfony HttpFoundation component). 10. Let the DrupalKernel handle it and return a response. 11. Send the response. 12. Terminate the request (modules can act upon this event).
  • 82. Deeper in Drupal End of Request
  • 83.
  • 84. @antonioperic Pipeline 1. After the controller returned a render array, the VIEW will be triggered by the HttpKernel, because the controller result is not a Response, but a render array. 2. MainContentViewSubscriber is subscribed to the VIEW event. It checks whether the controller result is an array, and if so, it guarantees to generate a Response. 3. Next, MainContentViewSubscriber checks whether the negotiated request format is supported: 1. Any format for which a main content renderer service exists (an implementation of MainContentRendererInterface is supported. 2. If the negotiated request format is not supported, a 406 JSON response is generated, which lists the supported formats in a machine-readable way (as per RFC 2616, section 10.4.7). 4. Otherwise, when the negotiated request format is supported, the corresponding main content renderer service is initialized. A response is generated by calling MainContentRendererInterface::renderResponse() on the service. That's it
  • 85. @antonioperic Main Content Renderes • HTML: HtmlRenderer (text/html) • AJAX: AjaxRenderer (application/vnd.drupal-ajax) • Dialog: DialogRenderer (application/vnd.drupal-dialog) • Modal: ModalRenderer (application/vnd.drupal-modal
  • 86.
  • 87.
  • 89.
  • 90. @antonioperic Available “defaults” keys • _controller
 The specified method is simply called with the specified route parameters, and is expected to return a response. • _content
 If specified, the _controller is set based on the request's mime type, and fills the content of the response with the result of the specified method (usually a string or render array). • _form
 If specified, the _controller is set to HtmlFormController::content, which responds with the specified form. This form must be a fully qualified class name (or service id) that implements FormInterface and usually extends FormBase. Indeed, form building has also become object oriented! • _entity_form
 If specified, the _controller is set to HtmlEntityFormController::content, which responds with the specified entity form (specified as {entity_type}.{add|edit|delete}).
  • 91. @antonioperic Available “defaults” keys • _controller
 The specified method is simply called with the specified route parameters, and is expected to return a response. • _content
 If specified, the _controller is set based on the request's mime type, and fills the content of the response with the result of the specified method (usually a string or render array). • _form
 If specified, the _controller is set to HtmlFormController::content, which responds with the specified form. This form must be a fully qualified class name (or service id) that implements FormInterface and usually extends FormBase. Indeed, form building has also become object oriented! • _entity_form
 If specified, the _controller is set to HtmlEntityFormController::content, which responds with the specified entity form (specified as {entity_type}.{add|edit|delete}).
  • 92. @antonioperic Available “requirements” keys • _permission
 The current user must have the specified permission. • _role
 The current user must have the specified role. • _method
 The allowed HTTP methods (GET, POST, etc). • _scheme
 Set to https or http. The request scheme must be the same as the specified scheme. This property is also taken into account when generating urls (Drupal::url(..)) rather than routing. If set, urls will have this scheme set fixed. • _node_add_access
 A custom access check for adding new nodes of some node type. • _entity_access
 A generic access checker for entities. • _format
 Mime type formats
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 100.
  • 101.
  • 104. @antonioperic Registering event subscribers Here are the steps to register an event subscriber: Define a service in your module, tagged with 'event_subscriber' (see the Services topic for instructions). Define a class for your subscriber service that implements SymfonyComponentEventDispatcherEventSubscriberInterface In your class, the getSubscribedEvents method returns a list of the events this class is subscribed to, and which methods on the class should be called for each one. Example: public static function getSubscribedEvents() { // Subscribe to kernel terminate with priority 100. $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); // Subscribe to kernel request with default priority of 0. $events[KernelEvents::REQUEST][] = array('onRequest'); return $events; }
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128. @antonioperic Recap • Symfony components are main building tool for D8 • DIC is backbone of Drupal • DI for controllers is very easy • Events are replacing hooks • Building custom module is easy • Hardest thing is to start • This is just beginning there is a lot to learn about and from D8