SlideShare a Scribd company logo
1 of 46
Introduction to Symfony components
and helper components in Drupal 8
Ankit Babbar
Drupal Developer at Valuebound
Volunteer at SPIC MACAY
twitter: ankitbabbar
History of PHP
Functional vs OOPs Programming
Frameworks
3rd Party Libraries
Namespace
PHP-FIG
YAML
Composer
Awesome Drupal CMS +
Symfony2 Framework
+ Best PHP Practices from Community
https://cipix.nl/understanding-drupal-8-part-1-general-structure-framework
HTTP Foundation
Request -> Response
HTTP request looks like:
GET /foo.html HTTP/1.1
Host: example.com
Accept: text/html
User-Agent: Mozialla/5.0 (Macintosh)
GET
Retrieve the resource from the
server
POST
Create a resource on the
server
PUT
Update the resource on the
server
DELETE
Delete the resource from the
server
Request
HTTP response looks like:
HTTP/1.1 200 OK
Date: Sat, 25 Jul 2015 10:30:00 IST
Server: apache2/2.xx
Content-Type: text/html
<html>
Response
Routing
YAML: YAML Ain’t Markup Language
Sample Router
hello_world.content:
path: ‘/hello-world'
defaults:
_controller: 'DrupalhelloControllerHelloController::content'
_title: 'Hello World'
requirements:
_permission: 'access content'
Controllers
Sample Hello World Controller
class HelloController extends ControllerBase {
public function content() {
return array(
'#type' => 'markup',
'#markup' => t('Hello, World!'),
);
}
}
Application Flow
Event Dispatcher
HTTP Kernel
Dependency Injection
class Notifier {
private $mailer;
public function __construct() {
$this->mailer = new Mailer();
}
public function notify() {
…
$this->mailer->send($from, $to, $msg);
…
}
}
class Notifier {
private $mailer;
public function __construct(MailInterface $m) {
$this->mailer = $m;
}
public function notify() {
….
$this->mailer->send($from, $to, $msg);
…
}
}
$mailer = new SpecialMailer();
$notifier = new Notifier($mailer);
Composer
Sample composer.json for hello_world module
{
"name": “drupal/hello_world",
"require": {
"mailchimp/mailchimp": "2.0.6"
}
}
Namespace
+
Autoloading
Full Controller File Look like:
<?php
/**
* @file
* Contains DrupalhelloControllerHelloController.
*/
namespace DrupalhelloController;
use DrupalCoreControllerControllerBase;
class HelloController extends ControllerBase {
public function content() {
return array(
'#type' => 'markup',
'#markup' => t('Hello, World!'),
);
}
}
?>
Serializer
Array
Serialization
FormatObject
DeSerialization
Validator
1. Symfony Documentation
2. DrupalCon Denver 2012: DRUPAL 8 MEETS SYMFONY2
https://www.youtube.com/watch?v=Gr71z_WoejM
3. UNDERSTANDING DRUPAL 8: https://cipix.nl/understanding-drupal-8-part-1-general-
structure-framework
4. DrupalCon Portland 2013: DEPENDENCY INJECTION IN DRUPAL 8
https://www.youtube.com/watch?v=kocJ6pn9kEc
5. DrupalCon Denver 2012: DRUPAL 8 MEETS SYMFONY2
https://www.youtube.com/watch?v=Gr71z_WoejM
6. Symfony en Drupal 8
http://symfony.com/doc/current/components/event_dispatcher/introduction.html#introduction
7. Unravelling the Drupal 8 Plugin System https://drupalize.me/blog/201409/unravelling-drupal-
8-plugin-system
8. Drupal 8 Plugin System https://www.youtube.com/watch?v=2o5uY-iOoMo
9. PSR-4 http://www.php-fig.org/psr/psr-4/
10. Namespaces http://php.net/manual/en/language.namespaces.php
References and Resources
Thank You!
Questions?

More Related Content

