SlideShare a Scribd company logo
1 of 60
Download to read offline
Symfony Internals

diving into symfony's guts
About me

Zend Certified Engineer

Developer at Sensio Labs

Vice-President of AFSY (French Symfony User Group)

Co-author of "More with symfony"

As you can see, I love bermudas

  http://twitter.com/ubermuda (mostly in french sorry)
More with symfony?

Yes, I wrote the Symfony Internals chapter

Don't worry if you read it already

There's new material here
Introduction

The symfony framework

  Customizable

  Flexible

  Extensible
Customizable

Configuration files

  settings.yml

  factory.yml

Hierarchical configuration

Lots of ways to handle how the framework behaves
Flexible

The framework bows to your needs

  Does not enforce an ORM

  Does not enforce an user management system

  Does not enforce a mailer

  Etc.
Extensible

You can easily add capabilities

  Using plugins

  Hooking up on events

  Overriding entire parts of the framework
How is it achieved?

     Yes, how?
The bootstrap

Retrieves the application's configuration

Instanciates sfContext

Initiates dispatching
sfContext ?

Implements the Singleton design pattern

  Has its pros and cons

  Mostly, cons. (testability issues, etc)

Responsible for loading factories

  (We'll talk about factories later)
The application configuration

frontendConfiguration

  Extends ProjectConfiguration

    Shares methods

    Also, constructors

  Most customization usually happens in ProjectConfiguration
The project configuration

Two very important steps:

  Creates an event dispatcher

  Loads plugins
The event dispatcher

sfEventDispatcher

  Available as a separate component

  http://components.symfony-project.org/event-dispatcher/

Implements the Observer pattern

Used throughout the whole framework
The event dispatcher

Available configuration events

  autoload.filter_config

     Allows to customize the autoloader configuration

More events later
Plugins

Used to extend the framework capabilities

  Can contain entire modules

  Or just hook on some event

  Or provide a specific library

  Etc.
Plugins

Have their own configuration file

  used to be config/config.php

  Now sfMyPluginConfiguration

     extends sfPluginConfiguration

  sfPluginConfigurationGeneric (if none was found)
Plugins

Find plugins

  http://www.symfony-project.org/plugins/

  http://www.symplist.net/

  More than 900 plugins available!

Write your own plugins

  It's easy

  Simplifies code re-use
The configuration files

settings.yml

  Holds the framework settings

  And there are a lot of them

  Actions, security strategies, I18N, debug bar, etc

  http://www.symfony-project.org/reference/1_4/en/04-Settings
The configuration files

app.yml

  Application specific configuration

  You decide what's in there

  Project wide app.yml (config/app.yml)
Environments

Environment specific configuration

  Default envs are prod, dev and test

Configuration fine-tuning

  Have a different database

  Use a different mailing strategy

It's all handled by a ConfigHandler
Config Handler ?

Not very well known part of symfony

Parse and translate configuration files

Each configuration file has its own handler (kinda)

  sfDefineEnvironmentConfigHandler

  sfDatabaseConfigHandler

  sfFactoryConfigHandler

  Etc.
Back to sfContext

Instanciates factories

  Components that drive your application

     Logger, I18N, mailer, request, response, etc.

  Configured through factories.yml

     Has its own ConfigHandler too!
The factories configuration

Configured per-application

In your app's config/factory.yml

Gives you control over the whole framework

Handle by sfFactoryConfigHandler
sfFactoryConfigHandler

Translates your factory.yml into executable PHP
It's all in your cache

All config handlers use the config cache

Look in your cache/ directory for more information
The factories

You can override almost every components used by symfony

There is a reference for that, of course

http://www.symfony-project.org/reference/1_4/en/05-Factories
Here be events

Events notified during the factories loading

  request.filter_parameters

  routing.load_configuration

  context.load_factories
context.load_factories

Earliest event where access to all factories is possible

  Database access anyone?
The dispatch process

      and more
The front controller

sfFrontWebController implements the Front Controller pattern

  http://en.wikipedia.org/wiki/Front_Controller_pattern

Grabs module and action from the request

Issues a simple forward()
sfError404Exception

Thrown if no module/action was found

Will stop symfony's workflow

Forces a redirect to configured 404 handler

  sf_error_404_module

  sf_error_404_action

Can be thrown from anywhere in your application
The admin generator

Well-known symfony feature

generator.yml is consumed just there

  Because we need the base action classes

By its own Config Handler, of course

http://www.symfony-project.org/reference/1_4/en/06-Admin-
Generator
sfGeneratorConfigHandler

Instanciates a generator

Runs it

There is no step 3
Controllers dir

You can't do much here

Except override getControllersDir()

  Gives you huge control over the controllers' location

  You can add any directory to the list

  Or just plain replace it
The action stack

A FIFO (First In First Out) stack

Holds every action that were or will be executed

Access it through sfContext's getActionStack()

Useful to interact with the action (getActionName(), etc)
Enabling and disabling modules

Two ways of doing this

  Through sf_enabled_modules, in settings.yml

  Through mod_MyModule_enabled, in module.yml

The difference is how disabled modules are handled
Enabling and disabling modules

Modules disabled through settings.yml

  Will cause a sfConfigurationException to be thrown

  Should be used for permanently disabled modules
Enabling and disabling modules

Modules disabled through module.yml

  Will redirect to the "disabled module" module

    sf_module_disabled_module

    sf_module_disabled_action

  Should be used for temporarily disabled modules
The filter chain

and yet another design pattern
The filter chain

Implements the Chain of Responsibility pattern

  http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern

Configurable through filters.yml

It has a Config Handler too (sfFilterConfigHandler) :-)
Default filters configuration
Write your own filters

