SlideShare a Scribd company logo
1 of 34
Symfony2 Tutorial




    By Alexios Tzanetopoulos
What is Symfony2?
• Symfony2 is a PHP Framework that:

 1. Provides a selection of components (i.e. the Symfony2
 Components) and third-party libraries (e.g. Swiftmailer18 for sending
 emails);

 2. Provides sensible configuration and a "glue" library that ties all of
 these pieces together.

 3. Provides the feeling of objective programming cause it’s a MVC
 Framework.
What is MVC?
• MVC is a software architecture that separates the representation of
  information from the user's interaction with it. It consists of:

   • A controller can send commands to its associated view to change the view's
     presentation of the model (e.g., by scrolling through a document).
   • A model notifies its associated views and controllers when there has been a
     change in its state. This notification allows the views to produce updated
     output, and the controllers to change the available set of commands.
   • A view requests from the model the information that it needs to generate an
     output representation.
Pros
• It allows a lot of flexibility around how the project is setup.
• It is very fast and comparable to other web frameworks
• Propel and Doctrine are both supported but not enforced. The
  creator can choose to use whatever they want as an ORM(Object-
  relational mapping). Or none at all.
• Some of the Symfony2 components are now being implemented in
  large projects such as Drupal and PhpBB.
• Enough documentation and tutorials
Cons
• Requires command line (troll)
• Not easy to learn
Flat PHP (blog posts page)
•   <?php // index.php
•   $link = mysql_connect('localhost', 'myuser', 'mypassword');
•   mysql_select_db('blog_db', $link);
•   $result = mysql_query('SELECT id, title FROM post', $link); ?>
•   <!DOCTYPE html>
•   <html><head>
•   <title>List of Posts</title> </head> <body>
•   <h1>List of Posts</h1> <ul>
•   <?php while ($row = mysql_fetch_assoc($result)): ?>
•   <li>
•   <a href="/show.php?id=<?php echo $row['id'] ?>">
•   <?php echo $row['title'] ?> </a>
•   </li> <?php endwhile; ?> </ul> </body> </html>
•   <?php mysql_close($link); ?>
Result?
• No error-checking
• Poor organization
• Difficult to reuse code
Ready to learn
symfony2?
1st step Installation
• Download from http://symfony.com/download (standard version)
• If you use php 5,4 it contains built-in web server
• From 5,3 and below use your own web server (e.g xampp)
• Unpack folder in htdocs
• Test it @ http://localhost/symfony2/web/app_dev.php
2nd step Create application bundle
• As you know, a Symfony2 project is made up of bundles.
• Execute in command line:
      php app/console generate:bundle --namespace=Ens/JobeetBundle --
      format=yml
• Clear cache then:
       php app/console cache:clear --env=prod
       php app/console cache:clear --env=dev
3rd step The Data Model
Edit the parameters file
;app/config/parameters.ini
[parameters]
  database_driver = pdo_mysql
  database_host = localhost
  database_name = jobeet
  database_user = root
  database_password = password


Use doctrine in command line to auto-create the database in mysql:
        php app/console doctrine:database:create
3rd step The Data Model
# src/Ens/JobeetBundle/Resources/config/doctrine/CategoryAffiliate.orm.yml
EnsJobeetBundleEntityCategoryAffiliate:
 type: entity
 table: category_affiliate
 id:
   id:
     type: integer
     generator: { strategy: AUTO }
 manyToOne:
   category:
     targetEntity: Category
     inversedBy: category_affiliates
     joinColumn:
       name: category_id
       referencedColumnName: id
   affiliate:
     targetEntity: Affiliate
     inversedBy: category_affiliates
     joinColumn:
       name: affiliate_id
       referencedColumnName: id
3rd step The ORM
• Now Doctrine can generate the classes that define our objects for us with the command:
  php app/console doctrine:generate:entities EnsJobeetBundle
    /**
•     * Get location
•     *
•     * @return string
•     */
•    public function getLocation()
•    {
•         return $this->location;
•    }
3rd step The ORM
We will also ask Doctrine to create our database tables (or to update
them to reflect our setup) with the command:
      php app/console doctrine:schema:update --force
      Updating database schema...
      Database schema updated successfully! "7" queries were executed
4th step Initial Data
• We will use DoctrineFixturesBundle.
• Add the following to your deps file:
 [doctrine-fixtures]
 git=http://github.com/doctrine/data-fixtures.git

 [DoctrineFixturesBundle]
  git=http://github.com/doctrine/DoctrineFixturesBundle.git
  target=/bundles/Symfony/Bundle/DoctrineFixturesBundle
 version=origin/2.0
