SlideShare a Scribd company logo
1 of 32
Download to read offline
Symfony and Drupal 8
Kunal Kursija @ iksula-services-pvt-ltd
ABOUT ME
I am Kunal Kursija.
I am a Drupal Developer based in Mumbai(India).
I have 5 years experience working with:
• Drupal Site Building
• Drupal Back End Development
• Drupal Front End Development
TOPICS
1. What is Symfony?
2. Why Symfony?
3. Symfony Components.
4. Symfony Components Used By Drupal
5. Pre-Requisites for Drupal 8 Development.
1. What is Symfony?
Symfony is a set of PHP Components, a Web Application framework, a Philosophy, and a
Community — all working together in harmony.
Projects using symfony: Drupal, Magento, Joomla, Composer, Laravel, Behat…
2. Why Symfony?
Symfony is Object-Oriented, Secure, and stable framework and provides Decoupled and
reusable components.
Since Drupal 8 steps into OOPS World, Using Symfony reduced the need to ‘Reinvent
the wheel’.
Due to Symfony, The development process was fast.
Save Drupaler’s time as Symfony components are managed and maintained by Symfony
Community developers.
3. Symfony Components
Symfony components are set of decoupled and reusable PHP Libraries.
They are becoming the standard foundation on which the best PHP applications are
built on.
You can use any of these components in your own applications independently from the
Symfony Framework.
Examples: Routing, Yaml, Serializer, EventDispatcher, DependencyInjection and Many
More !!!
4. Symfony Components Used By Drupal
First Things First, Drupal is not using Symfony as a Full Stack Framework. Rather, It is
using Decoupled Symfony Components.
Symfony Components used by Drupal are found in Drupal Core’s Composer.json file.
Let’s go through some symfony components…
ClassLoader
Loads your project classes automatically if they follow some standard PHP conventions.
By following PSR-4 standard’s, Class loader loads Classes, Traits, Interfaces globally.
So, no more usage of Php’s ‘require_once’ & ‘include’ in your Drupal projects.
The EventDispatcher component provides tools that allow your application components
to communicate with each other by dispatching events and listening to them.
Dispatching events in Drupal 8:
$event_dispatcher = Drupal::service('event_dispatcher');