What's hot

Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90minsLarry Cai
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extensionVõ Duy Tuấn
 
Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Helgi Þormar Þorbjörnsson
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
EdTechJoker Spring 2020 - Lecture 8 Drupal again
EdTechJoker Spring 2020 - Lecture 8 Drupal againEdTechJoker Spring 2020 - Lecture 8 Drupal again
EdTechJoker Spring 2020 - Lecture 8 Drupal againBryan Ollendyke
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 
Flask patterns
Flask patternsFlask patterns
Flask patternsit-people
 
Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Helgi Þormar Þorbjörnsson
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindDylan Jay
 
PHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksPHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksRoyston Olivera
 

What's hot (20)

Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 
CakePHP 3.0: Embracing the future
CakePHP 3.0: Embracing the futureCakePHP 3.0: Embracing the future
CakePHP 3.0: Embracing the future
 
Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009Website releases made easy with the PEAR installer, OSCON 2009
Website releases made easy with the PEAR installer, OSCON 2009
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
EdTechJoker Spring 2020 - Lecture 8 Drupal again
EdTechJoker Spring 2020 - Lecture 8 Drupal againEdTechJoker Spring 2020 - Lecture 8 Drupal again
EdTechJoker Spring 2020 - Lecture 8 Drupal again
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
PHP Function
PHP Function PHP Function
PHP Function
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
Php Power Tools
Php Power ToolsPhp Power Tools
Php Power Tools
 
Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008Website releases made easy with the PEAR installer - Barcelona 2008
Website releases made easy with the PEAR installer - Barcelona 2008
 
CakePHP 3
CakePHP 3CakePHP 3
CakePHP 3
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mind
 
PHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksPHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and Frameworks
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 

Similar to Introduction to Symfony Components and helper components in Drupal 8

RESTful in Drupal 8 and Services module - New`n`Tasty!
RESTful in Drupal 8 and Services module - New`n`Tasty!RESTful in Drupal 8 and Services module - New`n`Tasty!
RESTful in Drupal 8 and Services module - New`n`Tasty!Dmytro Olaresko
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicehazzaz
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTPBen Ramsey
 
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...apidays
 
Very Brief Intro to Catalyst
Very Brief Intro to CatalystVery Brief Intro to Catalyst
Very Brief Intro to CatalystZachary Blair
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Nguyen Duc Phu
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 networkVitali Pekelis
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
Php framework at BarCampPP
Php framework at BarCampPPPhp framework at BarCampPP
Php framework at BarCampPPpsophy
 
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIsHTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIsRoan Brasil Monteiro
 
Automate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in PythonAutomate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in PythonAtlassian
 
Automate that
Automate thatAutomate that
Automate thatAtlassian
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016Codemotion
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Don't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and JoomlaDon't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and JoomlaPierre-André Vullioud
 
Introduction to RESTful Webservice
Introduction to RESTful WebserviceIntroduction to RESTful Webservice
Introduction to RESTful WebserviceEftakhairul Islam
 
Boost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BSBoost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BSInformation Development World
 

Similar to Introduction to Symfony Components and helper components in Drupal 8 (20)

RESTful in Drupal 8 and Services module - New`n`Tasty!
RESTful in Drupal 8 and Services module - New`n`Tasty!RESTful in Drupal 8 and Services module - New`n`Tasty!
RESTful in Drupal 8 and Services module - New`n`Tasty!
 
nguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-servicenguyenhainhathuy-building-restful-web-service
nguyenhainhathuy-building-restful-web-service
 
Spider Course Day 1
Spider Course Day 1Spider Course Day 1
Spider Course Day 1
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTP
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
 
Very Brief Intro to Catalyst
Very Brief Intro to CatalystVery Brief Intro to Catalyst
Very Brief Intro to Catalyst
 
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
Hanoi php day 2008 - 05. nguyen hai nhat huy - building-restful-web-service-w...
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 network
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Php framework at BarCampPP
Php framework at BarCampPPPhp framework at BarCampPP
Php framework at BarCampPP
 
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIsHTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
 
Automate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in PythonAutomate That! Scripting Atlassian applications in Python
Automate That! Scripting Atlassian applications in Python
 
