DOC PREVIEW
CU-Boulder CSCI 5448 - Symfony Framework

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Hemalatha What is Symfony Symfony is an Open source web application framework for PHP5 projects PHP is a general purpose scripting language designed for web development The best use of PHP is in creating dynamic web pages in client side Symfony is designed to optimize the development of web applications It adds a new layer on top of PHP providing tools that speedup the development of complex web applications Used in high demand e business websites Compatible with most of the available database servers including MySQL Oracle Microsoft SQL server Symfony History First released on October 2005 by founder Fabien Potencier When PHP5 was released Fabien decided that the available tools had reached a mature enough stage to be integrated into a full featured framework He then developed Symfony code basing his work on MVC architecture the propel object relational mapping and ruby on rails templating helpers After successful testing of a few projects Fabien released Symfony under Open Source licence Then Fabien along with his colleague authored a book with excellent documentation as he believed extensive documentation in english is important to be adopted globally Features of Symfony Simple to use Easy to install and configure on most platforms It is independent of database engine Easily adaptable for complex class definitions It has a lot of inbuilt functionalities that are conventional The user has to configure only unconventional functions Compliant with most web practices and design patterns The MVC Architecture Symfony is based on the classic web design pattern called the MVC pattern This consists of three levels The model The application logic that is the information using which the application operates The view This renders the model into a webpage that is suited for usage by the end user The controller This responds to user actions and it invokes changes in model or view as required Source http en wikipedia org wiki Model view controller Symfony VS MVC The Components of MVC The Components of Symfony Model layer Action Database abstraction Template Data access View layer View Template Layout Controller layer Front controller Action View Layout Client SymFONY WORKFLOW Internet Front Controller Action Layout View Logic Data Access Template Database Abstraction Database Server http www symfony project org book 1 0 02 Exploring Symfony s Code Script example A Flat Script Very Easy to write Very difficult to maintain Script example 2 In Symphony the entire code can be listed using just three files 1 List Action Script example 3 2 List Template 3 Layout Symfony libraries PEAR This package has all the symphony libraries Recommeneded for most users Subversion SVN Recommended for experienced or advanced PHP developers Pake A CLI Command line Interface utility Lime A unit testing utility Creole A Database abstraction engine Propel ORM tool Object persistence and query service Phing Build system used by model Page Creation in Symfony Symfony groups pages into modules Before creating a page an empty module has to be created A default index action is created for each module It has an action method and template file The logic behind page is stored in action and the presentation is stored in template Pages without a logic would still require an action method that is empty Similarly if we execute a URL without a template method symfony will give an error Page Creation in Symfony 2 Action example Adding an action means adding executeAction method to the Action class The name of an action is always executeXxx where Xxx is the name of action Page Creation in Symfony 3 Template example Normal PHP syntax to print time Alternative PHP syntax used for templates It is more readable to the user Passing Information Passing information from action to template Action does all the complicated calculation data retrieval and tests Symphony makes the attributes of action class directly accessible to template in the global namespace The following figure shows that the template has direct access to action attributes Forms Templates can use the traditional HTML forms as below However Symfony has helper functions defined which makes writing forms faster and easier URL and Action Names Symfony s routing system allows complete separation between actual action name and the form of URL needed to call it This allows custom formatting of URL Example A call to index of an action module could look like this http localhost myapp dev php article index id 123 But the URL can be written in a completely different way with a simple change in routing yml configuration The routing system automatically peels the request parameters from the smart URL Linking Action to other action There is a total decoupling between the action name and its corresponding URL Changing the way URLs look at later stages might become cumbersome since it will only work with default routing To avoid this use the link to helper to create hyperlinks for the actions The resulting HTML might look the same as previous however when we change the routing rules all the templates reformats the URLs correctly Symphony Configuration Symphony configuration system uses YAML language to be simple and readable We can deal with multiple environments and also set parameters through definition cascade This provides versatility to the developer sfConfig is the object using which some configuration files can be accessed Symfony has a lot of configuration files and they are useful when high level of customization is required Inside Control Layer In Symfony control layer the code linking the business logic and presentation is split into several components for different purposes 1 Front Controller It is the unique entry point to the application it loads configuration and determines the actions to execute Actions They contain the logic They check the integrity of a request and gets the presentation layer ready Request response and session These objects give access to request parameters the response headers and the persistent user data Filters Portions of code executed for every request either before or after the action Inside the View Layer Templates It contains HTML codes and some basic PHP codes Usually calls to varaiables are declared in action and helper class Helpers are PHP codes that return HTML code Code fragments Often it might be required to insert HTML or PHP codes in several places To avoid repeating these codes PHPinclude statement is used View Configuration In


View Full Document

CU-Boulder CSCI 5448 - Symfony Framework

Documents in this Course
Django

Django

42 pages

ENRS

ENRS

30 pages

PhoneGap

PhoneGap

22 pages

Load more
Download Symfony Framework
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Symfony Framework and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Symfony Framework 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?