SlideShare una empresa de Scribd logo
1 de 42
Symfony 2 meets Propel 1.5François Zaninotto
François Zaninotto Head of the Web Development Team at eTF1, editor the web properties of the leading TV network in France. Former symfony 1 contributor Author of “The Definitive Guide to Symfony” (APress) Lead Developer of Propel since October, 2009 Interests: Web development, Usability, Agility, ROI Not a developer Twitter: @francoisz, Github: fzaninotto
Propel 1.5
No surprise Backwards compatible with Propel 1.3 and 1.4 Faster than Propel 1.4, which was faster than Propel 1.3, which was... Very IDE friendly Better documented More robust (3 times as many unit tests as Propel 1.3) Fully integrated into symfony 1.3/1.4 (sfPropel15Plugin)
Surprise! Major new features Model Queries Collections Many-to-many relationships Major new behaviors Nested Sets Concrete Table Inheritance Better Oracle Support
Surprise! Major new features Model Queries Collections Many-to-many relationships Major new behaviors Nested Sets Concrete Table Inheritance Better Oracle Support Killer Feature Killer Feature
Model Queries Model Queries are to the SQL query what ActiveRecord is to the table row Shift from the relational Paradigm to the Object paradigm in Queries Inspirations: SQL Alchemy, Doctrine, DbFinder, Arel Code generation makes it fast and IDE friendly Easy to learn and use MUCH cleaner custom model code Bye bye, Criteria!
Model Queries $books = BookQuery::create() ->filterByPublishedAt(array(     ‘max’ => time()   )) ->filterByPublisher($publisher) ->useAuthorQuery() ->stillAlive()   ->endUse() ->orderByTitle() ->find();
 Concrete Table Inheritance content id title article body video url structure data