Extend sfFilter

Everything happens in the execute() method
Adding your own filters

It's just a matter of adding it to the filters.yml

Between security and cache, that is

Also, keep the rendering filter on top of the stack
Adding your own filters
The rendering filter

Does nothing right now

Remember, a filter can execute code

  Before the rest of the stack

  But also after
The security filter

First filter to actually execute code

Runs a bunch of security checks

  Configured through security.yml

  Checks for unauthenticated requests

  Or requests with insufficient credentials
Unauthenticated requests

Redirected to the "login" page

  sf_login_module

  sf_login_action
Insufficient credentials

Uses the "secure" page

  sf_secure_module

  sf_secure_action
The cache filter

Has two bits of logic

  Can prevent the rest of the chain to execute

     Not very likely, though

  Configures the HTTP cache headers

  Fills in the cache before rendering
The execution filter

Finally! Let's get some real work done

Checks for cache

If no cache is found, executes the action

Calls the view script
The execution workflow

Quite straightforward

  preExecute

  execute (via sfActions' execute())

  postExecute
A word on the return value

Determines what view gets executed

  You already know SUCCESS

  You most certainly also know NONE

  You might also know ERROR

  But there are more builtin types (ALERT and INPUT)

You can actually return anything you want
Handling the view

This is sfView's job

Two ways of getting a view object

  Custom sfView object for a specific action

  Class name from mod_module_view_class

Default is sfPHPView
sfPHPView

Loads core and standard helpers

  Helper, Url, Assets, Tag and Escaping

  sf_standard_helpers, in settings.yml

Executes a view script (pure PHP)

Decorates the result

Also handles some caching
sfPartialView

Responsible for rendering partials and components

Has its own logic

Handles cache for partials and components
Custom view examples

sfTwigView

  Integrates the Twig template engine

  http://github.com/henrikbjorn/sfTwigPlugin

sfTemplatingView

  Integrates templating from the symfony components

  http://www.symfony-project.
org/plugins/sfTemplatingViewPlugin
The return of the rendering filter

Remember the rendering filter ?

Well it's back, and it wants to render.

Sends the response content through sfWebResponse's send
method
That's all folks!

We're now ready to handle one more request

Hopefuly faster than we just did ;-)
Thank you

Hope you learned stuff!

Read the book for a more detailed (and boring) approach

http://www.symfony-project.org/more-with-symfony/1_4/en/10-
Symfony-Internals
Questions?

speak slowly please

More Related Content

Viewers also liked

Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Symfony As A Platform (Symfony Camp 2007)
Symfony As A Platform (Symfony Camp 2007)Symfony As A Platform (Symfony Camp 2007)
Symfony As A Platform (Symfony Camp 2007)Fabien Potencier
 
PHP, Cloud And Microsoft Symfony Live 2010
PHP,  Cloud And  Microsoft    Symfony  Live 2010PHP,  Cloud And  Microsoft    Symfony  Live 2010
PHP, Cloud And Microsoft Symfony Live 2010guest5a7126
 
What Symfony Has To Do With My Garage - Home Automation With PHP
What Symfony Has To Do With My Garage - Home Automation With PHPWhat Symfony Has To Do With My Garage - Home Automation With PHP
What Symfony Has To Do With My Garage - Home Automation With PHPJan Unger
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010Fabien Potencier
 
OkAPI meet symfony, symfony meet OkAPI
OkAPI meet symfony, symfony meet OkAPIOkAPI meet symfony, symfony meet OkAPI
OkAPI meet symfony, symfony meet OkAPILukas Smith
 
