SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
Creating a Symfony 2
Application from a
Drupal Perspective
Robyn Green
February 26, 2014
Robyn Green
●

Senior Developer and Themer for
Mediacurrent.

●

Bachelor of Science in Journalism,
Computer Science from University of
Central Arkansas.

●

Background in Media, news agencies.

●

Web app and Front End developer since
1996.

●

Live in Little Rock, Arkansas.

●

Build AngularJS, XCode, Django/Python
projects in my spare time.
What’s Going On?
● Why we talking about Symfony?
● What does this have to do with Drupal?
● Hasn’t this been covered already?
The Fine Print
● This is a high level presentation
○ There is no Symfony Apples === Drupal Oranges
The Fine Print
● This is a high level presentation
○ There is no Symfony Apples === Drupal Oranges Drupal
Blueberries
The Fine Print
● This is a high level presentation
○ There is no Symfony Apples === Drupal Oranges Drupal
Blueberries

● Won’t be going over Drupal 8
● No Drupal 7 to Drupal 8 module conversions
I solemnly swear to not rant and rave about best practices, my
opinion or procedural PHP vs MVC/OOP beyond what’s required
for Symfony 2 examples.
What Will You Do?
Build a simple Symfony 2 site using Drupal
terminology. (with examples … maybe)
MVC
Symfony: PHP web application framework using MVC
Drupal doesn’t have any sort of strict MVC requirement.

Example: PHP and SQL queries in theme tpl files.
MVC
Symfony: PHP web application framework using MVC

M: Model
● V: View
● C: Controller
●
MVC “Drupal”
Symfony: PHP web application framework using MVC
● M: Model
○ Content Types
● V: View
○ Theme template tpl files
● C: Controller
○ Modules
Lock and (down)load
Let’s create a basic site in Symfony and Drupal

Drush vs Composer
Both are CLI tools
You can install Drupal via Drush
You can install Symfony via Composer
Drush is 100% Drupal
Composer is a dependency manager for PHP. It owes
allegiance to no one
Lock and (down)load
Lock and (down)load
Lock and (down)load
Lock and (down)load
Lock and (down)load
We need to configure Symfony first
Load config.php

Fix any Problems, most likely permissions
Lock and (down)load
Plug in your database information
Lock and (down)load
Lock and (down)load
Note the URL: app_dev.php
Symfony has a built-in development environment toggle that
defaults to enabled.
This runs a different URL based on the environment
parameter set
If You Build It, They Will Come
Basic Recipe site should have … recipes
●
●
●
●
●

Title
Category
Ingredients
Instructions
Ratings. Maybe.
If You Build It, They Will Come
In Drupal, this is pretty standard*

*Field Collection and Fivestar contrib modules used
If You Build It, They Will Come
Let’s see that again, but in Symfony this
time.
If You Build It, They Will Come
Building a Bundle

php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml
If You Build It, They Will Come

Warning: Namespace Discussions Ahead
If You Build It, They Will Come
Building a Bundle

php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml

Namespaces. There are standards to how this is done and Drupal is currently
using PSR-0 but heavily debating a move to PSR-4.
Symfony as of 2.4 still uses PSR-0, 1 or 2.
http://symfony.com/doc/current/contributing/code/standards.html
If You Build It, They Will Come
Building a Bundle

php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml

Tutorial here is the vendor name.
CoreBundle is the package name.
If You Build It, They Will Come
Building a Bundle

php app/console generate:bundle --namespace=Recipes/WebBundle --format=yml

YAML Format. From Symfony’s own documentation:
“YAML, YAML Ain't Markup Language, is a human friendly data serialization
standard for all programming languages.”
If You Build It, They Will Come
YAML

Drupal 7 Module .info

YAML
If You Build It, They Will Come
Ignore Acme - default example
We’ve got a Tutorial directory
CoreBundle falls under that
Everything related to that
bundle is in here
Symfony Content Types
That’s all great, but what about our Drupal
Content Type?
●