Concrete Table Inheritance: An Example $article = new Article(); $article->setTitle(‘France loses World Cup’); $article->setBody(‘Lorem Ipsum’); $article->save(); $video = new Video(); $video->setTitle(‘World Cup Goals’); $video->setUrl(‘http://www.youtube.com/xxx’); $video->save();
> SELECT * FROMarticle; +----+------------------------+-------------+ | id | title                  | body        | +----+------------------------+-------------+ | 1  | France loses World Cup | Lorem Ipsum | +----+------------------------+-------------+ > SELECT * FROMvideo; +----+-----------------+----------------------------+ | id | title           | url                        | +----+-----------------+----------------------------+ | 2  | World Cup goals | http://www.youtube.com/xxx | +----+-----------------+----------------------------+ > SELECT * FROM content; +----+------------------------+ | id | title                  | +----+------------------------+ | 1  | France loses World Cup | | 2  | World Cup goals        | +----+------------------------+
Design your model in a true object-oriented way Let Propel do the mapping with the relational world Denormalize with ease for optimal performance Let PHP manipulate inheritance, not data replication. … Let PHP manipulate objects, not records. … Let PHP manipulate collections, not arrays. … Let PHP manipulate relations, not foreign keys.
Continuousimprovementsthroughminor versions 1.5.1 PropelObjectCollection::toKeyValue() One-to-manyjoinedhydration (no LIMIT support) CLI enhancements 1.5.2 Namespaces !  ModelQuery::findOneOrCreate() aggregate_columnbehavior SQL Comments
Continuous improvements through minor versions 1.5.1 PropelObjectCollection::toKeyValue() One-to-many joined hydration (no LIMIT support) CLI enhancements 1.5.2 Namespaces !  ModelQuery::findOneOrCreate() aggregate_column behavior SQL Comments Must Have Killer Feature
Namespaces // in schema.xml <table name="book"namespace="Bookstore">   ... </table> // in application code useBookstoreookQuery; $book = BookQuery::create(); ->findOneByTitle(‘War And Peace’); echoget_class($book);  // Bookstoreook $author = $book->getAuthor(); echoget_class($author);  // Bookstoreeopleuthor
 Aggregate Table Behavior author id name book id title author_id * <table name="author">   <behavior name="aggregate_column"> <parameter name="name" value="nb_books" />     <parameter name="foreign_table" value="book" />     <parameter name="expression" value="COUNT(id)" />   </behavior>   ... </table>
 Aggregate Table Behavior author id name nb_books book id title author_id * <table name="author">   <behavior name="aggregate_column"> <parameter name="name" value="nb_books" />     <parameter name="foreign_table" value="book" />     <parameter name="expression" value="COUNT(id)" />   </behavior>   ... </table>
Aggregate Table Behavior $author = new Author(); $author->setName(‘Leo Tolstoi'); $author->save(); echo $author->getNbBooks(); // 0 $book = new Book(); $book->setTitle(‘War and Peace’); $book->setAuthor($author); $book->save(); echo $author->getNbBooks(); // 1 $book->delete(); echo $author->getNbBooks(); // 0
No, really, Propel is definitely NOT DEAD
Propel 1.5 and Symfony
Propel Integration with symfony 1: sfPropel15Plugin  Use sf configuration system (databases.yml, propel.ini)  Use sf autoloading rather than Propel’s  Use sf task system (and hides Phing, thank God)  Adapt Propel to SF applications directory structure ,[object Object]
Web Debug Toolbar panel Form integration (Widgets, Validators, Model forms) ,[object Object], Routing integration (Model routes, Model route collections) ,[object Object],[object Object]
Many of the symfony add-ons to Propel are now part of Propel 1.5 Model hooks, query hooks Behavior system (at buildtime, for better performance and power) auto_add_pkbehavior timestampable behavior isPrimaryString column  attribute for automated __toString() No need for custom symfony code for these
Why you may want to use Propel rather than Doctrine 2 No need to upgrade your Model code It’s fast (without any cache system - that’s code generation) It’s an ActiveRecord implementation It has behaviors It’s IDE friendly The model code is easy to understand and debug It has unique features (ModelQueries, concrete table inheritance, aggregate column behavior, etc.)  It’s robust (3000+ unit tests) and already used by many developers It’s not alpha, it’s not beta, it’s already stable
Installation
The PropelBundle is bundled with the Symfony2 Framework Register the bundle in the kernel // in hello/HelloKernel.php classHelloKernelextendsKernel { public functionregisterBundles()   {     $bundles = array(       ...       new SymfonyrameworkropelBundleundle(),     ); return $bundles;   } }
Add Propel and Phing libraries in src/vendor/ > cd src/vendor > svn co http://svn.propelorm.org/branches/1.5/ propel > svn co http://svn.phing.info/tags/2.3.3 phing Add Propel and Phing paths to the project configuration # in hello/config/config.yml propel.config: path:       %kernel.root_dir%/../src/vendor/propel phing_path: %kernel.root_dir%/../src/vendor/phing
Test the installation by calling the project console > hello/console Symfony version 2.0.0-DEV - hello Usage:   [options] command [arguments] propel :build        Hub for Propel build commands (model, sql) :build-model  Build the Propel Object Model classes                    based on XML schemas :build-sql    Build the SQL generation code for all                  tables based on Propel XML schemas
Usage
Create an XML schema using namespaces // in src/Application/HelloBundle/Resources/config/schema.xml <?xml version="1.0" encoding="UTF-8"?> <database name="default" namespace="ApplicationelloBundleodel" defaultIdMethod="native">   <table name="book">     <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />     <column name="title" type="varchar" primaryString="1" size="100" />     <column name="ISBN" type="varchar" size="20" />     <column name="author_id" type="integer" />     <foreign-key foreignTable="author">       <reference local="author_id" foreign="id" />     </foreign-key>   </table>   <table name="author">     <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />     <column name="first_name" type="varchar" size="100" />     <column name="last_name" type="varchar" size="100" />   </table> </database>
Create an XML schemas using namespaces // in src/Application/HelloBundle/Resources/config/schema.xml <?xml version="1.0" encoding="UTF-8"?> <database name="default" namespace="ApplicationelloBundleodel" defaultIdMethod="native">   <table name="book">     <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />     <column name="title" type="varchar" primaryString="1" size="100" />     <column name="ISBN" type="varchar" size="20" />     <column name="author_id" type="integer" />     <foreign-key foreignTable="author">       <reference local="author_id" foreign="id" />     </foreign-key>   </table>   <table name="author">     <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />     <column name="first_name" type="varchar" size="100" />     <column name="last_name" type="varchar" size="100" />   </table> </database>
Build the model and SQL code > cd sandbox > hello/console propel:build src/Application/HelloBundle/   Model/     map/     om/     Author.php     AuthorPeer.php     AuthorQuery.php     Book.php     BookPeer.php     BookQuery.php hello/propel/sql/   HelloBundle-schema.sql
// in sandbox/src/application/HelloBundle/Model/Book.php namespaceApplicationelloBundleodel; useApplicationelloBundleodelmaseBook; /**  * Skeleton subclass for representing a row from the   * 'book' table.  *  * You should add additional methods to this class to meet  * the application requirements. This class will only be  * generated as long as it does not already exist in the  * output directory.  */ classBookextendsBaseBook { } // Book
Setup your connection in the project configuration # in sandbox/hello/config/config.yml propel.dbal: driver:   mysql user:     root password: null dsn:      mysql:host=localhost;dbname=test   options:  {}
Use models in your actions as with Propel 1.5 alone Symfony handles the autoloading // in sandbox/src/Application/HelloBundle/Controller/HelloController.php namespaceApplicationelloBundleontroller; useSymfonyrameworkebBundleontroller; useApplicationelloBundleodeluthorQuery; classHelloControllerextendsController { public functionindexAction($name)   {     $author = AuthorQuery::create()       ->findOneByName($name); return $this->render('HelloBundle:Hello:index',  array('author' => $author));   } }
That’s about it All the Propel features are ready to use… in the Propel way
The Future of Propel 1.5 and Symfony2
Ask Fabien
A lot left to do YAML format for the schema (and bundle override) Web Debug Toolbar Panel Form integration (Widgets, Validators, Model forms) Admin Generator Theme Documentation Unit tests
And even more Embedded Relation Forms Admin generator on steroids Easy Custom Filter Cross-module links Plain text fields Advanced Object Routing Collection routes Nested routes A thousand more ideas worth implementing cf. sfPropel15Plugin cf. DbFinderPlugin
Not much time to do so I’m already developing Propel I’m already developing sfPropel15Plugin I also have a full-time job …and a family Any help is welcome!
Questions? Online Resources http://github.com/fzaninotto/symfony http://www.propelorm.org/ http://www.symfony-project.org/plugins/sfPropel15Plugin News about all that http://propel.posterous.com/ http://twitter.com/francoisz

Más contenido relacionado

La actualidad más candente

Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or lessrijk.stofberg
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CDavid Wheeler
 
PyFoursquare: Python Library for Foursquare
PyFoursquare: Python Library for FoursquarePyFoursquare: Python Library for Foursquare
PyFoursquare: Python Library for FoursquareMarcel Caraciolo
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기형우 안
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toAlexander Makarov
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)James Titcumb
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPGuilherme Blanco
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)James Titcumb
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)lichtkind
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsMark Baker
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopJeroen Keppens
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyRaimonds Simanovskis
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021Ayesh Karunaratne
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Nikita Popov
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012xSawyer
 

