MVC IN S YMFONY Sayed Ahmed B.Sc. Eng. in Computer Science & Engineering M. Sc. in Computer Science Exploring Computing for 14+ years

Slides:



Advertisements
Similar presentations
Other Web Application Development Technologies. PHP.
Advertisements

Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.
PHP Reusing Code and Writing Functions.
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Ruby on Rails Model of MVC. Model-View-Controller Paradigm A way of organizing a software system Benefits: Isolation of business logic from the user interface.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Razor. Slide 2 Remember this? Browser Web Server HTTP Request HTTP Response (Web page / code) Client code (script) Interpret request Generate HTML and.
Direct Congress Dan Skorupski Dan Vingo. Inner workings Reminder: MVC design pattern Procedural view: From request to response o Request passed to a view.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
Ruby on Rails. What is Ruby on Rails? Ruby on Rails is an open source full-stack web framework. It is an alternative to PHP/MySQL. It can render templates,
Ruby on Rails CSCI 6314 David Gaspar Jennifer Garcia Avila.
ZFApp Preview Walkthrough. What is ZFApp? ZFApp is an application framework built on top of Zend Framework Fully compatible with the latest ZF Versions.
#psuweb13 WORDPRESS THEMES 101 A WORDPRESS THEME INTRO WORKSHOP.
A Close Look Inside the SharePoint Engine Randy Williams, MVP MOSS Synergy Corporate Technologies
S YMFONY ORM - D OCTRINE Sayed Ahmed B.Sc. Eng. in Computer Science & Engineering M. Sc. in Computer Science Exploring Computing for 14+ years
WHAT IS A WEB APP? Van Kelly Yeshiva University July 6, 2013.
Server-side Scripting Powering the webs favourite services.
W EB A PPLICATIONS & W EB S ERVICES DEVELOPMENT USING Z END F RAMEWORK Sayed Ahmed B. Sc. Engineering in Computer Science and Engineering M. Sc. in Computer.
ASP.NET Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital.
Architecture of the web Client Server retrieved or generated web page.
Chapter 6 Server-side Programming: Java Servlets
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
F UNCTIONAL T ESTS IN S YMFONY Sayed Ahmed B.Sc. Eng. in Computer Science & Engineering M. Sc. in Computer Science Exploring Computing for 14+ years
Rails & Ajax Module 5. Introduction to Rails Overview of Rails Rails is Ruby based “A development framework for Web-based applications” Rails uses the.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Date : 3/04/2010 Web Technology Solutions Class: PHP Web Application Frameworks.
 Pages within our Framework  Categories within Framework  Products within Framework  Model-View-Controller description of Page, category and products.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
 A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Display Page (HTML/CSS)
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
CS 160 and CMPE/SE 131 Software Engineering February 11 Class Meeting Department of Computer Science Department of Computer Engineering San José State.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Ruby on Rails. Web Framework for Ruby Designed to make it easier to develop, deploy, and maintain web applications Design with Model-View-Controller –almost.
CGS 3066: Web Programming and Design Spring 2016 PHP.
Customizing Share Document Previews Will Abson Senior Integrations Engineer and Share Extras Project Lead
Workshop Partner:. Saad Amin Cofounder and CTO Inspire Chittagong Cofounder & Managing Director Codework Builders and Assets Ltd.
Basics Components of Web Design & Development Basics, Components, Design and Development.
I2CE Framework I2CE: Intrahealth Informatics Core Engine Base Web Framework on which iHRIS Manage and iHRIS Qualify are built on: Module Structure Magic.
Web Technology Solutions
Creating a Theme From Scratch in Drupal
Introduction to Dynamic Web Programming
Department of Computer Science
MVC Architecture, Symfony Framework for PHP Web Apps
Play Framework: Introduction
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
Scripted Page Web App Development (Java Server Pages)
Content Management Systems
AVOIR -African virtual
PHP Training at GoLogica in Bangalore
TYPES OF SERVER. TYPES OF SERVER What is a server.
The Model Layer What is Model?
Secure Web Programming
Developing a Model-View-Controller Component for Joomla
ASP.NET MVC Web Development
Architecture of the web
ASP.NET Imran Rashid CTO at ManiWeber Technologies.
Client-Server Model: Requesting a Web Page
Web Application Development Using PHP
Struts BY: Tejashri Udavant..
Presentation transcript:

MVC IN S YMFONY Sayed Ahmed B.Sc. Eng. in Computer Science & Engineering M. Sc. in Computer Science Exploring Computing for 14+ years 10/8/2011 1

MVC D ESIGN P ATTERN Model: defines the business logic the database belongs to this layer Classes and files related to models are stored in lib/model/ directory View: is what the user interacts with a template engine is part of this layer the View layer is mainly made of PHP templates stored in various templates/ directories Controller: is a piece of code that calls the Model to get some data that it passes to the View for rendering to the client. all requests are managed by front controllers (index.php and frontend_dev.php) These front controllers delegate the real work to actions. these actions are logically grouped into modules 10/8/

MVC IN P ICTURE 10/8/