$event_dispatcher->dispatch(‘Event_name’, parameters());
EventDispatcher
The HttpFoundation component defines an object-oriented layer for the HTTP
specification.
In PHP, The HTTP Request is represented by $_GET, $_POST, $_FILES,
$_COOKIE, $_SESSION …
HTTP Foundation Replaces the above Global PHP variables with it’s Object Oriented
layer.
HttpFoundation
Provides the building blocks to create flexible and fast HTTP-based frameworks.
Provides a structured process for converting a Request into a Response by making use of
the EventDispatcher.
HttpKernel
The Routing component maps an HTTP request to a set of configuration variables.
Routing
Turns objects into a specific format (XML, JSON, ...) and the other way around.
Serializer
The DependencyInjection component allows you to standardise and centralise the way
objects are constructed in your application.
DependencyInjection
The Yaml component loads and dumps YAML files.
The Symfony Yaml component parses YAML strings to convert them to PHP arrays,
And vice-versa.
YAML Ain't Markup Language, is a human friendly data serialization standard for all
programming languages.
It is a great format for your configuration files.
Yaml
Provides tools to validate classes.
Enables specifying validation rules for classes using XML, YAML, PHP or annotations,
which can then be checked against instances of these classes.
Validator
The Translation component provides tools to internationalize your application.
Translation
5. Pre-Requisites
Namespaces
Services
Service Container
Dependency Injection
Annotations
Plugins
Namespaces
What are namespaces? Defining Namespaces Using Namespaces
Namespaces helps over come the problem of Name Collision.
Php Classes, Traits & Interfaces in Drupal are namespaced.
What are namespaces?
Defined by keyword 'namespace'. Example: namespace Drupalblock;
In Drupal, Each module has it's own namespace.
The namespace of all Drupal core components, as well as contributed modules, begins
with Drupal
The module's namespace is mapped to the ./src/ folder in the module directory. Hence,
Drupalvegetable → modules/vegetable/src/
Defining Namespaces
Used by using ‘use’ keyword.
Example: use DrupalCoreControllerControllerBase;
‘use’ statements are written at the top of php files.
Using Namespaces
What are Services? Defining Services Using Services
Services
A Service is nothing but an PHP Object/Class.
Services are written to perform Generic Functionality
Examples:
1. Sending Emails
2. Sending SMS
Tagged Services: Special services called by Drupal based on Tags.
What are Services?
Services are defined in your custom modules.
Services are defined in ‘modulename.services.yml’ file.
Example:
Defining Services
Accessing Services in global functions.
Using Services
Accessing Services via Dependency Injection.
$service = Drupal::service('d8_first_custom_module');
We will cover this in dependency injection section.
A Service container is nothing but an PHP Object/Class.
It is a special type of object, inside which all services live.
Service Container manages instantiation of services.
If you have the service container, then you can fetch a service by using that service's id.
Service Container is also called Dependency Injection Container.
Service Container
Dependency injection is the preferred method for accessing and using services in Drupal
8 and should be used whenever possible. Rather than calling out to the global services
container.
Dependency Injection
Annotations are the nothing but DocBlock Comments.
They hold metadata about your class, interface, functions e.t.c.
They do not affect your program directly, And are read & parsed at run-time by Annotation engine.
If you miss the annotation, Your program might compile fine - But it will not work as expected.
Annotations help in Plugin Discovery.
Annotations
Plugins are small pieces of functionality that are swappable.
Plugins that perform similar functionality are of the same plugin type.
Example:
• Field Widget = Plugin Type
• Each Widget Type = Plugin
Plugins
Questions?
Thank You !

More Related Content

Similar to Symfony Components Power Drupal 8

Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!sparkfabrik
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKDominik Renzel
 
Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Antonio Peric-Mazar
 
Drupal 8 preview_slideshow
Drupal 8 preview_slideshowDrupal 8 preview_slideshow
Drupal 8 preview_slideshowTee Malapela
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Hibernate interview questions
Hibernate interview questionsHibernate interview questions
Hibernate interview questionsvenkata52
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKDominik Renzel
 
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from TechlightningFrequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from TechlightningArul ChristhuRaj Alphonse
 
Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 3camp
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsSu Zin Kyaw
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview QuestionsSyed Shahul
 
Hibernate reference1
Hibernate reference1Hibernate reference1
Hibernate reference1chandra mouli
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source ApplittleMAS
 
Drupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPDrupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPAntonio Peric-Mazar
 

Similar to Symfony Components Power Drupal 8 (20)

Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!Do you know what your Drupal is doing_ Observe it!
Do you know what your Drupal is doing_ Observe it!
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
 
Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)
 
Drupal 8 preview_slideshow
Drupal 8 preview_slideshowDrupal 8 preview_slideshow
Drupal 8 preview_slideshow
 
Express node js
Express node jsExpress node js
Express node js
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Hibernate interview questions
Hibernate interview questionsHibernate interview questions
Hibernate interview questions
 
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDKHow to Build & Develop Responsive Open Learning Environments with the ROLE SDK
How to Build & Develop Responsive Open Learning Environments with the ROLE SDK
 
Learn Drupal 8 Render Pipeline
Learn Drupal 8 Render PipelineLearn Drupal 8 Render Pipeline
Learn Drupal 8 Render Pipeline
 
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from TechlightningFrequently asked MuleSoft Interview Questions and Answers from Techlightning
Frequently asked MuleSoft Interview Questions and Answers from Techlightning
 
Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2 Osiąganie mądrej architektury z Symfony2
Osiąganie mądrej architektury z Symfony2
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Rails interview questions
Rails interview questionsRails interview questions
Rails interview questions
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
Hibernate reference1
Hibernate reference1Hibernate reference1
Hibernate reference1
 