La actualidad más candente (20)

Dexterity in 15 minutes or less
Dexterity in 15 minutes or lessDexterity in 15 minutes or less
Dexterity in 15 minutes or less
 
Building and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning CBuilding and Distributing PostgreSQL Extensions Without Learning C
Building and Distributing PostgreSQL Extensions Without Learning C
 
PyFoursquare: Python Library for Foursquare
PyFoursquare: Python Library for FoursquarePyFoursquare: Python Library for Foursquare
PyFoursquare: Python Library for Foursquare
 
잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기잘 알려지지 않은 Php 코드 활용하기
잘 알려지지 않은 Php 코드 활용하기
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading to
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
Mirror, mirror on the wall: Building a new PHP reflection library (DPC 2016)
 
Ant
Ant Ant
Ant
 
P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)P6 OO vs Moose (&Moo)
P6 OO vs Moose (&Moo)
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
Anatomy of a reusable module
Anatomy of a reusable moduleAnatomy of a reusable module
Anatomy of a reusable module
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark Workshop
 
Ruby 2.0
Ruby 2.0Ruby 2.0
Ruby 2.0
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
 
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
 

Similar a Symfony2 meets propel 1.5

Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Michiel Rook
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handlingSuite Solutions
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Declarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPDeclarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPStephan Schmidt
 
Declarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPDeclarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPstubbles
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling FrameworkAjay K
 
Develop At The Speed Of Thought
Develop At The Speed Of ThoughtDevelop At The Speed Of Thought
Develop At The Speed Of ThoughtRoy Ganor
 
Final Project Presentation
Final Project PresentationFinal Project Presentation
Final Project Presentationzroserie
 
Flash Templates- Joomla!Days NL 2009 #jd09nl
Flash Templates- Joomla!Days NL 2009 #jd09nlFlash Templates- Joomla!Days NL 2009 #jd09nl
Flash Templates- Joomla!Days NL 2009 #jd09nlJoomla!Days Netherlands
 
Flash templates for Joomla!
Flash templates for Joomla!Flash templates for Joomla!
Flash templates for Joomla!Herman Peeren
 
cdac@parag.gajbhiye@test123
cdac@parag.gajbhiye@test123cdac@parag.gajbhiye@test123
cdac@parag.gajbhiye@test123Parag Gajbhiye
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Pythongturnquist
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2Tim Plummer
 
Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2JoomlaDay Australia
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Seleniumjoaopmaia
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в MagentoMagecom Ukraine
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 

Similar a Symfony2 meets propel 1.5 (20)

Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Declarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPDeclarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHP
 
Declarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHPDeclarative Development Using Annotations In PHP
Declarative Development Using Annotations In PHP
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling Framework
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Develop At The Speed Of Thought
Develop At The Speed Of ThoughtDevelop At The Speed Of Thought
Develop At The Speed Of Thought
 
Final Project Presentation
Final Project PresentationFinal Project Presentation
Final Project Presentation
 
Flash Templates- Joomla!Days NL 2009 #jd09nl
Flash Templates- Joomla!Days NL 2009 #jd09nlFlash Templates- Joomla!Days NL 2009 #jd09nl
Flash Templates- Joomla!Days NL 2009 #jd09nl
 
Flash templates for Joomla!
Flash templates for Joomla!Flash templates for Joomla!
Flash templates for Joomla!
 
cdac@parag.gajbhiye@test123
cdac@parag.gajbhiye@test123cdac@parag.gajbhiye@test123
cdac@parag.gajbhiye@test123
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2
 
Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2Rapid application development using Akeeba FOF and Joomla 3.2
Rapid application development using Akeeba FOF and Joomla 3.2
 
Web App Testing With Selenium
Web App Testing With SeleniumWeb App Testing With Selenium
Web App Testing With Selenium
 
Система рендеринга в Magento
Система рендеринга в MagentoСистема рендеринга в Magento
Система рендеринга в Magento
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 

Más de Francois Zaninotto

Vous aimez les legos ? React est fait pour vous !
Vous aimez les legos ? React est fait pour vous !Vous aimez les legos ? React est fait pour vous !
Vous aimez les legos ? React est fait pour vous !Francois Zaninotto
 
La blockchain, quand l'individu sert au collectif... malgré lui
La blockchain, quand l'individu sert au collectif... malgré luiLa blockchain, quand l'individu sert au collectif... malgré lui
La blockchain, quand l'individu sert au collectif... malgré luiFrancois Zaninotto
 
Le jeu vidéo à la rescousse du web
Le jeu vidéo à la rescousse du webLe jeu vidéo à la rescousse du web
Le jeu vidéo à la rescousse du webFrancois Zaninotto
 
Frameworks : A history of violence
Frameworks : A history of violenceFrameworks : A history of violence
Frameworks : A history of violenceFrancois Zaninotto
 