• Update the vendor libraries:
 php bin/vendors install --reinstall
4th step Load data in tables
• To do this just execute this command:
      php app/console doctrine:fixtures:load

• See it in Action in the Browser
• create a new controller with actions for listing, creating, editing and
  deleting jobs executing this command:
 php app/console doctrine:generate:crud --entity=EnsJobeetBundle:Job --route-prefix=ens_job --
 with-write --format=yml
Till now?
• Barely written PHP code
• Working web module for the job model
• Ready to be tweaked and customized



 Remember, no PHP code also means no bugs!
5th step The Layout


• Create a new file layout.html.twig in the
  src/Ens/JobeetBundle/Resources/views/ directory and put in the
  following code:
5th step The Layout
Tell Symfony to make them available to the public.
      php app/console assets:install web
5th step The Routing
• Used to be: /job.php?id=1
• Now with symfony2: /job/1/show
• Even: /job/sensio-labs/paris-france/1/web-developer
5th step The Routing
• Edit the ens_job_show route from the job.yml file:

      # src/Ens/JobeetBundle/Resources/config/routing/job.yml
      # ...
      ens_job_show:
      pattern: /{company}/{location}/{id}/{position}
      defaults: { _controller: "EnsJobeetBundle:Job:show" }
5th step The Routing
• Now, we need to pass all the parameters for the changed route for it to work:
      <!-- src/Ens/JobeetBundle/Resources/views/Job/index.html.twig -->
      <!-- ... -->
      <a href="{{ path('ens_job_show', { 'id': entity.id, 'company':
               entity.company, 'location': entity.location, 'position': entity.position })
      }}">
      {{ entity.position }}
      </a>
      <!-- ... -->
5th step The Routing
• NOW: http://jobeet.local/job/Sensio Labs/Paris, France/1/Web Developer
• Need to remove spaces
• This corrects the problem:
       static public function slugify($text)
       {
       // replace all non letters or digits by -
            $text = preg_replace('/W+/', '-', $text);

             // trim and lowercase
             $text = strtolower(trim($text, '-'));

             return $text;
         }
5th step Route Debugging
• See every route in your application:
       php app/console router:debug
• Or a single route:
       php app/console router:debug ens_job_show
6th step Testing
• 2 methods:
  Unit tests and Functional tests

• Unit tests verify that each method and function is working properly
• Functional tests verify that the resulting application behaves correctly
  as a whole
7th and last step Bundles
• Bundles are like modules in Drupal.
• Even symfony2 is a bundle itself.
• Many useful bundles such as
      -FOSUserBundle (Provides user management for your Symfony2
        Project. Compatible with Doctrine ORM & ODM, and Propel)
      -SonataAdminBundle (AdminBundle - The missing Symfony2
        Admin Generator)
      -FOSFacebookBundle (Integrate the Facebook Platform into your
       Symfony2 application)
      -KnpPaginatorBundle (SEO friendly Symfony2 paginator to sort
       and paginate)
Q&A
Manual:
-http://symfony.com/doc/current/book/index.html

Tutorial
-http://www.ens.ro/2012/03/21/jobeet-tutorial-with-symfony2/

More Related Content

What's hot

Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer packageLattapon Yodsuwan
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginHaehnchen
 
Zend Framework 2 Components
Zend Framework 2 ComponentsZend Framework 2 Components
Zend Framework 2 ComponentsShawn Stratton
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsBruno Rocha
 
Writing php extensions in golang
Writing php extensions in golangWriting php extensions in golang
Writing php extensions in golangdo_aki
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldGraham Weldon
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Ezobject wrapper workshop
Ezobject wrapper workshopEzobject wrapper workshop
Ezobject wrapper workshopKaliop-slide
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...King Foo
 

What's hot (20)

Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
Zend Framework 2 Components
Zend Framework 2 ComponentsZend Framework 2 Components
Zend Framework 2 Components
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
What The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIsWhat The Flask? and how to use it with some Google APIs
What The Flask? and how to use it with some Google APIs
 
Writing php extensions in golang
Writing php extensions in golangWriting php extensions in golang
Writing php extensions in golang
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
CakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your worldCakePHP 2.0 - It'll rock your world
CakePHP 2.0 - It'll rock your world
 
