SlideShare a Scribd company logo
symfony
   in action.


     WebTech 2007
symfony ?




• PHP 5 Web Framework

• Based on well-known projets   (Mojavi, Propel, Prado …)


• Open-Source (MIT licence)

• Sponsored by Sensio ( http://www.sensio.com/ )
cite from symfony book




If you have been looking for a Rails/Django-like
   framework for PHP projects with features such as:

·   simple templating and helpers
·   cache management
·   multiple environments support
·   deployment management
·   scaffolding
·   smart URLs
·   multilingual and I18N support
·   object model and MVC separation
·   Ajax support

...where all elements work seamlessly together, then
   symfony is made for you
don’t reinvent the wheel




• Follow best practices

• MVC Pattern : Model / View / Controller

• Unit and functional test framework

• Environment and deployment support

• Security (XSS protection)

• Extensible (plugin system)
a professional web framework




• Built from experience
• 1.0 stable, maintained with commercial
  support
• Growing community
  – Developpers in more than 80 countries
  – 100 000 visitors per month on
    symfony-project.com
• Open-Source Documentation
  – The book (450 pages - GFDL)
  – Askeet Tutorial (250 pages)
Sounds good ?
 Let’s try it !
requirements




• PHP5

• Web server (Apache)

• RDBMS (MySQL)
installation




• Sandbox
> wget http://www.symfony-project.com/get/sf_sandbox.tgz

• PEAR
> pear channel-discover pear.symfony-project.com
> pear install symfony/symfony


• Subversion
> svn checkout http://svn.symfony-project.com/branches/1.0/
  .
init new symfony project




                                            Project

                                         Application(s)
> mkdir WebTechComments
> cd WebTechComments
                                           Module(s)


> symfony init-project WebTechComments
                                          Actions(s)
> symfony init-app frontend
                                         Composant(s)


                                           Template
web server configuration




<VirtualHost *:80>

  ServerName WebTechComments
  DocumentRoot quot;/path/to/project/webquot;
  DirectoryIndex index.php

  Alias /sf /path/to/symfony/data/symfony/web/sf

  <Directory quot;/path/to/project/webquot;>
    AllowOverride All
  </Directory>

</VirtualHost>
demo




        Congratulations!

You have successfully created your
         symfony project.
object-relational mapping



• Tables as classes and records as objects
    public function getName()
    {
      return $this->getFirstName.' '.$this->getLastName();
                                                                        Relational      Object-Oriented
    }


                                                                        Table           Class
    public function getTotal()
                                                                        Row, record     Object
    {
      $total = 0;
                                                                        Field, column   Property
         foreach ($this->getItems() as $item)
        {
           $total += $item->getPrice() * $item->getQuantity();
        }
 
        return $total;
    }


• Object and Peer classes
    $article = new Article();
    ...
    $title = $article->getTitle();


    $articles = ArticlePeer::retrieveByPks(array(123, 124, 125));
create database schema



#/config/schema.yml
  propel:
    sessions:
     _attributes: { phpName: Session }
     id:
     date: timestamp
     speaker: varchar(255)
     topic: varchar(255)
     description: longvarchar
    comments:
     _attributes: { phpName: Comment }
     id:
     sessions_id:
       type: integer
       foreignTable: sessions
       foreignReference: id
       onDelete: cascade
       phpName: SessionId
       peerName: SESSION_ID
     author: varchar(255)
     content: longvarchar
     created_at:
build model and database




• Configuration
    – database access
    – Propel properties

•   Build model           > symfony propel-build-model
•   Build SQL             > symfony propel-build-sql
•   Create database       > symfony propel-insert-sql
•   Do them all           > symfony propel-build-all
define some test data




• Test data
# data/fixtures/data.yml
Session:
                                > symfony propel-load-data   frontend
 s1:
  date: 06/29/2007
  speaker: Test Speaker
  topic: Test Topic
  description: Just for testing
Comment:
 c1:
  sessions_id: s1
  author: Teo Tester
  content: It’s better when other do the tests
scafolding




• Create / Retrieval / Update / Delete (CRUD)

• Initiating or Generating Code
> symfony <TASK_NAME> <APP_NAME> <MODULE_NAME> <CLASS_NAME>
tasks: propel-init-crud, propel-generate-crud, and propel-init-admin




 > symfony propel-generate-crud frontend session Session
 > symfony propel-init-crud frontend comment Comment
routing




homepage:
                                                                       Internal URI
 url: /
                                                     <module>/<action>[?param1=value1][&param2=value2]
 param: { module: session, action: list }

<?php echo url_for(‘@homepage’) ?> => /
                                                                      External URL
                                                     http://www.example.com/module/action/[param1/value1]
session_view:
 url: /session/:id.html
 param: { module: session, action: view }
 requirements:
   id: d+

<?php echo link_to(‘@sesion_view?id=’.$session->getId()) ?> => /session/12.html


default:
 url: /:module/:action/*

<?php echo url_for(‘session/view?id=’.$session->getId()) ?>   => /session/view/id/12
view




• Templates
• Helpers
• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
view



                   <h1>Welcome</h1>

• Templates        <p>Welcome back, <?php echo $name ?>!</p>
                   <p>What would you like to do?</p>
                   <ul>
• Helpers           <li><?php echo link_to('Read', 'article/read') ?></li>
                    <li><?php echo link_to(‘Write', 'article/write') ?></li>
• Page layout      </ul>


• Code fragments
  – Partials
  – Components
  – Slots
view



                 <?php echo use_helper('HelperName') ?>
                 <?php echo use_helper('HelperName1', 'HelperName2' ) ?>
• Templates
                 <?php echo tag('input', array('name' => 'foo', 'type' => 'text')) ?>
• Helpers        <?php echo tag('input', 'name =foo type=text') ?>
                 => <input name=quot;fooquot; type=quot;textquot; />

• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
view




• Templates
• Helpers
• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
view




• Templates
• Helpers
• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
view




• Templates
• Helpers
• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
view




• Templates
• Helpers
• Page layout
• Code fragments
  – Partials
  – Components
  – Slots
controller




• Front controller

• Actions

• Request

• User sessions
• Validation
• Filters
controller



                     1 Define the core constants.

• Front controller   2 Locate the symfony libraries.
                     3 Load and initiate the core framework classes.

• Actions            4 Load the configuration.
                     5 Decode the request URL to determine the action to
                     execute and the request parameters.

• Request            6 If the action does not exist, redirect to the 404 error
                     action.
                     7 Activate filters (for instance, if the request needs
• User sessions      authentication).
                     8 Execute the filters, first pass.

• Validation         9 Execute the action and render the view.
                     10 Execute the filters, second pass.

• Filters            11# Output the response
controller

                     class mymoduleActions extends sfActions
                     {
                         public function executeIndex()
                         {
• Front controller           // Retrieving request parameters
                             $password = $this->getRequestParameter('password');


• Actions                    // Retrieving controller information
                             $moduleName = $this->getModuleName();
                             $actionName = $this->getActionName();  
• Request                    // Retrieving framework core objects
                             $request = $this->getRequest();

• User sessions              $userSession = $this->getUser();
                             $response = $this->getResponse();


• Validation           // Setting action variables to pass information to the
                     template
                             $this->setVar('foo', 'bar');

• Filters                    $this->foo = 'bar'; // Shorter version  
                         }
                     }
controller


                     $this->getRequest()->

                     getMethod() sfRequest::GET sfRequest::POST

• Front controller   getCookie('foo')
                     isXmlHttpRequest()
                     isSecure()

• Actions            hasParameter('foo')
                     getParameter('foo')

• Request            getParameterHolder()->getAll()

                     getLanguages()

• User sessions      getAcceptableContentTypes()

                     getFileNames()

• Validation         getFileSize($fileName)
                     getFileType($fileName)


• Filters            setAttribute(‘foo’)
                     getAttribute(‘foo’)
controller



                     $this->getUser()->

• Front controller
                     setAttribute('nickname', $nickname)

• Actions            getAttribute('nickname', ‘Default')


                     getAttributeHolder()->remove('nickname')
• Request            getAttributeHolder()->clear()


• User sessions
                     $this->setFlash('attrib', $value)

• Validation         $this->getFlash('attrib')



• Filters
controller


                     class myModuleActions extends sfActions
                     {
                         public function validateMyAction()
• Front controller       {
                             return ($this->getRequestParameter('id') > 0);
                         }
• Actions
                         public function handleErrorMyAction()
                         {
• Request                    $this->message = quot;Invalid parametersquot;;

                             return sfView::SUCCESS;
• User sessions          }

                         public function executeMyAction()
• Validation             {
                             $this->message = quot;The parameters are correctquot;;
                         }
• Filters            }
controller




• Front controller

• Actions

• Request

• User sessions
• Validation
• Filters
Live demo !
Questions ?



   Петър Вукадинов (patter)
   p.vukadinov@pi-consult.bg
      p.vukadinov@gmail.com

More Related Content

What's hot

Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
Kirill Chebunin
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
Kris Wallsmith
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
Fatc
FatcFatc
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
Vic Metcalfe
 
Beyond symfony 1.2 (Symfony Camp 2008)
Beyond symfony 1.2 (Symfony Camp 2008)Beyond symfony 1.2 (Symfony Camp 2008)
Beyond symfony 1.2 (Symfony Camp 2008)Fabien Potencier
 
Dependency Injection in PHP
Dependency Injection in PHPDependency Injection in PHP
Dependency Injection in PHP
Kacper Gunia
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundleth0masr
 
Dirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionDirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionAdam Trachtenberg
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
Luca Mearelli
 
Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3
Katy Slemon
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...D
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…D
 
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers CracowForget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Kacper Gunia
 

What's hot (20)

Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
Fatc
FatcFatc
Fatc
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 
Beyond symfony 1.2 (Symfony Camp 2008)
Beyond symfony 1.2 (Symfony Camp 2008)Beyond symfony 1.2 (Symfony Camp 2008)
Beyond symfony 1.2 (Symfony Camp 2008)
 
Dependency Injection in PHP
Dependency Injection in PHPDependency Injection in PHP
Dependency Injection in PHP
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundle
 
Dirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP ExtensionDirty Secrets of the PHP SOAP Extension
Dirty Secrets of the PHP SOAP Extension
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
 
Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3Crud operations using aws dynamo db with flask ap is and boto3
Crud operations using aws dynamo db with flask ap is and boto3
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
 
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
Things Your Mother Didn't Tell You About Bundle Configurations - Symfony Live...
 
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
Things Your Mother Didnt Tell You About Bundle Configurations - Symfony Live…
 
Forget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers CracowForget about Index.php and build you applications around HTTP - PHPers Cracow
Forget about Index.php and build you applications around HTTP - PHPers Cracow
 

Similar to symfony on action - WebTech 207

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
Darren Craig
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
Hugo Hamon
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
Michelangelo van Dam
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
Michelangelo van Dam
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
Fabien Potencier
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
Jason McCreary
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
Vrann Tulika
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
Lukas Smith
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
Paul Jones
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
Ben Scofield
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
Bo-Yi Wu
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
Marcus Ramberg
 
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
Jakub Zalas
 
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
Francois Zaninotto
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
Jacopo Romei
 

Similar to symfony on action - WebTech 207 (20)

関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Symfony2 revealed
Symfony2 revealedSymfony2 revealed
Symfony2 revealed
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
 
Magento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request FlowMagento Live Australia 2016: Request Flow
Magento Live Australia 2016: Request Flow
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12Symfony components in the wild, PHPNW12
Symfony components in the wild, PHPNW12
 
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
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 

symfony on action - WebTech 207

  • 1. symfony in action. WebTech 2007
  • 2. symfony ? • PHP 5 Web Framework • Based on well-known projets (Mojavi, Propel, Prado …) • Open-Source (MIT licence) • Sponsored by Sensio ( http://www.sensio.com/ )
  • 3. cite from symfony book If you have been looking for a Rails/Django-like framework for PHP projects with features such as: · simple templating and helpers · cache management · multiple environments support · deployment management · scaffolding · smart URLs · multilingual and I18N support · object model and MVC separation · Ajax support ...where all elements work seamlessly together, then symfony is made for you
  • 4. don’t reinvent the wheel • Follow best practices • MVC Pattern : Model / View / Controller • Unit and functional test framework • Environment and deployment support • Security (XSS protection) • Extensible (plugin system)
  • 5. a professional web framework • Built from experience • 1.0 stable, maintained with commercial support • Growing community – Developpers in more than 80 countries – 100 000 visitors per month on symfony-project.com • Open-Source Documentation – The book (450 pages - GFDL) – Askeet Tutorial (250 pages)
  • 6. Sounds good ? Let’s try it !
  • 7. requirements • PHP5 • Web server (Apache) • RDBMS (MySQL)
  • 8. installation • Sandbox > wget http://www.symfony-project.com/get/sf_sandbox.tgz • PEAR > pear channel-discover pear.symfony-project.com > pear install symfony/symfony • Subversion > svn checkout http://svn.symfony-project.com/branches/1.0/ .
  • 9. init new symfony project Project Application(s) > mkdir WebTechComments > cd WebTechComments Module(s) > symfony init-project WebTechComments Actions(s) > symfony init-app frontend Composant(s) Template
  • 10. web server configuration <VirtualHost *:80> ServerName WebTechComments DocumentRoot quot;/path/to/project/webquot; DirectoryIndex index.php Alias /sf /path/to/symfony/data/symfony/web/sf <Directory quot;/path/to/project/webquot;> AllowOverride All </Directory> </VirtualHost>
  • 11. demo Congratulations! You have successfully created your symfony project.
  • 12. object-relational mapping • Tables as classes and records as objects public function getName() { return $this->getFirstName.' '.$this->getLastName(); Relational Object-Oriented } Table Class public function getTotal() Row, record Object { $total = 0; Field, column Property foreach ($this->getItems() as $item) { $total += $item->getPrice() * $item->getQuantity(); }   return $total; } • Object and Peer classes $article = new Article(); ... $title = $article->getTitle(); $articles = ArticlePeer::retrieveByPks(array(123, 124, 125));
  • 13. create database schema #/config/schema.yml propel: sessions: _attributes: { phpName: Session } id: date: timestamp speaker: varchar(255) topic: varchar(255) description: longvarchar comments: _attributes: { phpName: Comment } id: sessions_id: type: integer foreignTable: sessions foreignReference: id onDelete: cascade phpName: SessionId peerName: SESSION_ID author: varchar(255) content: longvarchar created_at:
  • 14. build model and database • Configuration – database access – Propel properties • Build model > symfony propel-build-model • Build SQL > symfony propel-build-sql • Create database > symfony propel-insert-sql • Do them all > symfony propel-build-all
  • 15. define some test data • Test data # data/fixtures/data.yml Session: > symfony propel-load-data frontend s1: date: 06/29/2007 speaker: Test Speaker topic: Test Topic description: Just for testing Comment: c1: sessions_id: s1 author: Teo Tester content: It’s better when other do the tests
  • 16. scafolding • Create / Retrieval / Update / Delete (CRUD) • Initiating or Generating Code > symfony <TASK_NAME> <APP_NAME> <MODULE_NAME> <CLASS_NAME> tasks: propel-init-crud, propel-generate-crud, and propel-init-admin > symfony propel-generate-crud frontend session Session > symfony propel-init-crud frontend comment Comment
  • 17. routing homepage: Internal URI url: / <module>/<action>[?param1=value1][&param2=value2] param: { module: session, action: list } <?php echo url_for(‘@homepage’) ?> => / External URL http://www.example.com/module/action/[param1/value1] session_view: url: /session/:id.html param: { module: session, action: view } requirements: id: d+ <?php echo link_to(‘@sesion_view?id=’.$session->getId()) ?> => /session/12.html default: url: /:module/:action/* <?php echo url_for(‘session/view?id=’.$session->getId()) ?> => /session/view/id/12
  • 18. view • Templates • Helpers • Page layout • Code fragments – Partials – Components – Slots
  • 19. view <h1>Welcome</h1> • Templates <p>Welcome back, <?php echo $name ?>!</p> <p>What would you like to do?</p> <ul> • Helpers <li><?php echo link_to('Read', 'article/read') ?></li> <li><?php echo link_to(‘Write', 'article/write') ?></li> • Page layout </ul> • Code fragments – Partials – Components – Slots
  • 20. view <?php echo use_helper('HelperName') ?> <?php echo use_helper('HelperName1', 'HelperName2' ) ?> • Templates <?php echo tag('input', array('name' => 'foo', 'type' => 'text')) ?> • Helpers <?php echo tag('input', 'name =foo type=text') ?> => <input name=quot;fooquot; type=quot;textquot; /> • Page layout • Code fragments – Partials – Components – Slots
  • 21. view • Templates • Helpers • Page layout • Code fragments – Partials – Components – Slots
  • 22. view • Templates • Helpers • Page layout • Code fragments – Partials – Components – Slots
  • 23. view • Templates • Helpers • Page layout • Code fragments – Partials – Components – Slots
  • 24. view • Templates • Helpers • Page layout • Code fragments – Partials – Components – Slots
  • 25. controller • Front controller • Actions • Request • User sessions • Validation • Filters
  • 26. controller 1 Define the core constants. • Front controller 2 Locate the symfony libraries. 3 Load and initiate the core framework classes. • Actions 4 Load the configuration. 5 Decode the request URL to determine the action to execute and the request parameters. • Request 6 If the action does not exist, redirect to the 404 error action. 7 Activate filters (for instance, if the request needs • User sessions authentication). 8 Execute the filters, first pass. • Validation 9 Execute the action and render the view. 10 Execute the filters, second pass. • Filters 11# Output the response
  • 27. controller class mymoduleActions extends sfActions { public function executeIndex() { • Front controller // Retrieving request parameters $password = $this->getRequestParameter('password'); • Actions // Retrieving controller information $moduleName = $this->getModuleName(); $actionName = $this->getActionName();   • Request // Retrieving framework core objects $request = $this->getRequest(); • User sessions $userSession = $this->getUser(); $response = $this->getResponse(); • Validation // Setting action variables to pass information to the template $this->setVar('foo', 'bar'); • Filters $this->foo = 'bar'; // Shorter version   } }
  • 28. controller $this->getRequest()-> getMethod() sfRequest::GET sfRequest::POST • Front controller getCookie('foo') isXmlHttpRequest() isSecure() • Actions hasParameter('foo') getParameter('foo') • Request getParameterHolder()->getAll() getLanguages() • User sessions getAcceptableContentTypes() getFileNames() • Validation getFileSize($fileName) getFileType($fileName) • Filters setAttribute(‘foo’) getAttribute(‘foo’)
  • 29. controller $this->getUser()-> • Front controller setAttribute('nickname', $nickname) • Actions getAttribute('nickname', ‘Default') getAttributeHolder()->remove('nickname') • Request getAttributeHolder()->clear() • User sessions $this->setFlash('attrib', $value) • Validation $this->getFlash('attrib') • Filters
  • 30. controller class myModuleActions extends sfActions { public function validateMyAction() • Front controller { return ($this->getRequestParameter('id') > 0); } • Actions public function handleErrorMyAction() { • Request $this->message = quot;Invalid parametersquot;; return sfView::SUCCESS; • User sessions } public function executeMyAction() • Validation { $this->message = quot;The parameters are correctquot;; } • Filters }
  • 31. controller • Front controller • Actions • Request • User sessions • Validation • Filters
  • 33. Questions ? Петър Вукадинов (patter) p.vukadinov@pi-consult.bg p.vukadinov@gmail.com