La migration continue vers Symfony
La migration continue vers SymfonyLa migration continue vers Symfony
La migration continue vers SymfonyFrancois Zaninotto
 
La programmation asynchrone... et les pates
La programmation asynchrone... et les patesLa programmation asynchrone... et les pates
La programmation asynchrone... et les patesFrancois Zaninotto
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 

Más de Francois Zaninotto (11)

Vous aimez les legos ? React est fait pour vous !
Vous aimez les legos ? React est fait pour vous !Vous aimez les legos ? React est fait pour vous !
Vous aimez les legos ? React est fait pour vous !
 
GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?
 
La blockchain, quand l'individu sert au collectif... malgré lui
La blockchain, quand l'individu sert au collectif... malgré luiLa blockchain, quand l'individu sert au collectif... malgré lui
La blockchain, quand l'individu sert au collectif... malgré lui
 
Le jeu vidéo à la rescousse du web
Le jeu vidéo à la rescousse du webLe jeu vidéo à la rescousse du web
Le jeu vidéo à la rescousse du web
 
Frameworks : A history of violence
Frameworks : A history of violenceFrameworks : A history of violence
Frameworks : A history of violence
 
Php 100k
Php 100kPhp 100k
Php 100k
 
La migration continue vers Symfony
La migration continue vers SymfonyLa migration continue vers Symfony
La migration continue vers Symfony
 
La programmation asynchrone... et les pates
La programmation asynchrone... et les patesLa programmation asynchrone... et les pates
La programmation asynchrone... et les pates
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
Ce bon vieux propel
Ce bon vieux propelCe bon vieux propel
Ce bon vieux propel
 
Developing for Developers
Developing for DevelopersDeveloping for Developers
Developing for Developers
 