How PHP works
How PHP works How PHP works
How PHP works
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
A dive into Symfony 4
A dive into Symfony 4A dive into Symfony 4
A dive into Symfony 4
 
Ezobject wrapper workshop
Ezobject wrapper workshopEzobject wrapper workshop
Ezobject wrapper workshop
 
Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
 
php
phpphp
php
 
PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 

Viewers also liked

Presentation du framework symfony
Presentation du framework symfonyPresentation du framework symfony
Presentation du framework symfonyJeremy Gachet
 
Presentation Symfony
Presentation SymfonyPresentation Symfony
Presentation SymfonyJeremy Gachet
 
Symfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleSymfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleAbdelkader Rhouati
 
Introduction à CakePHP
Introduction à CakePHPIntroduction à CakePHP
Introduction à CakePHPPierre MARTIN
 
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ss
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ssAlphorm.com Support de la Formation Symfony 3 , les fondamentaux-ss
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ssAlphorm
 
Introduction to symfony2
Introduction to symfony2Introduction to symfony2
Introduction to symfony2Pablo Godel
 
Php symfony and software lifecycle
Php symfony and software lifecyclePhp symfony and software lifecycle
Php symfony and software lifecyclePierre Joye
 
3.2 Les Infrastructures de données spatiales régionales développées dans le p...
3.2 Les Infrastructures de données spatiales régionales développées dans le p...3.2 Les Infrastructures de données spatiales régionales développées dans le p...
3.2 Les Infrastructures de données spatiales régionales développées dans le p...grisicap
 
de Google Maps à OpenStreetMap
de Google Maps à OpenStreetMapde Google Maps à OpenStreetMap
de Google Maps à OpenStreetMapFrédéric Rodrigo
 
Symfony2: Get your project started
Symfony2: Get your project startedSymfony2: Get your project started
Symfony2: Get your project startedRyan Weaver
 
Installation apache mandriva
Installation apache mandrivaInstallation apache mandriva
Installation apache mandrivaMajid CHADAD
 
ConfSL: Sviluppo Applicazioni web con Symfony
ConfSL: Sviluppo Applicazioni web con SymfonyConfSL: Sviluppo Applicazioni web con Symfony
ConfSL: Sviluppo Applicazioni web con SymfonyLuca Saba
 
rapport_stage_issame
rapport_stage_issamerapport_stage_issame
rapport_stage_issameAMAL Issame
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type scriptRavi Mone
 
Node.js et MongoDB: Mongoose
Node.js et MongoDB: MongooseNode.js et MongoDB: Mongoose
Node.js et MongoDB: Mongoosejeromegn
 
Bases de données Spatiales - POSTGIS
Bases de données Spatiales - POSTGISBases de données Spatiales - POSTGIS
Bases de données Spatiales - POSTGISOmar El Kharki
 

Viewers also liked (20)

Presentation du framework symfony
Presentation du framework symfonyPresentation du framework symfony
Presentation du framework symfony
 
Presentation Symfony
Presentation SymfonyPresentation Symfony
Presentation Symfony
 
Symfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleSymfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation Générale
 
Symfony 3
Symfony 3Symfony 3
Symfony 3
 
Introduction à CakePHP
Introduction à CakePHPIntroduction à CakePHP
Introduction à CakePHP
 
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ss
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ssAlphorm.com Support de la Formation Symfony 3 , les fondamentaux-ss
Alphorm.com Support de la Formation Symfony 3 , les fondamentaux-ss
 
Introduction to symfony2
Introduction to symfony2Introduction to symfony2
Introduction to symfony2
 
Php symfony and software lifecycle
Php symfony and software lifecyclePhp symfony and software lifecycle
Php symfony and software lifecycle
 
3.2 Les Infrastructures de données spatiales régionales développées dans le p...
3.2 Les Infrastructures de données spatiales régionales développées dans le p...3.2 Les Infrastructures de données spatiales régionales développées dans le p...
3.2 Les Infrastructures de données spatiales régionales développées dans le p...
 
de Google Maps à OpenStreetMap
de Google Maps à OpenStreetMapde Google Maps à OpenStreetMap
de Google Maps à OpenStreetMap
 
Symfony2: Get your project started
Symfony2: Get your project startedSymfony2: Get your project started
Symfony2: Get your project started
 
Installation apache mandriva
Installation apache mandrivaInstallation apache mandriva
Installation apache mandriva
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Symfony ignite
Symfony igniteSymfony ignite
Symfony ignite
 