We have to declare the bundle before
we can generate the entity.

Don’t get confused with between Models, Entities,
Bundles and Content Types.
Symfony Content Types
Building an Entity
php app/console doctrine:generate:entity --entity="TutorialCoreBundle:recipe"

The console is going to ask us about fields in this entity. Let’s
treat it like our content type*

*we can pass fields in the command as a shortcut, but we’ll keep it simple here.
Symfony Content Types
Symfony Content Types
What does this look like in Drupal?
Symfony Content Types
Building an Entity
Think about relationships when deciding fields.
Ingredients is better as its own Entity, not on it’s own as a
Field. We’ll establish a Many-to-Many relationship.
Categories as well.
Symfony Content Types
Building an Entity
Drupal: Nodereferences, Taxonomy, even Images - anything
that needs a complex set of its own fields or data is perhaps
better suited as its own Entity in Symfony
We have to tell Symfony these items will have a relationship
In Drupal, the power of the community has done this for us
with modules like Entity Reference and Node Reference
Symfony Content Types
Building an Entity
ManyToMany
OneToMany
ManyToOne
OneToOne
These relationships are extremely powerful, and
unfortunately beyond the scope of what we can cover here.
Symfony Content Types
Building an Entity
What do the fields in this Entity look like?
src/Tutorial/CoreBundle/Entity/recipe.php
/**
* @var string
*
* @ORMColumn(name="category", type="string", length=255)
*/
private $category;
Symfony Content Types
Building an Entity
So that’s it, we have our content type minus the
different relationships?
Not quite.
Symfony Content Types
Building an Entity
We have to tell Symfony to update our schema:
php app/console doctrine:schema:update --force
One Data Entry to Rule Them All
Drupal
One Data Entry to Rule Them All
Symfony

Remember, this is just a framework.
Also, don’t do mysql inserts directly like that. It’s hard to
establish relationships by hand.
One Data Entry to Rule Them All
$RecipeObj = new Recipe();
$RecipeObj->setTitle(“Yummy Recipe”);
$RecipeObj->setInstructions(“Some set of instructions”);
$RecipeObj->setCategory($CategoryObj);
$RecipeObj->setRating(2.5);
$em = $this->getDoctrine()->getManager();
$em->persist($RecipeObj);
$em->flush();
My First Symfony Site
How do we let Symfony know about our
new bundle?
Routing
src/Tutorial/CoreBundle/Resources/routing.yml
My First Symfony Site
By Default, our bundle routing looks like this:
tutorial_core_homepage:
pattern: /hello/{name}
defaults: { _controller: TutorialCoreBundle:Default:index }

Which we can access here:
http://localhost/symfony/web/app_dev.php/hello/test
My First Symfony Site
By Default, our bundle routing looks like this:
tutorial_core_homepage:
pattern: /hello/{name}
defaults: { _controller: TutorialCoreBundle:Default:index }

Which we can access here:
http://localhost/symfony/web/app_dev.php/hello/test
My First Symfony Site

Imagine trying to build a custom Drupal module
page and not implementing hook_menu()
This is the same logic behind Symfony routing
My First Symfony Site
My First Symfony Site
Let’s open
src/Tutorial/CoreBundle/Resources/routing.yml

pattern:

/hello/{name}

Change To
pattern:

/