Automate that
Automate thatAutomate that
Automate that
 
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
The new features of PHP 7 - Enrico Zimuel - Codemotion Milan 2016
 
The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Don't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and JoomlaDon't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and Joomla
 
Introduction to RESTful Webservice
Introduction to RESTful WebserviceIntroduction to RESTful Webservice
Introduction to RESTful Webservice
 
Boost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BSBoost Your Content Strategy for REST APIs with Gururaj BS
Boost Your Content Strategy for REST APIs with Gururaj BS
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 

Introduction to Symfony Components and helper components in Drupal 8

  • 1. Introduction to Symfony components and helper components in Drupal 8 Ankit Babbar Drupal Developer at Valuebound Volunteer at SPIC MACAY twitter: ankitbabbar
  • 2.
  • 3. History of PHP Functional vs OOPs Programming Frameworks 3rd Party Libraries Namespace PHP-FIG YAML Composer
  • 4. Awesome Drupal CMS + Symfony2 Framework + Best PHP Practices from Community
  • 5.
  • 8.
  • 10. HTTP request looks like: GET /foo.html HTTP/1.1 Host: example.com Accept: text/html User-Agent: Mozialla/5.0 (Macintosh) GET Retrieve the resource from the server POST Create a resource on the server PUT Update the resource on the server DELETE Delete the resource from the server Request
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. HTTP response looks like: HTTP/1.1 200 OK Date: Sat, 25 Jul 2015 10:30:00 IST Server: apache2/2.xx Content-Type: text/html <html> Response
  • 17. YAML: YAML Ain’t Markup Language Sample Router hello_world.content: path: ‘/hello-world' defaults: _controller: 'DrupalhelloControllerHelloController::content' _title: 'Hello World' requirements: _permission: 'access content'
  • 19. Sample Hello World Controller class HelloController extends ControllerBase { public function content() { return array( '#type' => 'markup', '#markup' => t('Hello, World!'), ); } }
  • 22.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 36. class Notifier { private $mailer; public function __construct() { $this->mailer = new Mailer(); } public function notify() { … $this->mailer->send($from, $to, $msg); … } }
  • 37. class Notifier { private $mailer; public function __construct(MailInterface $m) { $this->mailer = $m; } public function notify() { …. $this->mailer->send($from, $to, $msg); … } } $mailer = new SpecialMailer(); $notifier = new Notifier($mailer);
  • 38. Composer Sample composer.json for hello_world module { "name": “drupal/hello_world", "require": { "mailchimp/mailchimp": "2.0.6" } }
  • 40. Full Controller File Look like: <?php /** * @file * Contains DrupalhelloControllerHelloController. */ namespace DrupalhelloController; use DrupalCoreControllerControllerBase; class HelloController extends ControllerBase { public function content() { return array( '#type' => 'markup', '#markup' => t('Hello, World!'), ); } } ?>
  • 43.
  • 44. 1. Symfony Documentation 2. DrupalCon Denver 2012: DRUPAL 8 MEETS SYMFONY2 https://www.youtube.com/watch?v=Gr71z_WoejM 3. UNDERSTANDING DRUPAL 8: https://cipix.nl/understanding-drupal-8-part-1-general- structure-framework 4. DrupalCon Portland 2013: DEPENDENCY INJECTION IN DRUPAL 8 https://www.youtube.com/watch?v=kocJ6pn9kEc 5. DrupalCon Denver 2012: DRUPAL 8 MEETS SYMFONY2 https://www.youtube.com/watch?v=Gr71z_WoejM 6. Symfony en Drupal 8 http://symfony.com/doc/current/components/event_dispatcher/introduction.html#introduction 7. Unravelling the Drupal 8 Plugin System https://drupalize.me/blog/201409/unravelling-drupal- 8-plugin-system 8. Drupal 8 Plugin System https://www.youtube.com/watch?v=2o5uY-iOoMo 9. PSR-4 http://www.php-fig.org/psr/psr-4/ 10. Namespaces http://php.net/manual/en/language.namespaces.php References and Resources