Spring boot
Spring bootSpring boot
Spring boot
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
 
Drupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHPDrupal8 for Symfony developers - Dutch PHP
Drupal8 for Symfony developers - Dutch PHP
 

More from Kunal Kursija

Spick and span php unit tests using data providers
Spick and span php unit tests using data providersSpick and span php unit tests using data providers
Spick and span php unit tests using data providersKunal Kursija
 
Php 8: String Helpers
Php 8: String HelpersPhp 8: String Helpers
Php 8: String HelpersKunal Kursija
 
Decoupling entity validations from entity forms
Decoupling entity validations from entity formsDecoupling entity validations from entity forms
Decoupling entity validations from entity formsKunal Kursija
 
Decoupling entity-validations from entity-forms
Decoupling entity-validations from entity-formsDecoupling entity-validations from entity-forms
Decoupling entity-validations from entity-formsKunal Kursija
 
Modern java script features
Modern java script featuresModern java script features
Modern java script featuresKunal Kursija
 
Modern JavaScript features
Modern JavaScript featuresModern JavaScript features
Modern JavaScript featuresKunal Kursija
 
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.x
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.xDrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.x
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.xKunal Kursija
 

More from Kunal Kursija (7)

Spick and span php unit tests using data providers
Spick and span php unit tests using data providersSpick and span php unit tests using data providers
Spick and span php unit tests using data providers
 
Php 8: String Helpers
Php 8: String HelpersPhp 8: String Helpers
Php 8: String Helpers
 
Decoupling entity validations from entity forms
Decoupling entity validations from entity formsDecoupling entity validations from entity forms
Decoupling entity validations from entity forms
 
Decoupling entity-validations from entity-forms
Decoupling entity-validations from entity-formsDecoupling entity-validations from entity-forms
Decoupling entity-validations from entity-forms
 
Modern java script features
Modern java script featuresModern java script features
Modern java script features
 
Modern JavaScript features
Modern JavaScript featuresModern JavaScript features
Modern JavaScript features
 
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.x
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.xDrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.x
DrupalCamp Mumbai 2017: Drupal 8 and Commerce 2.x
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