T HE L AYOUT The pages generated by Symfony by default has similar structure such as Header Template/Body Footer We can separate the Headers and Footers from each page and place them in a single central place and link them (header and footer files) to all pages We can use a Design Pattern for the purpose decorator design pattern 10/8/

T HE D ECORATOR P ATTERN 10/8/

T HE D ECORATOR P ATTERN 10/8/

D ECORATION IN S YMFONY the template is decorated after the content is rendered by a global template called a layout in symfony 10/8/

D ECORATION IN S YMFONY The default layout of an application is called layout.php and can be found in the apps/frontend/templates/ directory This directory contains all the global templates for an application Important: You can modify the layout to include all the extra stuff that you need for all pages including the headers and footers You can replace the default symfony layout with your own layout and create a section for the body/template In the example layout file $sf_content is the main content/template as seen in the pictures of the page $sf_content is the generated HTML based on the current page it is defined by the framework itself and contains the HTML generated by the action. 10/8/

I MAGE, CSS, AND JS F ILES web/images/ web/css/ the generate:project task has created three directories for the project assets: web/images/ for images, web/~css|CSS~/ for stylesheets, and web/js/ for JavaScripts 10/8/

H ELPER A helper is a function, defined by symfony, that can take parameters and returns HTML code. Most of the time, helpers are time-savers, they package code snippets frequently used in templates The include_stylesheets() helper generates tags for stylesheets. 10/8/

H ELPER, S TYLESHEETS, AND V IEW The stylesheet files can be included by the include_stylesheets() function call But how does the helper know which stylesheets to include? Using View layer View layer generated by generate:app 10/8/

V IEW LAYER GENERATED BY GENERATE : APP FOR THE TEMPLATE ‘ LAYOUT ’ 10/8/

S TYLESHEETS, AND V IEW stylesheets: [main.css, jobs.css, job.css] symfony prefixes relative paths with /~css|CSS~/. Change media stylesheets: [main.css, jobs.css, job.css, print: { media: print }] The view.yml configuration file can be customized on a per-module basis create a view.yml file in the apps/frontend/modules/job/config/ directory # apps/frontend/modules/job/config/view.yml indexSuccess: stylesheets: [jobs.css] showSuccess: stylesheets: [job.css] 10/8/

T EMPLATES indexSuccess and showSuccess sections are the template names associated with the index and show actions respectively 10/8/

C ONFIGURATION P RINCIPLES IN SYMFONY Configuration Principles in symfony For many symfony configuration files, the same setting can be defined at different levels: The default configuration is located in the framework The global configuration for the project (in config/) The local configuration for an application (in apps/APP/config/) The local configuration restricted to a module (in apps/APP/modules/MODULE/config/) At runtime, the configuration system merges all the values from the different files if they exist and caches the result for better performance. use_stylesheet() helper can be used (in the template file) to include a stylesheet from a template: Instead of using view.yml 10/8/

L INKING TO JAVA S CRIPT FILES Symmetrically, the JavaScript configuration is done via the javascripts entry of the view.yml configuration file and the use_javascript() helper defines JavaScript files to include for a template. use_javascript() helper defines JavaScript files to include for a template. 10/8/

A CTIONS AND TEMPLATES The index action is the Controller part of the page and the associated template, indexSuccess.php, is the View part: 10/8/

T HE A CTION Each action is represented by a method of a class For the job homepage, the class is jobActions (the name of the module suffixed by Actions) and the method is executeIndex() (execute suffixed by the name of the action). It retrieves all the jobs from the database 10/8/

T HE T EMPLATE By default, the template name associated with an action is deduced by symfony 10/8/

T HE " FORWARD " M ETHODS F AMILY $this->forward404If(!$this->job); $this->forward404(); $this->forward('default', '404'); 10/8/

T HE R EQUEST AND THE R ESPONSE The Request The sfWebRequest class wraps the $_SERVER, $_COOKIE, $_GET, $_POST, and $_FILES PHP global arrays: Method name -- PHP equivalent getMethod() -- $_SERVER['REQUEST_METHOD'] getUri() $_SERVER['REQUEST_URI'] getReferer() $_SERVER['HTTP_REFERER'] getHost() $_SERVER['HTTP_HOST'] getLanguages() $_SERVER['HTTP_ACCEPT_LANGUAGE'] getCharsets() $_SERVER['HTTP_ACCEPT_CHARSET'] isXmlHttpRequest() $_SERVER['X_REQUESTED_WITH'] == 'XMLHttpRequest' getHttpHeader() $_SERVER getCookie() $_COOKIE isSecure() $_SERVER['HTTPS'] getFiles() $_FILES getGetParameter() $_GET getPostParameter() $_POST getUrlParameter() $_SERVER['PATH_INFO'] getRemoteAddress() $_SERVER['REMOTE_ADDR'] 10/8/

T HE R ESPONSE The Response The sfWebResponse class wraps the header() and setrawcookie() PHP methods: Method name PHP equivalent setCookie() setrawcookie() setStatusCode() header() setHttpHeader() header() setContentType() header() addVaryHttpHeader() header() addCacheControlHttpHeader() header() 10/8/

REFERENCES 10/8/