ConfSL: Sviluppo Applicazioni web con Symfony
ConfSL: Sviluppo Applicazioni web con SymfonyConfSL: Sviluppo Applicazioni web con Symfony
ConfSL: Sviluppo Applicazioni web con Symfony
 
rapport_stage_issame
rapport_stage_issamerapport_stage_issame
rapport_stage_issame
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
Node.js et MongoDB: Mongoose
Node.js et MongoDB: MongooseNode.js et MongoDB: Mongoose
Node.js et MongoDB: Mongoose
 
Bases de données spatiales
Bases de données spatialesBases de données spatiales
Bases de données spatiales
 
Bases de données Spatiales - POSTGIS
Bases de données Spatiales - POSTGISBases de données Spatiales - POSTGIS
Bases de données Spatiales - POSTGIS
 

Similar to Symfony2 Introduction Presentation

Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin GeneratorJohn Cleveley
 
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
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesShabir Ahmad
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Creating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 ComponentsCreating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 ComponentsDeepak Chandani
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkRyan Weaver
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architectureHai Vo Hoang
 
Customizing oro crm webinar
Customizing oro crm webinarCustomizing oro crm webinar
Customizing oro crm webinarOro Inc.
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4openerpwiki
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOCCarl Lu
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_companyGanesh Kulkarni
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 Joe Ferguson
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3Borni DHIFI
 
Writing Ansible Modules (DENOG11)
Writing Ansible Modules (DENOG11)Writing Ansible Modules (DENOG11)
Writing Ansible Modules (DENOG11)Martin Schütte
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Antonio Peric-Mazar
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015Oro Inc.
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 

Similar to Symfony2 Introduction Presentation (20)

Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
 
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
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Drupal 8 - Core and API Changes
Drupal 8 - Core and API ChangesDrupal 8 - Core and API Changes
Drupal 8 - Core and API Changes
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Creating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 ComponentsCreating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 Components
 
Hands-on with the Symfony2 Framework
Hands-on with the Symfony2 FrameworkHands-on with the Symfony2 Framework
Hands-on with the Symfony2 Framework
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Intro to drupal_7_architecture
Intro to drupal_7_architectureIntro to drupal_7_architecture
Intro to drupal_7_architecture
 
Customizing oro crm webinar
Customizing oro crm webinarCustomizing oro crm webinar
Customizing oro crm webinar
 
Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4Open erp technical_memento_v0.6.3_a4
Open erp technical_memento_v0.6.3_a4
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_companyEdp bootstrapping a-software_company
Edp bootstrapping a-software_company
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
 
Writing Ansible Modules (DENOG11)
Writing Ansible Modules (DENOG11)Writing Ansible Modules (DENOG11)
Writing Ansible Modules (DENOG11)
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 

More from Nerd Tzanetopoulos (11)

Ajax for dummies, and not only.
Ajax for dummies, and not only.Ajax for dummies, and not only.
Ajax for dummies, and not only.
 
Symperasmata
SymperasmataSymperasmata
Symperasmata
 
Peirama2
Peirama2Peirama2
Peirama2
 
Peirama2
Peirama2Peirama2
Peirama2
 
Peirama2
Peirama2Peirama2
Peirama2
 
Genikeuseis
GenikeuseisGenikeuseis
Genikeuseis
 
Peirama
PeiramaPeirama
Peirama
 
Ypotheseis
YpotheseisYpotheseis
Ypotheseis
 
Enaysma
EnaysmaEnaysma
Enaysma
 
Ergasia Kausima
Ergasia KausimaErgasia Kausima
Ergasia Kausima
 
εργασία καύσιμα
εργασία καύσιμαεργασία καύσιμα
εργασία καύσιμα
 

Recently uploaded

GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEApsara Of India
 
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...Apsara Of India
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130Suhani Kapoor
 
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...anamikaraghav4
 
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur EscortsVIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...Neha Kaur
 
👙 Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service
👙  Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service👙  Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service
👙 Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Serviceanamikaraghav4
 
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolVIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolRiya Pathan
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914Delhi Call girls
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goasexy call girls service in goa
 
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...rahim quresi
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaRiya Pathan
 

Recently uploaded (20)

GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICEGV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
GV'S 24 CLUB & BAR CONTACT 09602870969 CALL GIRLS IN UDAIPUR ESCORT SERVICE
 
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
Karnal Call Girls 8860008073 Dyal Singh Colony Call Girls Service in Karnal E...
 
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
VIP Call Girls Service Banjara Hills Hyderabad Call +91-8250192130
 
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
Russian Call Girl South End Park - Call 8250192130 Rs-3500 with A/C Room Cash...
 
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
 
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur EscortsVIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
VIP Call Girls Nagpur Megha Call 7001035870 Meet With Nagpur Escorts
 
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Behala ⟟ 8250192130 ⟟ High Class Call Girl In...
 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