Symfony Components Power Drupal 8

  • 1. Symfony and Drupal 8 Kunal Kursija @ iksula-services-pvt-ltd
  • 2. ABOUT ME I am Kunal Kursija. I am a Drupal Developer based in Mumbai(India). I have 5 years experience working with: • Drupal Site Building • Drupal Back End Development • Drupal Front End Development
  • 3. TOPICS 1. What is Symfony? 2. Why Symfony? 3. Symfony Components. 4. Symfony Components Used By Drupal 5. Pre-Requisites for Drupal 8 Development.
  • 4. 1. What is Symfony? Symfony is a set of PHP Components, a Web Application framework, a Philosophy, and a Community — all working together in harmony. Projects using symfony: Drupal, Magento, Joomla, Composer, Laravel, Behat…
  • 5. 2. Why Symfony? Symfony is Object-Oriented, Secure, and stable framework and provides Decoupled and reusable components. Since Drupal 8 steps into OOPS World, Using Symfony reduced the need to ‘Reinvent the wheel’. Due to Symfony, The development process was fast. Save Drupaler’s time as Symfony components are managed and maintained by Symfony Community developers.
  • 6. 3. Symfony Components Symfony components are set of decoupled and reusable PHP Libraries. They are becoming the standard foundation on which the best PHP applications are built on. You can use any of these components in your own applications independently from the Symfony Framework. Examples: Routing, Yaml, Serializer, EventDispatcher, DependencyInjection and Many More !!!
  • 7. 4. Symfony Components Used By Drupal First Things First, Drupal is not using Symfony as a Full Stack Framework. Rather, It is using Decoupled Symfony Components. Symfony Components used by Drupal are found in Drupal Core’s Composer.json file. Let’s go through some symfony components…
  • 8. ClassLoader Loads your project classes automatically if they follow some standard PHP conventions. By following PSR-4 standard’s, Class loader loads Classes, Traits, Interfaces globally. So, no more usage of Php’s ‘require_once’ & ‘include’ in your Drupal projects.
  • 9. The EventDispatcher component provides tools that allow your application components to communicate with each other by dispatching events and listening to them. Dispatching events in Drupal 8: $event_dispatcher = Drupal::service('event_dispatcher');
 $event_dispatcher->dispatch(‘Event_name’, parameters()); EventDispatcher
  • 10. The HttpFoundation component defines an object-oriented layer for the HTTP specification. In PHP, The HTTP Request is represented by $_GET, $_POST, $_FILES, $_COOKIE, $_SESSION … HTTP Foundation Replaces the above Global PHP variables with it’s Object Oriented layer. HttpFoundation
  • 11. Provides the building blocks to create flexible and fast HTTP-based frameworks. Provides a structured process for converting a Request into a Response by making use of the EventDispatcher. HttpKernel
  • 12. The Routing component maps an HTTP request to a set of configuration variables. Routing
  • 13. Turns objects into a specific format (XML, JSON, ...) and the other way around. Serializer
  • 14. The DependencyInjection component allows you to standardise and centralise the way objects are constructed in your application. DependencyInjection
  • 15. The Yaml component loads and dumps YAML files. The Symfony Yaml component parses YAML strings to convert them to PHP arrays, And vice-versa. YAML Ain't Markup Language, is a human friendly data serialization standard for all programming languages. It is a great format for your configuration files. Yaml
  • 16. Provides tools to validate classes. Enables specifying validation rules for classes using XML, YAML, PHP or annotations, which can then be checked against instances of these classes. Validator
  • 17. The Translation component provides tools to internationalize your application. Translation
  • 19. Namespaces What are namespaces? Defining Namespaces Using Namespaces
  • 20. Namespaces helps over come the problem of Name Collision. Php Classes, Traits & Interfaces in Drupal are namespaced. What are namespaces?
  • 21. Defined by keyword 'namespace'. Example: namespace Drupalblock; In Drupal, Each module has it's own namespace. The namespace of all Drupal core components, as well as contributed modules, begins with Drupal The module's namespace is mapped to the ./src/ folder in the module directory. Hence, Drupalvegetable → modules/vegetable/src/ Defining Namespaces
  • 22. Used by using ‘use’ keyword. Example: use DrupalCoreControllerControllerBase; ‘use’ statements are written at the top of php files. Using Namespaces
  • 23. What are Services? Defining Services Using Services Services
  • 24. A Service is nothing but an PHP Object/Class. Services are written to perform Generic Functionality Examples: 1. Sending Emails 2. Sending SMS Tagged Services: Special services called by Drupal based on Tags. What are Services?
  • 25. Services are defined in your custom modules. Services are defined in ‘modulename.services.yml’ file. Example: Defining Services
  • 26. Accessing Services in global functions. Using Services Accessing Services via Dependency Injection. $service = Drupal::service('d8_first_custom_module'); We will cover this in dependency injection section.
  • 27. A Service container is nothing but an PHP Object/Class. It is a special type of object, inside which all services live. Service Container manages instantiation of services. If you have the service container, then you can fetch a service by using that service's id. Service Container is also called Dependency Injection Container. Service Container
  • 28. Dependency injection is the preferred method for accessing and using services in Drupal 8 and should be used whenever possible. Rather than calling out to the global services container. Dependency Injection
  • 29. Annotations are the nothing but DocBlock Comments. They hold metadata about your class, interface, functions e.t.c. They do not affect your program directly, And are read & parsed at run-time by Annotation engine. If you miss the annotation, Your program might compile fine - But it will not work as expected. Annotations help in Plugin Discovery. Annotations
  • 30. Plugins are small pieces of functionality that are swappable. Plugins that perform similar functionality are of the same plugin type. Example: • Field Widget = Plugin Type • Each Widget Type = Plugin Plugins