Decoupling Content Management with Create.js and PHPCR
Decoupling Content Management with Create.js and PHPCRDecoupling Content Management with Create.js and PHPCR
Decoupling Content Management with Create.js and PHPCRHenri Bergius
 
Plugins And Making Your Own
Plugins And Making Your OwnPlugins And Making Your Own
Plugins And Making Your OwnLambert Beekhuis
 
How to Clear Cache in a Symfony Cross Application
How to Clear Cache in a Symfony Cross ApplicationHow to Clear Cache in a Symfony Cross Application
How to Clear Cache in a Symfony Cross ApplicationMike Taylor
 
Apostrophe
ApostropheApostrophe
Apostrophetompunk
 
Doctrine in the Real World
Doctrine in the Real WorldDoctrine in the Real World
Doctrine in the Real WorldJonathan Wage
 
Symfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationSymfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationJonathan Wage
 
Doctrine Php Object Relational Mapper
Doctrine Php Object Relational MapperDoctrine Php Object Relational Mapper
Doctrine Php Object Relational Mapperguesta3af58
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyMarcos Labad
 

Viewers also liked (20)

Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Symfony As A Platform (Symfony Camp 2007)
Symfony As A Platform (Symfony Camp 2007)Symfony As A Platform (Symfony Camp 2007)
Symfony As A Platform (Symfony Camp 2007)
 
PHP, Cloud And Microsoft Symfony Live 2010
PHP,  Cloud And  Microsoft    Symfony  Live 2010PHP,  Cloud And  Microsoft    Symfony  Live 2010
PHP, Cloud And Microsoft Symfony Live 2010
 
What Symfony Has To Do With My Garage - Home Automation With PHP
What Symfony Has To Do With My Garage - Home Automation With PHPWhat Symfony Has To Do With My Garage - Home Automation With PHP
What Symfony Has To Do With My Garage - Home Automation With PHP
 
The new form framework
The new form frameworkThe new form framework
The new form framework
 
The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010The state of Symfony2 - SymfonyDay 2010
The state of Symfony2 - SymfonyDay 2010
 
OkAPI meet symfony, symfony meet OkAPI
OkAPI meet symfony, symfony meet OkAPIOkAPI meet symfony, symfony meet OkAPI
OkAPI meet symfony, symfony meet OkAPI
 
Debugging With Symfony
Debugging With SymfonyDebugging With Symfony
Debugging With Symfony
 
Decoupling Content Management with Create.js and PHPCR
Decoupling Content Management with Create.js and PHPCRDecoupling Content Management with Create.js and PHPCR
Decoupling Content Management with Create.js and PHPCR
 
Plugins And Making Your Own
Plugins And Making Your OwnPlugins And Making Your Own
Plugins And Making Your Own
 
Symfony in the Cloud
Symfony in the CloudSymfony in the Cloud
Symfony in the Cloud
 
How to Clear Cache in a Symfony Cross Application
How to Clear Cache in a Symfony Cross ApplicationHow to Clear Cache in a Symfony Cross Application
How to Clear Cache in a Symfony Cross Application
 
Apostrophe
ApostropheApostrophe
Apostrophe
 
Doctrine in the Real World
Doctrine in the Real WorldDoctrine in the Real World
Doctrine in the Real World
 
Symfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 IntegrationSymfony2 and Doctrine2 Integration
Symfony2 and Doctrine2 Integration
 
Developing for Developers
Developing for DevelopersDeveloping for Developers
Developing for Developers
 
Doctrine Php Object Relational Mapper
Doctrine Php Object Relational MapperDoctrine Php Object Relational Mapper
Doctrine Php Object Relational Mapper
 
Symfony and eZ Publish
Symfony and eZ PublishSymfony and eZ Publish
Symfony and eZ Publish
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
 

Similar to Symfony Internals

Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumMatthias Noback
 
Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Stefan Koopmanschap
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Fabien Potencier
 
Integrating symfony and Zend Framework
Integrating symfony and Zend FrameworkIntegrating symfony and Zend Framework
Integrating symfony and Zend FrameworkStefan Koopmanschap
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
An introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersAn introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersGiorgio Cefaro
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaMatthias Noback
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
Create Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien PotencierCreate Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien PotencierHimel Nag Rana
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014Matthias Noback
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automationsecurityxploded
 
Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Stefan Koopmanschap
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumJodie Miners
 