VIP Call Girls Darjeeling Aaradhya 8250192130 Independent Escort Service Darj...
 
Goa Call Girls 9316020077 Call Girls In Goa By Russian Call Girl in goa
Goa Call Girls 9316020077 Call Girls  In Goa By Russian Call Girl in goaGoa Call Girls 9316020077 Call Girls  In Goa By Russian Call Girl in goa
Goa Call Girls 9316020077 Call Girls In Goa By Russian Call Girl in goa
 
👙 Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service
👙  Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service👙  Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service
👙 Kolkata Call Girls Sonagachi 💫💫7001035870 Model escorts Service
 
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service AsansolVIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
VIP Call Girls Asansol Ananya 8250192130 Independent Escort Service Asansol
 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914
 
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort GoaDesi Bhabhi Call Girls  In Goa  💃 730 02 72 001💃desi Bhabhi Escort Goa
Desi Bhabhi Call Girls In Goa 💃 730 02 72 001💃desi Bhabhi Escort Goa
 
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
Call Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls GoaCall Girls In Goa  9316020077 Goa  Call Girl By Indian Call Girls Goa
Call Girls In Goa 9316020077 Goa Call Girl By Indian Call Girls Goa
 
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
𓀤Call On 6297143586 𓀤 Ultadanga Call Girls In All Kolkata 24/7 Provide Call W...
 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service GulbargaVIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