Último

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Último (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Symfony2 meets propel 1.5

  • 1. Symfony 2 meets Propel 1.5François Zaninotto
  • 2. François Zaninotto Head of the Web Development Team at eTF1, editor the web properties of the leading TV network in France. Former symfony 1 contributor Author of “The Definitive Guide to Symfony” (APress) Lead Developer of Propel since October, 2009 Interests: Web development, Usability, Agility, ROI Not a developer Twitter: @francoisz, Github: fzaninotto
  • 4. No surprise Backwards compatible with Propel 1.3 and 1.4 Faster than Propel 1.4, which was faster than Propel 1.3, which was... Very IDE friendly Better documented More robust (3 times as many unit tests as Propel 1.3) Fully integrated into symfony 1.3/1.4 (sfPropel15Plugin)
  • 5. Surprise! Major new features Model Queries Collections Many-to-many relationships Major new behaviors Nested Sets Concrete Table Inheritance Better Oracle Support
  • 6. Surprise! Major new features Model Queries Collections Many-to-many relationships Major new behaviors Nested Sets Concrete Table Inheritance Better Oracle Support Killer Feature Killer Feature
  • 7. Model Queries Model Queries are to the SQL query what ActiveRecord is to the table row Shift from the relational Paradigm to the Object paradigm in Queries Inspirations: SQL Alchemy, Doctrine, DbFinder, Arel Code generation makes it fast and IDE friendly Easy to learn and use MUCH cleaner custom model code Bye bye, Criteria!
  • 8. Model Queries $books = BookQuery::create() ->filterByPublishedAt(array( ‘max’ => time() )) ->filterByPublisher($publisher) ->useAuthorQuery() ->stillAlive() ->endUse() ->orderByTitle() ->find();
  • 9. Concrete Table Inheritance content id title article body video url structure data
  • 10. Concrete Table Inheritance: An Example $article = new Article(); $article->setTitle(‘France loses World Cup’); $article->setBody(‘Lorem Ipsum’); $article->save(); $video = new Video(); $video->setTitle(‘World Cup Goals’); $video->setUrl(‘http://www.youtube.com/xxx’); $video->save();
  • 11. > SELECT * FROMarticle; +----+------------------------+-------------+ | id | title | body | +----+------------------------+-------------+ | 1 | France loses World Cup | Lorem Ipsum | +----+------------------------+-------------+ > SELECT * FROMvideo; +----+-----------------+----------------------------+ | id | title | url | +----+-----------------+----------------------------+ | 2 | World Cup goals | http://www.youtube.com/xxx | +----+-----------------+----------------------------+ > SELECT * FROM content; +----+------------------------+ | id | title | +----+------------------------+ | 1 | France loses World Cup | | 2 | World Cup goals | +----+------------------------+
  • 12. Design your model in a true object-oriented way Let Propel do the mapping with the relational world Denormalize with ease for optimal performance Let PHP manipulate inheritance, not data replication. … Let PHP manipulate objects, not records. … Let PHP manipulate collections, not arrays. … Let PHP manipulate relations, not foreign keys.
  • 13. Continuousimprovementsthroughminor versions 1.5.1 PropelObjectCollection::toKeyValue() One-to-manyjoinedhydration (no LIMIT support) CLI enhancements 1.5.2 Namespaces ! ModelQuery::findOneOrCreate() aggregate_columnbehavior SQL Comments
  • 14. Continuous improvements through minor versions 1.5.1 PropelObjectCollection::toKeyValue() One-to-many joined hydration (no LIMIT support) CLI enhancements 1.5.2 Namespaces ! ModelQuery::findOneOrCreate() aggregate_column behavior SQL Comments Must Have Killer Feature
  • 15. Namespaces // in schema.xml <table name="book"namespace="Bookstore"> ... </table> // in application code useBookstoreookQuery; $book = BookQuery::create(); ->findOneByTitle(‘War And Peace’); echoget_class($book); // Bookstoreook $author = $book->getAuthor(); echoget_class($author); // Bookstoreeopleuthor
  • 16. Aggregate Table Behavior author id name book id title author_id * <table name="author"> <behavior name="aggregate_column"> <parameter name="name" value="nb_books" /> <parameter name="foreign_table" value="book" /> <parameter name="expression" value="COUNT(id)" /> </behavior> ... </table>
  • 17. Aggregate Table Behavior author id name nb_books book id title author_id * <table name="author"> <behavior name="aggregate_column"> <parameter name="name" value="nb_books" /> <parameter name="foreign_table" value="book" /> <parameter name="expression" value="COUNT(id)" /> </behavior> ... </table>
  • 18. Aggregate Table Behavior $author = new Author(); $author->setName(‘Leo Tolstoi'); $author->save(); echo $author->getNbBooks(); // 0 $book = new Book(); $book->setTitle(‘War and Peace’); $book->setAuthor($author); $book->save(); echo $author->getNbBooks(); // 1 $book->delete(); echo $author->getNbBooks(); // 0
  • 19. No, really, Propel is definitely NOT DEAD
  • 20. Propel 1.5 and Symfony
  • 21.
  • 22.
  • 23. Many of the symfony add-ons to Propel are now part of Propel 1.5 Model hooks, query hooks Behavior system (at buildtime, for better performance and power) auto_add_pkbehavior timestampable behavior isPrimaryString column attribute for automated __toString() No need for custom symfony code for these
  • 24. Why you may want to use Propel rather than Doctrine 2 No need to upgrade your Model code It’s fast (without any cache system - that’s code generation) It’s an ActiveRecord implementation It has behaviors It’s IDE friendly The model code is easy to understand and debug It has unique features (ModelQueries, concrete table inheritance, aggregate column behavior, etc.) It’s robust (3000+ unit tests) and already used by many developers It’s not alpha, it’s not beta, it’s already stable
  • 26. The PropelBundle is bundled with the Symfony2 Framework Register the bundle in the kernel // in hello/HelloKernel.php classHelloKernelextendsKernel { public functionregisterBundles() { $bundles = array( ... new SymfonyrameworkropelBundleundle(), ); return $bundles; } }
  • 27. Add Propel and Phing libraries in src/vendor/ > cd src/vendor > svn co http://svn.propelorm.org/branches/1.5/ propel > svn co http://svn.phing.info/tags/2.3.3 phing Add Propel and Phing paths to the project configuration # in hello/config/config.yml propel.config: path: %kernel.root_dir%/../src/vendor/propel phing_path: %kernel.root_dir%/../src/vendor/phing
  • 28. Test the installation by calling the project console > hello/console Symfony version 2.0.0-DEV - hello Usage: [options] command [arguments] propel :build Hub for Propel build commands (model, sql) :build-model Build the Propel Object Model classes based on XML schemas :build-sql Build the SQL generation code for all tables based on Propel XML schemas
  • 29. Usage
  • 30. Create an XML schema using namespaces // in src/Application/HelloBundle/Resources/config/schema.xml <?xml version="1.0" encoding="UTF-8"?> <database name="default" namespace="ApplicationelloBundleodel" defaultIdMethod="native"> <table name="book"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> <column name="title" type="varchar" primaryString="1" size="100" /> <column name="ISBN" type="varchar" size="20" /> <column name="author_id" type="integer" /> <foreign-key foreignTable="author"> <reference local="author_id" foreign="id" /> </foreign-key> </table> <table name="author"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> <column name="first_name" type="varchar" size="100" /> <column name="last_name" type="varchar" size="100" /> </table> </database>
  • 31. Create an XML schemas using namespaces // in src/Application/HelloBundle/Resources/config/schema.xml <?xml version="1.0" encoding="UTF-8"?> <database name="default" namespace="ApplicationelloBundleodel" defaultIdMethod="native"> <table name="book"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> <column name="title" type="varchar" primaryString="1" size="100" /> <column name="ISBN" type="varchar" size="20" /> <column name="author_id" type="integer" /> <foreign-key foreignTable="author"> <reference local="author_id" foreign="id" /> </foreign-key> </table> <table name="author"> <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" /> <column name="first_name" type="varchar" size="100" /> <column name="last_name" type="varchar" size="100" /> </table> </database>
  • 32. Build the model and SQL code > cd sandbox > hello/console propel:build src/Application/HelloBundle/ Model/ map/ om/ Author.php AuthorPeer.php AuthorQuery.php Book.php BookPeer.php BookQuery.php hello/propel/sql/ HelloBundle-schema.sql
  • 33. // in sandbox/src/application/HelloBundle/Model/Book.php namespaceApplicationelloBundleodel; useApplicationelloBundleodelmaseBook; /** * Skeleton subclass for representing a row from the * 'book' table. * * You should add additional methods to this class to meet * the application requirements. This class will only be * generated as long as it does not already exist in the * output directory. */ classBookextendsBaseBook { } // Book
  • 34. Setup your connection in the project configuration # in sandbox/hello/config/config.yml propel.dbal: driver: mysql user: root password: null dsn: mysql:host=localhost;dbname=test options: {}
  • 35. Use models in your actions as with Propel 1.5 alone Symfony handles the autoloading // in sandbox/src/Application/HelloBundle/Controller/HelloController.php namespaceApplicationelloBundleontroller; useSymfonyrameworkebBundleontroller; useApplicationelloBundleodeluthorQuery; classHelloControllerextendsController { public functionindexAction($name) { $author = AuthorQuery::create() ->findOneByName($name); return $this->render('HelloBundle:Hello:index', array('author' => $author)); } }
  • 36. That’s about it All the Propel features are ready to use… in the Propel way
  • 37. The Future of Propel 1.5 and Symfony2
  • 39. A lot left to do YAML format for the schema (and bundle override) Web Debug Toolbar Panel Form integration (Widgets, Validators, Model forms) Admin Generator Theme Documentation Unit tests
  • 40. And even more Embedded Relation Forms Admin generator on steroids Easy Custom Filter Cross-module links Plain text fields Advanced Object Routing Collection routes Nested routes A thousand more ideas worth implementing cf. sfPropel15Plugin cf. DbFinderPlugin
  • 41. Not much time to do so I’m already developing Propel I’m already developing sfPropel15Plugin I also have a full-time job …and a family Any help is welcome!
  • 42. Questions? Online Resources http://github.com/fzaninotto/symfony http://www.propelorm.org/ http://www.symfony-project.org/plugins/sfPropel15Plugin News about all that http://propel.posterous.com/ http://twitter.com/francoisz