Similar to Symfony Internals (20)

Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup Belgium
 
Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)Integrating symfony and Zend Framework (PHPBarcelona 2009)
Integrating symfony and Zend Framework (PHPBarcelona 2009)
 
Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3Symfony Components 2.0 on PHP 5.3
Symfony Components 2.0 on PHP 5.3
 
Integrating symfony and Zend Framework
Integrating symfony and Zend FrameworkIntegrating symfony and Zend Framework
Integrating symfony and Zend Framework
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
An introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developersAn introduction to Symfony 2 for symfony 1 developers
An introduction to Symfony 2 for symfony 1 developers
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony Barcelona
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Create Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien PotencierCreate Your Own Framework by Fabien Potencier
Create Your Own Framework by Fabien Potencier
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Symfony
SymfonySymfony
Symfony
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automation
 
Magento Meetup New Delhi- Console
Magento Meetup New Delhi- ConsoleMagento Meetup New Delhi- Console
Magento Meetup New Delhi- Console
 
Symfony quick tour_2.3
Symfony quick tour_2.3Symfony quick tour_2.3
Symfony quick tour_2.3
 
Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)Integrating symfony and Zend Framework (PHPNW09)
Integrating symfony and Zend Framework (PHPNW09)
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
Zf2
Zf2Zf2
Zf2
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 

Recently uploaded

Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopBachir Benyammi
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 

Recently uploaded (20)

Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
NIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 WorkshopNIST Cybersecurity Framework (CSF) 2.0 Workshop
NIST Cybersecurity Framework (CSF) 2.0 Workshop
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 