We might as well set it to our homepage.
My First Symfony Site
Because we’ve removed the {name} placeholder,
we have to update our Controller and Twig.
src/Tutorial/CoreBundle/Controller/DefaultController.php
$recipes = $this->getDoctrine()
->getRepository(TutorialCoreBundle:recipe')
->findBy(array(), array('name' => 'asc'));
return $this->render('TutorialCoreBundle:Default:index.html.
twig',
array('recipes' => $recipes));
My First Symfony Site
What did we just do?
getRepository(TutorialCoreBunder:recipe')
->findBy(array(), array('name' => 'asc'))

Is basically the same as building a View
- of node.type = ‘recipe’
- sort by node.title, asc
But instead of outputting formatting or building a block, we’re
just storing a collection of objects.
My First Symfony Site
What did we just do?
We pass that $recipes collection on to Twig
My First Symfony Site
Twig index.html.twig
●

Drupal’s page.tpl.php

●

We can add whatever markup we need, but no PHP

●

Even better, define a base.html.twig and extend it

●

Extend allows us to use all the features of the parent, but
override when necessary

{% extends 'TutorialCoreBundle:Default:base.html.twig' %}
My First Symfony Site
Twig index.html.twig
<div>
{% for recipe in recipes %}
<h1>{{ recipe.title }}</h1>
{% endfor %}
</div>
My First Symfony Site
Twig index.html.twig
My First Symfony Site
Drupal page.tpl.php
My First Symfony Site
Twig
My First Symfony Site
Twig
One last thing ...
My First Symfony Site
Twig index.html.twig
My First Symfony Site
Twig index.html.twig
Except, that wasn’t Twig
That was Django. Python.
My First Symfony Site
Django index.html
My First Symfony Site
Twig index.html.twig
Because the backend logic is decoupled from the front
end display, the markup structure is so similar any
themer or front end developer can pick up these
templates without first having to learn the backend
code.
Thank You!

Questions?
@Mediacurrent

Mediacurrent.com

slideshare.net/mediacurrent

Weitere ähnliche Inhalte

Was ist angesagt?

Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsIgnacio Martín
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017Ryan Weaver
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Symfony Components
Symfony ComponentsSymfony Components
Symfony Componentsguest0de7c2
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersMarcin Chwedziak
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)Win Yu
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreRyan Weaver
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQLJussi Pohjolainen
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkJeremy Kendall
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Fabien Potencier
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Jacopo Romei
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overviewjsmith92
 
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Pedro Cunha
 
O que vem por aí com Rails 3
O que vem por aí com Rails 3O que vem por aí com Rails 3
O que vem por aí com Rails 3Frevo on Rails
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeOscar Merida
 

Was ist angesagt? (20)

A dive into Symfony 4
A dive into Symfony 4A dive into Symfony 4
A dive into Symfony 4
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
 
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
The Coolest Symfony Components you’ve never heard of - DrupalCon 2017
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Symfony Components
Symfony ComponentsSymfony Components
Symfony Components
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
Effective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 DevelopersEffective Doctrine2: Performance Tips for Symfony2 Developers
Effective Doctrine2: Performance Tips for Symfony2 Developers
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and moreSymfony Guard Authentication: Fun with API Token, Social Login, JWT and more
Symfony Guard Authentication: Fun with API Token, Social Login, JWT and more
 
Short Intro to PHP and MySQL
Short Intro to PHP and MySQLShort Intro to PHP and MySQL
Short Intro to PHP and MySQL
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009Symfony2 San Francisco Meetup 2009
Symfony2 San Francisco Meetup 2009
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
PHP 5.3 Overview
PHP 5.3 OverviewPHP 5.3 Overview
PHP 5.3 Overview
 
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
 
O que vem por aí com Rails 3
O que vem por aí com Rails 3O que vem por aí com Rails 3
O que vem por aí com Rails 3
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with ease
 

Ähnlich wie Create a Symfony Application from a Drupal Perspective

Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumMatthias Noback
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaMatthias Noback
 
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
 
Sympal - Symfony CMS Preview
Sympal - Symfony CMS PreviewSympal - Symfony CMS Preview
Sympal - Symfony CMS PreviewJonathan Wage
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvarsSam Marley-Jarrett
 
Fabien Potencier "Symfony 4 in action"
Fabien Potencier "Symfony 4 in action"Fabien Potencier "Symfony 4 in action"
Fabien Potencier "Symfony 4 in action"Fwdays
 
Using HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationUsing HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationCiaranMcNulty
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi
 
Creating a modern web application using Symfony API Platform Atlanta
Creating a modern web application using  Symfony API Platform AtlantaCreating a modern web application using  Symfony API Platform Atlanta
Creating a modern web application using Symfony API Platform AtlantaJesus Manuel Olivas
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricksJavier Eguiluz
 
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
 
Symfony 4: A new way to develop applications #phpsrb
 Symfony 4: A new way to develop applications #phpsrb Symfony 4: A new way to develop applications #phpsrb
Symfony 4: A new way to develop applications #phpsrbAntonio Peric-Mazar
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - TryoutMatthias Noback
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalDrupalDay
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupalsparkfabrik
 

Ähnlich wie Create a Symfony Application from a Drupal Perspective (20)

Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 
The Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup BelgiumThe Naked Bundle - Symfony Usergroup Belgium
The Naked Bundle - Symfony Usergroup Belgium
 
The Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony BarcelonaThe Naked Bundle - Symfony Barcelona
The Naked Bundle - Symfony Barcelona
 
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
 
Sympal - Symfony CMS Preview
Sympal - Symfony CMS PreviewSympal - Symfony CMS Preview
Sympal - Symfony CMS Preview
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Fabien Potencier "Symfony 4 in action"
Fabien Potencier "Symfony 4 in action"Fabien Potencier "Symfony 4 in action"
Fabien Potencier "Symfony 4 in action"
 
Using HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless IntegrationUsing HttpKernelInterface for Painless Integration
Using HttpKernelInterface for Painless Integration
 
Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8Ran Mizrahi - Symfony2 meets Drupal8
Ran Mizrahi - Symfony2 meets Drupal8
 
Oop's in php
Oop's in php Oop's in php
Oop's in php
 
Creating a modern web application using Symfony API Platform Atlanta
Creating a modern web application using  Symfony API Platform AtlantaCreating a modern web application using  Symfony API Platform Atlanta
Creating a modern web application using Symfony API Platform Atlanta
 
Symfony quick tour_2.3
Symfony quick tour_2.3Symfony quick tour_2.3
Symfony quick tour_2.3
 
Symfony tips and tricks
Symfony tips and tricksSymfony tips and tricks
Symfony tips and tricks
 
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
 
Symfony 4 & Flex news
Symfony 4 & Flex newsSymfony 4 & Flex news
Symfony 4 & Flex news
 
Symfony 4: A new way to develop applications #phpsrb
 Symfony 4: A new way to develop applications #phpsrb Symfony 4: A new way to develop applications #phpsrb
Symfony 4: A new way to develop applications #phpsrb
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
 
The Symfony CLI
The Symfony CLIThe Symfony CLI
The Symfony CLI
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 
Behaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & DrupalBehaviour Driven Development con Behat & Drupal
Behaviour Driven Development con Behat & Drupal
 

Mehr von Acquia

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelAcquia
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfCDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfAcquia
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022May Partner Bootcamp 2022
May Partner Bootcamp 2022Acquia
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022April Partner Bootcamp 2022
April Partner Bootcamp 2022Acquia
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story Acquia
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXUsing Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXAcquia
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowImprove Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowAcquia
 
September Partner Bootcamp
September Partner BootcampSeptember Partner Bootcamp
September Partner BootcampAcquia
 
August partner bootcamp
August partner bootcampAugust partner bootcamp
August partner bootcampAcquia
 
July 2021 Partner Bootcamp
July  2021 Partner BootcampJuly  2021 Partner Bootcamp
July 2021 Partner BootcampAcquia
 
May Partner Bootcamp
May Partner BootcampMay Partner Bootcamp
May Partner BootcampAcquia
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYDRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYAcquia
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineWork While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineAcquia
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia
 
April partner bootcamp deck cookieless future
April partner bootcamp deck  cookieless futureApril partner bootcamp deck  cookieless future
April partner bootcamp deck cookieless futureAcquia
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsHow to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsAcquia
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...Acquia
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Acquia
 

Mehr von Acquia (20)

Acquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdfAcquia_Adcetera Webinar_Marketing Automation.pdf
Acquia_Adcetera Webinar_Marketing Automation.pdf
 
Acquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdfAcquia Webinar Deck - 9_13 .pdf
Acquia Webinar Deck - 9_13 .pdf
 
Taking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next LevelTaking Your Multi-Site Management at Scale to the Next Level
Taking Your Multi-Site Management at Scale to the Next Level
 
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdfCDP for Retail Webinar with Appnovation - Q2 2022.pdf
CDP for Retail Webinar with Appnovation - Q2 2022.pdf
 
May Partner Bootcamp 2022
May Partner Bootcamp 2022May Partner Bootcamp 2022
May Partner Bootcamp 2022
 
April Partner Bootcamp 2022
April Partner Bootcamp 2022April Partner Bootcamp 2022
April Partner Bootcamp 2022
 
How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story How to Unify Brand Experience: A Hootsuite Story
How to Unify Brand Experience: A Hootsuite Story
 
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CXUsing Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
Using Personas to Guide DAM Results: How Life Time Pumped Up Their UX and CX
 
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development WorkflowImprove Code Quality and Time to Market: 100% Cloud-Based Development Workflow
Improve Code Quality and Time to Market: 100% Cloud-Based Development Workflow
 
September Partner Bootcamp
September Partner BootcampSeptember Partner Bootcamp
September Partner Bootcamp
 
August partner bootcamp
August partner bootcampAugust partner bootcamp
August partner bootcamp
 
July 2021 Partner Bootcamp
July  2021 Partner BootcampJuly  2021 Partner Bootcamp
July 2021 Partner Bootcamp
 
May Partner Bootcamp
May Partner BootcampMay Partner Bootcamp
May Partner Bootcamp
 
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASYDRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
DRUPAL 7 END OF LIFE IS NEAR - MIGRATE TO DRUPAL 9 FAST AND EASY
 
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead MachineWork While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
Work While You Sleep: The CMO’s Guide to a 24/7/365 Lead Machine
 
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B LeadsAcquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
Acquia webinar: Leveraging Drupal to Bury Your Sales Team In B2B Leads
 
April partner bootcamp deck cookieless future
April partner bootcamp deck  cookieless futureApril partner bootcamp deck  cookieless future
April partner bootcamp deck cookieless future
 
How to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutionsHow to enhance cx through personalised, automated solutions
How to enhance cx through personalised, automated solutions
 
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
DRUPAL MIGRATIONS AND DRUPAL 9 INNOVATION: HOW PAC-12 DELIVERED DIGITALLY FOR...
 
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
Customer Experience (CX): 3 Key Factors Shaping CX Redesign in 2021
 

Kürzlich hochgeladen

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
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
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
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"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
 
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
 
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
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Kürzlich hochgeladen (20)

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
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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!
 
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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"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
 
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
 
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!
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Create a Symfony Application from a Drupal Perspective

  • 1. Creating a Symfony 2 Application from a Drupal Perspective Robyn Green February 26, 2014
  • 2. Robyn Green ● Senior Developer and Themer for Mediacurrent. ● Bachelor of Science in Journalism, Computer Science from University of Central Arkansas. ● Background in Media, news agencies. ● Web app and Front End developer since 1996. ● Live in Little Rock, Arkansas. ● Build AngularJS, XCode, Django/Python projects in my spare time.
  • 3. What’s Going On? ● Why we talking about Symfony? ● What does this have to do with Drupal? ● Hasn’t this been covered already?
  • 4. The Fine Print ● This is a high level presentation ○ There is no Symfony Apples === Drupal Oranges
  • 5. The Fine Print ● This is a high level presentation ○ There is no Symfony Apples === Drupal Oranges Drupal Blueberries
  • 6. The Fine Print ● This is a high level presentation ○ There is no Symfony Apples === Drupal Oranges Drupal Blueberries ● Won’t be going over Drupal 8 ● No Drupal 7 to Drupal 8 module conversions I solemnly swear to not rant and rave about best practices, my opinion or procedural PHP vs MVC/OOP beyond what’s required for Symfony 2 examples.
  • 7. What Will You Do? Build a simple Symfony 2 site using Drupal terminology. (with examples … maybe)
  • 8. MVC Symfony: PHP web application framework using MVC Drupal doesn’t have any sort of strict MVC requirement. Example: PHP and SQL queries in theme tpl files.
  • 9. MVC Symfony: PHP web application framework using MVC M: Model ● V: View ● C: Controller ●
  • 10. MVC “Drupal” Symfony: PHP web application framework using MVC ● M: Model ○ Content Types ● V: View ○ Theme template tpl files ● C: Controller ○ Modules
  • 11. Lock and (down)load Let’s create a basic site in Symfony and Drupal Drush vs Composer Both are CLI tools You can install Drupal via Drush You can install Symfony via Composer Drush is 100% Drupal Composer is a dependency manager for PHP. It owes allegiance to no one
  • 16. Lock and (down)load We need to configure Symfony first Load config.php Fix any Problems, most likely permissions
  • 17. Lock and (down)load Plug in your database information
  • 19. Lock and (down)load Note the URL: app_dev.php Symfony has a built-in development environment toggle that defaults to enabled. This runs a different URL based on the environment parameter set
  • 20. If You Build It, They Will Come Basic Recipe site should have … recipes ● ● ● ● ● Title Category Ingredients Instructions Ratings. Maybe.
  • 21. If You Build It, They Will Come In Drupal, this is pretty standard* *Field Collection and Fivestar contrib modules used
  • 22. If You Build It, They Will Come Let’s see that again, but in Symfony this time.
  • 23. If You Build It, They Will Come Building a Bundle php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml
  • 24. If You Build It, They Will Come Warning: Namespace Discussions Ahead
  • 25. If You Build It, They Will Come Building a Bundle php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml Namespaces. There are standards to how this is done and Drupal is currently using PSR-0 but heavily debating a move to PSR-4. Symfony as of 2.4 still uses PSR-0, 1 or 2. http://symfony.com/doc/current/contributing/code/standards.html
  • 26. If You Build It, They Will Come Building a Bundle php app/console generate:bundle --namespace=Tutorial/CoreBundle --format=yml Tutorial here is the vendor name. CoreBundle is the package name.
  • 27. If You Build It, They Will Come Building a Bundle php app/console generate:bundle --namespace=Recipes/WebBundle --format=yml YAML Format. From Symfony’s own documentation: “YAML, YAML Ain't Markup Language, is a human friendly data serialization standard for all programming languages.”
  • 28. If You Build It, They Will Come YAML Drupal 7 Module .info YAML
  • 29. If You Build It, They Will Come Ignore Acme - default example We’ve got a Tutorial directory CoreBundle falls under that Everything related to that bundle is in here
  • 30. Symfony Content Types That’s all great, but what about our Drupal Content Type? ● We have to declare the bundle before we can generate the entity. Don’t get confused with between Models, Entities, Bundles and Content Types.
  • 31. Symfony Content Types Building an Entity php app/console doctrine:generate:entity --entity="TutorialCoreBundle:recipe" The console is going to ask us about fields in this entity. Let’s treat it like our content type* *we can pass fields in the command as a shortcut, but we’ll keep it simple here.
  • 33. Symfony Content Types What does this look like in Drupal?
  • 34. Symfony Content Types Building an Entity Think about relationships when deciding fields. Ingredients is better as its own Entity, not on it’s own as a Field. We’ll establish a Many-to-Many relationship. Categories as well.
  • 35. Symfony Content Types Building an Entity Drupal: Nodereferences, Taxonomy, even Images - anything that needs a complex set of its own fields or data is perhaps better suited as its own Entity in Symfony We have to tell Symfony these items will have a relationship In Drupal, the power of the community has done this for us with modules like Entity Reference and Node Reference
  • 36. Symfony Content Types Building an Entity ManyToMany OneToMany ManyToOne OneToOne These relationships are extremely powerful, and unfortunately beyond the scope of what we can cover here.
  • 37. Symfony Content Types Building an Entity What do the fields in this Entity look like? src/Tutorial/CoreBundle/Entity/recipe.php /** * @var string * * @ORMColumn(name="category", type="string", length=255) */ private $category;
  • 38. Symfony Content Types Building an Entity So that’s it, we have our content type minus the different relationships? Not quite.
  • 39. Symfony Content Types Building an Entity We have to tell Symfony to update our schema: php app/console doctrine:schema:update --force
  • 40. One Data Entry to Rule Them All Drupal
  • 41. One Data Entry to Rule Them All Symfony Remember, this is just a framework. Also, don’t do mysql inserts directly like that. It’s hard to establish relationships by hand.
  • 42. One Data Entry to Rule Them All $RecipeObj = new Recipe(); $RecipeObj->setTitle(“Yummy Recipe”); $RecipeObj->setInstructions(“Some set of instructions”); $RecipeObj->setCategory($CategoryObj); $RecipeObj->setRating(2.5); $em = $this->getDoctrine()->getManager(); $em->persist($RecipeObj); $em->flush();
  • 43. My First Symfony Site How do we let Symfony know about our new bundle? Routing src/Tutorial/CoreBundle/Resources/routing.yml
  • 44. My First Symfony Site By Default, our bundle routing looks like this: tutorial_core_homepage: pattern: /hello/{name} defaults: { _controller: TutorialCoreBundle:Default:index } Which we can access here: http://localhost/symfony/web/app_dev.php/hello/test
  • 45. My First Symfony Site By Default, our bundle routing looks like this: tutorial_core_homepage: pattern: /hello/{name} defaults: { _controller: TutorialCoreBundle:Default:index } Which we can access here: http://localhost/symfony/web/app_dev.php/hello/test
  • 46. My First Symfony Site Imagine trying to build a custom Drupal module page and not implementing hook_menu() This is the same logic behind Symfony routing
  • 48. My First Symfony Site Let’s open src/Tutorial/CoreBundle/Resources/routing.yml pattern: /hello/{name} Change To pattern: / We might as well set it to our homepage.
  • 49. My First Symfony Site Because we’ve removed the {name} placeholder, we have to update our Controller and Twig. src/Tutorial/CoreBundle/Controller/DefaultController.php $recipes = $this->getDoctrine() ->getRepository(TutorialCoreBundle:recipe') ->findBy(array(), array('name' => 'asc')); return $this->render('TutorialCoreBundle:Default:index.html. twig', array('recipes' => $recipes));
  • 50. My First Symfony Site What did we just do? getRepository(TutorialCoreBunder:recipe') ->findBy(array(), array('name' => 'asc')) Is basically the same as building a View - of node.type = ‘recipe’ - sort by node.title, asc But instead of outputting formatting or building a block, we’re just storing a collection of objects.
  • 51. My First Symfony Site What did we just do? We pass that $recipes collection on to Twig
  • 52. My First Symfony Site Twig index.html.twig ● Drupal’s page.tpl.php ● We can add whatever markup we need, but no PHP ● Even better, define a base.html.twig and extend it ● Extend allows us to use all the features of the parent, but override when necessary {% extends 'TutorialCoreBundle:Default:base.html.twig' %}
  • 53. My First Symfony Site Twig index.html.twig <div> {% for recipe in recipes %} <h1>{{ recipe.title }}</h1> {% endfor %} </div>
  • 54. My First Symfony Site Twig index.html.twig
  • 55. My First Symfony Site Drupal page.tpl.php
  • 56. My First Symfony Site Twig
  • 57. My First Symfony Site Twig One last thing ...
  • 58. My First Symfony Site Twig index.html.twig
  • 59. My First Symfony Site Twig index.html.twig Except, that wasn’t Twig That was Django. Python.
  • 60. My First Symfony Site Django index.html
  • 61. My First Symfony Site Twig index.html.twig Because the backend logic is decoupled from the front end display, the markup structure is so similar any themer or front end developer can pick up these templates without first having to learn the backend code.