VIP Call Girls in Gulbarga Aarohi 8250192130 Independent Escort Service Gulbarga
 
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in  Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Malviya Nagar, (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Symfony2 Introduction Presentation

  • 1. Symfony2 Tutorial By Alexios Tzanetopoulos
  • 2. What is Symfony2? • Symfony2 is a PHP Framework that: 1. Provides a selection of components (i.e. the Symfony2 Components) and third-party libraries (e.g. Swiftmailer18 for sending emails); 2. Provides sensible configuration and a "glue" library that ties all of these pieces together. 3. Provides the feeling of objective programming cause it’s a MVC Framework.
  • 3. What is MVC? • MVC is a software architecture that separates the representation of information from the user's interaction with it. It consists of: • A controller can send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document). • A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. • A view requests from the model the information that it needs to generate an output representation.
  • 4. Pros • It allows a lot of flexibility around how the project is setup. • It is very fast and comparable to other web frameworks • Propel and Doctrine are both supported but not enforced. The creator can choose to use whatever they want as an ORM(Object- relational mapping). Or none at all. • Some of the Symfony2 components are now being implemented in large projects such as Drupal and PhpBB. • Enough documentation and tutorials
  • 5. Cons • Requires command line (troll) • Not easy to learn
  • 6. Flat PHP (blog posts page) • <?php // index.php • $link = mysql_connect('localhost', 'myuser', 'mypassword'); • mysql_select_db('blog_db', $link); • $result = mysql_query('SELECT id, title FROM post', $link); ?> • <!DOCTYPE html> • <html><head> • <title>List of Posts</title> </head> <body> • <h1>List of Posts</h1> <ul> • <?php while ($row = mysql_fetch_assoc($result)): ?> • <li> • <a href="/show.php?id=<?php echo $row['id'] ?>"> • <?php echo $row['title'] ?> </a> • </li> <?php endwhile; ?> </ul> </body> </html> • <?php mysql_close($link); ?>
  • 7. Result? • No error-checking • Poor organization • Difficult to reuse code
  • 9. 1st step Installation • Download from http://symfony.com/download (standard version) • If you use php 5,4 it contains built-in web server • From 5,3 and below use your own web server (e.g xampp) • Unpack folder in htdocs • Test it @ http://localhost/symfony2/web/app_dev.php
  • 10.
  • 11. 2nd step Create application bundle • As you know, a Symfony2 project is made up of bundles. • Execute in command line: php app/console generate:bundle --namespace=Ens/JobeetBundle -- format=yml • Clear cache then: php app/console cache:clear --env=prod php app/console cache:clear --env=dev
  • 12. 3rd step The Data Model Edit the parameters file ;app/config/parameters.ini [parameters] database_driver = pdo_mysql database_host = localhost database_name = jobeet database_user = root database_password = password Use doctrine in command line to auto-create the database in mysql: php app/console doctrine:database:create
  • 13. 3rd step The Data Model # src/Ens/JobeetBundle/Resources/config/doctrine/CategoryAffiliate.orm.yml EnsJobeetBundleEntityCategoryAffiliate: type: entity table: category_affiliate id: id: type: integer generator: { strategy: AUTO } manyToOne: category: targetEntity: Category inversedBy: category_affiliates joinColumn: name: category_id referencedColumnName: id affiliate: targetEntity: Affiliate inversedBy: category_affiliates joinColumn: name: affiliate_id referencedColumnName: id
  • 14. 3rd step The ORM • Now Doctrine can generate the classes that define our objects for us with the command: php app/console doctrine:generate:entities EnsJobeetBundle /** • * Get location • * • * @return string • */ • public function getLocation() • { • return $this->location; • }
  • 15. 3rd step The ORM We will also ask Doctrine to create our database tables (or to update them to reflect our setup) with the command: php app/console doctrine:schema:update --force Updating database schema... Database schema updated successfully! "7" queries were executed
  • 16. 4th step Initial Data • We will use DoctrineFixturesBundle. • Add the following to your deps file: [doctrine-fixtures] git=http://github.com/doctrine/data-fixtures.git [DoctrineFixturesBundle] git=http://github.com/doctrine/DoctrineFixturesBundle.git target=/bundles/Symfony/Bundle/DoctrineFixturesBundle version=origin/2.0 • Update the vendor libraries: php bin/vendors install --reinstall
  • 17.
  • 18. 4th step Load data in tables • To do this just execute this command: php app/console doctrine:fixtures:load • See it in Action in the Browser • create a new controller with actions for listing, creating, editing and deleting jobs executing this command: php app/console doctrine:generate:crud --entity=EnsJobeetBundle:Job --route-prefix=ens_job -- with-write --format=yml
  • 19.
  • 20.
  • 21. Till now? • Barely written PHP code • Working web module for the job model • Ready to be tweaked and customized Remember, no PHP code also means no bugs!
  • 22. 5th step The Layout • Create a new file layout.html.twig in the src/Ens/JobeetBundle/Resources/views/ directory and put in the following code:
  • 23.
  • 24. 5th step The Layout Tell Symfony to make them available to the public. php app/console assets:install web
  • 25.
  • 26. 5th step The Routing • Used to be: /job.php?id=1 • Now with symfony2: /job/1/show • Even: /job/sensio-labs/paris-france/1/web-developer
  • 27. 5th step The Routing • Edit the ens_job_show route from the job.yml file: # src/Ens/JobeetBundle/Resources/config/routing/job.yml # ... ens_job_show: pattern: /{company}/{location}/{id}/{position} defaults: { _controller: "EnsJobeetBundle:Job:show" }
  • 28. 5th step The Routing • Now, we need to pass all the parameters for the changed route for it to work: <!-- src/Ens/JobeetBundle/Resources/views/Job/index.html.twig --> <!-- ... --> <a href="{{ path('ens_job_show', { 'id': entity.id, 'company': entity.company, 'location': entity.location, 'position': entity.position }) }}"> {{ entity.position }} </a> <!-- ... -->
  • 29. 5th step The Routing • NOW: http://jobeet.local/job/Sensio Labs/Paris, France/1/Web Developer • Need to remove spaces • This corrects the problem: static public function slugify($text) { // replace all non letters or digits by - $text = preg_replace('/W+/', '-', $text); // trim and lowercase $text = strtolower(trim($text, '-')); return $text; }
  • 30. 5th step Route Debugging • See every route in your application: php app/console router:debug • Or a single route: php app/console router:debug ens_job_show
  • 31.
  • 32. 6th step Testing • 2 methods: Unit tests and Functional tests • Unit tests verify that each method and function is working properly • Functional tests verify that the resulting application behaves correctly as a whole
  • 33. 7th and last step Bundles • Bundles are like modules in Drupal. • Even symfony2 is a bundle itself. • Many useful bundles such as -FOSUserBundle (Provides user management for your Symfony2 Project. Compatible with Doctrine ORM & ODM, and Propel) -SonataAdminBundle (AdminBundle - The missing Symfony2 Admin Generator) -FOSFacebookBundle (Integrate the Facebook Platform into your Symfony2 application) -KnpPaginatorBundle (SEO friendly Symfony2 paginator to sort and paginate)