Symfony Internals

  • 2. About me Zend Certified Engineer Developer at Sensio Labs Vice-President of AFSY (French Symfony User Group) Co-author of "More with symfony" As you can see, I love bermudas http://twitter.com/ubermuda (mostly in french sorry)
  • 3. More with symfony? Yes, I wrote the Symfony Internals chapter Don't worry if you read it already There's new material here
  • 4. Introduction The symfony framework Customizable Flexible Extensible
  • 5. Customizable Configuration files settings.yml factory.yml Hierarchical configuration Lots of ways to handle how the framework behaves
  • 6. Flexible The framework bows to your needs Does not enforce an ORM Does not enforce an user management system Does not enforce a mailer Etc.
  • 7. Extensible You can easily add capabilities Using plugins Hooking up on events Overriding entire parts of the framework
  • 8. How is it achieved? Yes, how?
  • 9. The bootstrap Retrieves the application's configuration Instanciates sfContext Initiates dispatching
  • 10. sfContext ? Implements the Singleton design pattern Has its pros and cons Mostly, cons. (testability issues, etc) Responsible for loading factories (We'll talk about factories later)
  • 11. The application configuration frontendConfiguration Extends ProjectConfiguration Shares methods Also, constructors Most customization usually happens in ProjectConfiguration
  • 12. The project configuration Two very important steps: Creates an event dispatcher Loads plugins
  • 13. The event dispatcher sfEventDispatcher Available as a separate component http://components.symfony-project.org/event-dispatcher/ Implements the Observer pattern Used throughout the whole framework
  • 14. The event dispatcher Available configuration events autoload.filter_config Allows to customize the autoloader configuration More events later
  • 15. Plugins Used to extend the framework capabilities Can contain entire modules Or just hook on some event Or provide a specific library Etc.
  • 16. Plugins Have their own configuration file used to be config/config.php Now sfMyPluginConfiguration extends sfPluginConfiguration sfPluginConfigurationGeneric (if none was found)
  • 17. Plugins Find plugins http://www.symfony-project.org/plugins/ http://www.symplist.net/ More than 900 plugins available! Write your own plugins It's easy Simplifies code re-use
  • 18. The configuration files settings.yml Holds the framework settings And there are a lot of them Actions, security strategies, I18N, debug bar, etc http://www.symfony-project.org/reference/1_4/en/04-Settings
  • 19. The configuration files app.yml Application specific configuration You decide what's in there Project wide app.yml (config/app.yml)
  • 20. Environments Environment specific configuration Default envs are prod, dev and test Configuration fine-tuning Have a different database Use a different mailing strategy It's all handled by a ConfigHandler
  • 21. Config Handler ? Not very well known part of symfony Parse and translate configuration files Each configuration file has its own handler (kinda) sfDefineEnvironmentConfigHandler sfDatabaseConfigHandler sfFactoryConfigHandler Etc.
  • 22. Back to sfContext Instanciates factories Components that drive your application Logger, I18N, mailer, request, response, etc. Configured through factories.yml Has its own ConfigHandler too!
  • 23. The factories configuration Configured per-application In your app's config/factory.yml Gives you control over the whole framework Handle by sfFactoryConfigHandler
  • 25. It's all in your cache All config handlers use the config cache Look in your cache/ directory for more information
  • 26. The factories You can override almost every components used by symfony There is a reference for that, of course http://www.symfony-project.org/reference/1_4/en/05-Factories
  • 27. Here be events Events notified during the factories loading request.filter_parameters routing.load_configuration context.load_factories
  • 28. context.load_factories Earliest event where access to all factories is possible Database access anyone?
  • 30. The front controller sfFrontWebController implements the Front Controller pattern http://en.wikipedia.org/wiki/Front_Controller_pattern Grabs module and action from the request Issues a simple forward()
  • 31. sfError404Exception Thrown if no module/action was found Will stop symfony's workflow Forces a redirect to configured 404 handler sf_error_404_module sf_error_404_action Can be thrown from anywhere in your application
  • 32. The admin generator Well-known symfony feature generator.yml is consumed just there Because we need the base action classes By its own Config Handler, of course http://www.symfony-project.org/reference/1_4/en/06-Admin- Generator
  • 34. Controllers dir You can't do much here Except override getControllersDir() Gives you huge control over the controllers' location You can add any directory to the list Or just plain replace it
  • 35. The action stack A FIFO (First In First Out) stack Holds every action that were or will be executed Access it through sfContext's getActionStack() Useful to interact with the action (getActionName(), etc)
  • 36. Enabling and disabling modules Two ways of doing this Through sf_enabled_modules, in settings.yml Through mod_MyModule_enabled, in module.yml The difference is how disabled modules are handled
  • 37. Enabling and disabling modules Modules disabled through settings.yml Will cause a sfConfigurationException to be thrown Should be used for permanently disabled modules
  • 38. Enabling and disabling modules Modules disabled through module.yml Will redirect to the "disabled module" module sf_module_disabled_module sf_module_disabled_action Should be used for temporarily disabled modules
  • 39. The filter chain and yet another design pattern
  • 40. The filter chain Implements the Chain of Responsibility pattern http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern Configurable through filters.yml It has a Config Handler too (sfFilterConfigHandler) :-)
  • 42. Write your own filters Extend sfFilter Everything happens in the execute() method
  • 43. Adding your own filters It's just a matter of adding it to the filters.yml Between security and cache, that is Also, keep the rendering filter on top of the stack
  • 44. Adding your own filters
  • 45. The rendering filter Does nothing right now Remember, a filter can execute code Before the rest of the stack But also after
  • 46. The security filter First filter to actually execute code Runs a bunch of security checks Configured through security.yml Checks for unauthenticated requests Or requests with insufficient credentials
  • 47. Unauthenticated requests Redirected to the "login" page sf_login_module sf_login_action
  • 48. Insufficient credentials Uses the "secure" page sf_secure_module sf_secure_action
  • 49. The cache filter Has two bits of logic Can prevent the rest of the chain to execute Not very likely, though Configures the HTTP cache headers Fills in the cache before rendering
  • 50. The execution filter Finally! Let's get some real work done Checks for cache If no cache is found, executes the action Calls the view script
  • 51. The execution workflow Quite straightforward preExecute execute (via sfActions' execute()) postExecute
  • 52. A word on the return value Determines what view gets executed You already know SUCCESS You most certainly also know NONE You might also know ERROR But there are more builtin types (ALERT and INPUT) You can actually return anything you want
  • 53. Handling the view This is sfView's job Two ways of getting a view object Custom sfView object for a specific action Class name from mod_module_view_class Default is sfPHPView
  • 54. sfPHPView Loads core and standard helpers Helper, Url, Assets, Tag and Escaping sf_standard_helpers, in settings.yml Executes a view script (pure PHP) Decorates the result Also handles some caching
  • 55. sfPartialView Responsible for rendering partials and components Has its own logic Handles cache for partials and components
  • 56. Custom view examples sfTwigView Integrates the Twig template engine http://github.com/henrikbjorn/sfTwigPlugin sfTemplatingView Integrates templating from the symfony components http://www.symfony-project. org/plugins/sfTemplatingViewPlugin
  • 57. The return of the rendering filter Remember the rendering filter ? Well it's back, and it wants to render. Sends the response content through sfWebResponse's send method
  • 58. That's all folks! We're now ready to handle one more request Hopefuly faster than we just did ;-)
  • 59. Thank you Hope you learned stuff! Read the book for a more detailed (and boring) approach http://www.symfony-project.org/more-with-symfony/1_4/en/10- Symfony-Internals