SlideShare une entreprise Scribd logo
1  sur  13
ZEND FRAMEWORK:
INTRODUZIONE AD MVC




                      Copyright © 2007, Zend Technologies Inc.
L'applicazione




                                                    | 31 mar    |
                 Zend Framework dalla A alla Zend
                                                        2008   2
Divide et Impera

  •  E' sempre conveniente separare il livello che incapsula
    la business logic da quello di presentazione

  •  Per questo è importante dividere il codice HTML da
    quello PHP.




                                                                            | 31 mar    |
                                         Zend Framework dalla A alla Zend
                                                                                2008   3
Ottenere la separazione

  •  Ci sono molti modi per dividere la logica dai template.

  •  Sicuramente la maniera più veloce (ma non la più
    conveniente) è quella di includere le pagine HTML
    all'interno dei nostri script PHP.




                                                                             | 31 mar    |
                                          Zend Framework dalla A alla Zend
                                                                                 2008   4
Esempio di separazione

  index.php                     index.tpl

  $content = array();           <html>
  $content['title']='Titolo';   [...]
  $content['text']='Testo';     <body>
                                <div id=”title”>
  include_once('index.tpl');     <?php echo $content['title'] ?>
                                </div>


                                <div id=”text”>
                                 <?php echo $content['text'] ?>
                                </div>
                                </body>
                                </html>


                                                                                      | 31 mar    |
                                                   Zend Framework dalla A alla Zend
                                                                                          2008   5
Design Pattern?

  •  Non è facile trovare il modo perfetto per scrivere
    un'applicazione.

  •  I design pattern sicuramente ci vengono in aiuto per
    identificare i nostri bisogni e costruire applicazioni solide
    e manutenibili.




                                                                               | 31 mar    |
                                            Zend Framework dalla A alla Zend
                                                                                   2008   6
Il Pattern MVC

  •  Il design pattern MVC implementa la concezione di
    Divide et Impera dividendo l'applicazione addirittura in
    tre blocchi distinti:
     • Model
     • View
     • Controller




                                                                             | 31 mar    |
                                          Zend Framework dalla A alla Zend
                                                                                 2008   7
Controller

  •  I controller si occupano di analizzare le richieste
    dell'utente per inviarlo alla pagina desiderata.

  •  Mappano i cambiamenti della User Interface
    (normalmente attraverso una vista) verso i modelli.




                                                                               | 31 mar    |
                                            Zend Framework dalla A alla Zend
                                                                                   2008   8
Model

 •  Mantengono lo stato
   dell'applicazio
   n
   e e utilizzano realmente le risorse (database,file e altro)‫‏‬

 •  Rispondono alle richieste di dati

 •  Incapsulano la Business Logic




                                                                             | 31 mar    |
                                          Zend Framework dalla A alla Zend
                                                                                 2008   9
View

 •  Visualizzano la User Interface

 •  Richiedono dati ai Modelli (attraverso i controller)‫‏‬

 •  Inviano eventi e richieste ai controller




                                                                                          |
                                                                              | 31 mar
                                           Zend Framework dalla A alla Zend              1
                                                                                  2008
                                                                                         0
Flusso della nostra applicazione

                                                     BOOTSTRAP                        index.php
                                                                                     Tutte le richieste vengono inviate a
                                                                                     un file di bootstrap che istanzia un oggetto
                                                   Front Controller
       Lista dei post                                                                front controller per elaborare le richieste.

       l'utente richiede la visualizzazione                            Il Front Controller istanzia il controller che si
       dei post                                                        occupa della gestione dei post e chiama
                                                                       l'azione di visualizzazione


class Post                                         Controller: Post
                                                                                      PostController
                                                                                      extends Zend_Controller_Action
  Model: Post
                                                      Action: List                    listAction()‫‏‬
                                                                      I dati elaborati dal modello vengono inviati
                                                                      alla vista per la creazione dell'html finale


Viene istanziato un oggetto del
modello che si occupa di estrarre i
                                                        View: List                    list.pthml
post dal db. I risultati vengono              L'html viene creato e visualizzato
restituiti dal modello al controller          all'utente
                                                                                                                                       |
                                                                                                                           | 31 mar
                                                                                       Zend Framework dalla A alla Zend               1
                                                                                                                               2008
                                                                                                                                      1
Il formato della richiesta

  •  Nell'esempio precedente l'utente richiedeva la lista dei
    post.

  •  La richiesta per essere interpretata dal front controller di
    Zend Framework deve essere composta in questo
    modo:


            http:// server / controller / action

            http:// localhost / post / list

                                                                                           |
                                                                               | 31 mar
                                            Zend Framework dalla A alla Zend              1
                                                                                   2008
                                                                                          2
THANK YOU


“
    Zend Framework
    Simplicity, Meet Power

    massimiliano@zend.com

Contenu connexe

Tendances

Introduzioni ai services in Angular 4 e ad RxJS
Introduzioni ai services in Angular 4 e ad RxJSIntroduzioni ai services in Angular 4 e ad RxJS
Introduzioni ai services in Angular 4 e ad RxJSGiovanni Buffa
 
Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Giovanni Buffa
 
Slide typescript - net campus
Slide typescript - net campusSlide typescript - net campus
Slide typescript - net campusDotNetCampus
 
Acadevmy - Angular Overview
Acadevmy - Angular OverviewAcadevmy - Angular Overview
Acadevmy - Angular OverviewFrancesco Sciuti
 
Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Manuel Scapolan
 
SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)Valerio Radice
 
Introduzione ad angular 7/8
Introduzione ad angular 7/8Introduzione ad angular 7/8
Introduzione ad angular 7/8Valerio Radice
 
Domain Driven Design e CQRS
Domain Driven Design e CQRSDomain Driven Design e CQRS
Domain Driven Design e CQRSManuel Scapolan
 
AntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreAntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreManuel Scapolan
 
Introduzione ad Angular CLI
Introduzione ad Angular CLIIntroduzione ad Angular CLI
Introduzione ad Angular CLIGiovanni Buffa
 
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Wellnet srl
 
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Eugenio Minardi
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroAndrea Dottor
 
Introduzione a jQuery
Introduzione a jQueryIntroduzione a jQuery
Introduzione a jQuerySandro Marcon
 
Customize ASP.NET Core scaffolding
Customize ASP.NET Core scaffoldingCustomize ASP.NET Core scaffolding
Customize ASP.NET Core scaffoldingAndrea Dottor
 
Spring Framework
Spring FrameworkSpring Framework
Spring FrameworkNaLUG
 

Tendances (20)

Introduzioni ai services in Angular 4 e ad RxJS
Introduzioni ai services in Angular 4 e ad RxJSIntroduzioni ai services in Angular 4 e ad RxJS
Introduzioni ai services in Angular 4 e ad RxJS
 
Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4
 
Slide typescript - net campus
Slide typescript - net campusSlide typescript - net campus
Slide typescript - net campus
 
Acadevmy - Angular Overview
Acadevmy - Angular OverviewAcadevmy - Angular Overview
Acadevmy - Angular Overview
 
Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3
 
SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)SPRING - MAVEN - REST API (ITA - Luglio 2017)
SPRING - MAVEN - REST API (ITA - Luglio 2017)
 
Require js
Require jsRequire js
Require js
 
Introduzione ad angular 7/8
Introduzione ad angular 7/8Introduzione ad angular 7/8
Introduzione ad angular 7/8
 
AngularJS-Intro
AngularJS-IntroAngularJS-Intro
AngularJS-Intro
 
Angular js: routing
Angular js: routingAngular js: routing
Angular js: routing
 
Domain Driven Design e CQRS
Domain Driven Design e CQRSDomain Driven Design e CQRS
Domain Driven Design e CQRS
 
AntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreAntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatore
 
Introduzione ad Angular CLI
Introduzione ad Angular CLIIntroduzione ad Angular CLI
Introduzione ad Angular CLI
 
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
 
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8Come sfruttare tutte le potenzialità di Symfony in Drupal 8
Come sfruttare tutte le potenzialità di Symfony in Drupal 8
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuro
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
 
Introduzione a jQuery
Introduzione a jQueryIntroduzione a jQuery
Introduzione a jQuery
 
Customize ASP.NET Core scaffolding
Customize ASP.NET Core scaffoldingCustomize ASP.NET Core scaffolding
Customize ASP.NET Core scaffolding
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 

En vedette

Addict Wipii English 081128
Addict Wipii English 081128Addict Wipii English 081128
Addict Wipii English 081128eardigo
 
3rd Workshop on Social Information Retrieval for Technology-Enhanced Learnin...
3rd Workshop onSocial  Information Retrieval for Technology-Enhanced Learnin...3rd Workshop onSocial  Information Retrieval for Technology-Enhanced Learnin...
3rd Workshop on Social Information Retrieval for Technology-Enhanced Learnin...Hendrik Drachsler
 
INFLUENZA H1N1, desde la ciencia, el mito y la realidad
INFLUENZA H1N1, desde la ciencia, el mito y la realidadINFLUENZA H1N1, desde la ciencia, el mito y la realidad
INFLUENZA H1N1, desde la ciencia, el mito y la realidadPablo Gallegos
 
Elderhostilepart109
Elderhostilepart109Elderhostilepart109
Elderhostilepart109lblodgett
 
Hoe ziet de toekomst van Learning Analytics er uit?
Hoe ziet de toekomst van Learning Analytics er uit?Hoe ziet de toekomst van Learning Analytics er uit?
Hoe ziet de toekomst van Learning Analytics er uit?Hendrik Drachsler
 
Inbound Marketing Cookbook
Inbound Marketing CookbookInbound Marketing Cookbook
Inbound Marketing CookbookEddie Choi
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideSharepiwnioyh
 
A Long Walk to Water - Lssn 14
A Long Walk to Water - Lssn 14A Long Walk to Water - Lssn 14
A Long Walk to Water - Lssn 14Terri Weiss
 
Marketing strategies to increase the ROI on mobile
Marketing strategies to increase the ROI on mobileMarketing strategies to increase the ROI on mobile
Marketing strategies to increase the ROI on mobileAmit Ambastha
 
Lyddie: Unit3 lesson4
Lyddie:  Unit3 lesson4Lyddie:  Unit3 lesson4
Lyddie: Unit3 lesson4Terri Weiss
 
Conferenceware meeting functionalities
Conferenceware meeting functionalitiesConferenceware meeting functionalities
Conferenceware meeting functionalitiesguest01d22d
 
ASP.NET MVC 3 in area of Javascript and Ajax improvement
ASP.NET MVC 3 in area of Javascript and Ajax improvementASP.NET MVC 3 in area of Javascript and Ajax improvement
ASP.NET MVC 3 in area of Javascript and Ajax improvementSuthep Sangvirotjanaphat
 
My Friends Descriptions 5th B
My Friends Descriptions 5th BMy Friends Descriptions 5th B
My Friends Descriptions 5th Benglishdepartment
 
Presentation of the SIG TEL 4 Health
Presentation of the SIG TEL 4 HealthPresentation of the SIG TEL 4 Health
Presentation of the SIG TEL 4 HealthHendrik Drachsler
 
Mobiles as a Marketing Platform
Mobiles as a Marketing PlatformMobiles as a Marketing Platform
Mobiles as a Marketing PlatformKinshuk Sunil
 

En vedette (20)

Chemistryfm
ChemistryfmChemistryfm
Chemistryfm
 
Addict Wipii English 081128
Addict Wipii English 081128Addict Wipii English 081128
Addict Wipii English 081128
 
Fqenlaceionico
FqenlaceionicoFqenlaceionico
Fqenlaceionico
 
3rd Workshop on Social Information Retrieval for Technology-Enhanced Learnin...
3rd Workshop onSocial  Information Retrieval for Technology-Enhanced Learnin...3rd Workshop onSocial  Information Retrieval for Technology-Enhanced Learnin...
3rd Workshop on Social Information Retrieval for Technology-Enhanced Learnin...
 
INFLUENZA H1N1, desde la ciencia, el mito y la realidad
INFLUENZA H1N1, desde la ciencia, el mito y la realidadINFLUENZA H1N1, desde la ciencia, el mito y la realidad
INFLUENZA H1N1, desde la ciencia, el mito y la realidad
 
Elderhostilepart109
Elderhostilepart109Elderhostilepart109
Elderhostilepart109
 
Hoe ziet de toekomst van Learning Analytics er uit?
Hoe ziet de toekomst van Learning Analytics er uit?Hoe ziet de toekomst van Learning Analytics er uit?
Hoe ziet de toekomst van Learning Analytics er uit?
 
Inbound Marketing Cookbook
Inbound Marketing CookbookInbound Marketing Cookbook
Inbound Marketing Cookbook
 
香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare香港六合彩 &raquo; SlideShare
香港六合彩 &raquo; SlideShare
 
A Long Walk to Water - Lssn 14
A Long Walk to Water - Lssn 14A Long Walk to Water - Lssn 14
A Long Walk to Water - Lssn 14
 
Marketing strategies to increase the ROI on mobile
Marketing strategies to increase the ROI on mobileMarketing strategies to increase the ROI on mobile
Marketing strategies to increase the ROI on mobile
 
Lyddie: Unit3 lesson4
Lyddie:  Unit3 lesson4Lyddie:  Unit3 lesson4
Lyddie: Unit3 lesson4
 
Conferenceware meeting functionalities
Conferenceware meeting functionalitiesConferenceware meeting functionalities
Conferenceware meeting functionalities
 
ASP.NET MVC 3 in area of Javascript and Ajax improvement
ASP.NET MVC 3 in area of Javascript and Ajax improvementASP.NET MVC 3 in area of Javascript and Ajax improvement
ASP.NET MVC 3 in area of Javascript and Ajax improvement
 
Anyway
AnywayAnyway
Anyway
 
My Friends Descriptions 5th B
My Friends Descriptions 5th BMy Friends Descriptions 5th B
My Friends Descriptions 5th B
 
Doctor
DoctorDoctor
Doctor
 
JSX
JSXJSX
JSX
 
Presentation of the SIG TEL 4 Health
Presentation of the SIG TEL 4 HealthPresentation of the SIG TEL 4 Health
Presentation of the SIG TEL 4 Health
 
Mobiles as a Marketing Platform
Mobiles as a Marketing PlatformMobiles as a Marketing Platform
Mobiles as a Marketing Platform
 

Similaire à Zend Framework Workshop Parte1

Massimiliano Wosz - Zend Framework 1.5
Massimiliano Wosz - Zend Framework 1.5Massimiliano Wosz - Zend Framework 1.5
Massimiliano Wosz - Zend Framework 1.5Francesco Fullone
 
Meetup ASP.NET Core Angular
Meetup ASP.NET Core AngularMeetup ASP.NET Core Angular
Meetup ASP.NET Core Angulardotnetcode
 
Design Patterns - enterprise patterns (part I)
Design Patterns - enterprise patterns (part I)Design Patterns - enterprise patterns (part I)
Design Patterns - enterprise patterns (part I)Fabio Armani
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven DesignAndrea Saltarello
 
Dal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersDal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersAndrea Dottor
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the WebClaudio Gandelli
 
Introduzione al Domain Driven Design (DDD)
Introduzione al Domain Driven Design (DDD)Introduzione al Domain Driven Design (DDD)
Introduzione al Domain Driven Design (DDD)DotNetMarche
 
Design pattern architetturali Model View Controller, MVP e MVVM
Design pattern architetturali   Model View Controller, MVP e MVVMDesign pattern architetturali   Model View Controller, MVP e MVVM
Design pattern architetturali Model View Controller, MVP e MVVMRiccardo Cardin
 
Cert03 70-486 developing asp.net mvc 4 web applications
Cert03   70-486 developing asp.net mvc 4 web applicationsCert03   70-486 developing asp.net mvc 4 web applications
Cert03 70-486 developing asp.net mvc 4 web applicationsDotNetCampus
 
Yii Framework - yes it is rapid web application development (Parte 1)
Yii Framework - yes it is rapid web application development (Parte 1)Yii Framework - yes it is rapid web application development (Parte 1)
Yii Framework - yes it is rapid web application development (Parte 1)brossi676
 
Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockoutDotNetCampus
 
Dependency injection questa sconosciuta
Dependency injection questa sconosciutaDependency injection questa sconosciuta
Dependency injection questa sconosciutaAndrea Dottor
 
Cert04 70-484 - essentials of developing windows store apps
Cert04   70-484 - essentials of developing windows store appsCert04   70-484 - essentials of developing windows store apps
Cert04 70-484 - essentials of developing windows store appsDotNetCampus
 
We Want Web - Web Applications con MVC 3
We Want Web - Web Applications con MVC 3We Want Web - Web Applications con MVC 3
We Want Web - Web Applications con MVC 3DomusDotNet
 
Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0Alessandro Forte
 

Similaire à Zend Framework Workshop Parte1 (20)

Massimiliano Wosz - Zend Framework 1.5
Massimiliano Wosz - Zend Framework 1.5Massimiliano Wosz - Zend Framework 1.5
Massimiliano Wosz - Zend Framework 1.5
 
MVC and Struts 1
MVC and Struts 1MVC and Struts 1
MVC and Struts 1
 
Meetup ASP.NET Core Angular
Meetup ASP.NET Core AngularMeetup ASP.NET Core Angular
Meetup ASP.NET Core Angular
 
Design Patterns - enterprise patterns (part I)
Design Patterns - enterprise patterns (part I)Design Patterns - enterprise patterns (part I)
Design Patterns - enterprise patterns (part I)
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven Design
 
Dal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersDal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developers
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the Web
 
ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
Introduzione al Domain Driven Design (DDD)
Introduzione al Domain Driven Design (DDD)Introduzione al Domain Driven Design (DDD)
Introduzione al Domain Driven Design (DDD)
 
Design pattern architetturali Model View Controller, MVP e MVVM
Design pattern architetturali   Model View Controller, MVP e MVVMDesign pattern architetturali   Model View Controller, MVP e MVVM
Design pattern architetturali Model View Controller, MVP e MVVM
 
Cert03 70-486 developing asp.net mvc 4 web applications
Cert03   70-486 developing asp.net mvc 4 web applicationsCert03   70-486 developing asp.net mvc 4 web applications
Cert03 70-486 developing asp.net mvc 4 web applications
 
Yii Framework - yes it is rapid web application development (Parte 1)
Yii Framework - yes it is rapid web application development (Parte 1)Yii Framework - yes it is rapid web application development (Parte 1)
Yii Framework - yes it is rapid web application development (Parte 1)
 
m-v-vm @ UgiAlt.Net
m-v-vm @ UgiAlt.Netm-v-vm @ UgiAlt.Net
m-v-vm @ UgiAlt.Net
 
beContent
beContentbeContent
beContent
 
Zendframework Parte2
Zendframework    Parte2Zendframework    Parte2
Zendframework Parte2
 
Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockout
 
Dependency injection questa sconosciuta
Dependency injection questa sconosciutaDependency injection questa sconosciuta
Dependency injection questa sconosciuta
 
Cert04 70-484 - essentials of developing windows store apps
Cert04   70-484 - essentials of developing windows store appsCert04   70-484 - essentials of developing windows store apps
Cert04 70-484 - essentials of developing windows store apps
 
We Want Web - Web Applications con MVC 3
We Want Web - Web Applications con MVC 3We Want Web - Web Applications con MVC 3
We Want Web - Web Applications con MVC 3
 
Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0
 

Zend Framework Workshop Parte1

  • 1. ZEND FRAMEWORK: INTRODUZIONE AD MVC Copyright © 2007, Zend Technologies Inc.
  • 2. L'applicazione | 31 mar | Zend Framework dalla A alla Zend 2008 2
  • 3. Divide et Impera •  E' sempre conveniente separare il livello che incapsula la business logic da quello di presentazione •  Per questo è importante dividere il codice HTML da quello PHP. | 31 mar | Zend Framework dalla A alla Zend 2008 3
  • 4. Ottenere la separazione •  Ci sono molti modi per dividere la logica dai template. •  Sicuramente la maniera più veloce (ma non la più conveniente) è quella di includere le pagine HTML all'interno dei nostri script PHP. | 31 mar | Zend Framework dalla A alla Zend 2008 4
  • 5. Esempio di separazione index.php index.tpl $content = array(); <html> $content['title']='Titolo'; [...] $content['text']='Testo'; <body> <div id=”title”> include_once('index.tpl'); <?php echo $content['title'] ?> </div> <div id=”text”> <?php echo $content['text'] ?> </div> </body> </html> | 31 mar | Zend Framework dalla A alla Zend 2008 5
  • 6. Design Pattern? •  Non è facile trovare il modo perfetto per scrivere un'applicazione. •  I design pattern sicuramente ci vengono in aiuto per identificare i nostri bisogni e costruire applicazioni solide e manutenibili. | 31 mar | Zend Framework dalla A alla Zend 2008 6
  • 7. Il Pattern MVC •  Il design pattern MVC implementa la concezione di Divide et Impera dividendo l'applicazione addirittura in tre blocchi distinti: • Model • View • Controller | 31 mar | Zend Framework dalla A alla Zend 2008 7
  • 8. Controller •  I controller si occupano di analizzare le richieste dell'utente per inviarlo alla pagina desiderata. •  Mappano i cambiamenti della User Interface (normalmente attraverso una vista) verso i modelli. | 31 mar | Zend Framework dalla A alla Zend 2008 8
  • 9. Model •  Mantengono lo stato dell'applicazio n e e utilizzano realmente le risorse (database,file e altro)‫‏‬ •  Rispondono alle richieste di dati •  Incapsulano la Business Logic | 31 mar | Zend Framework dalla A alla Zend 2008 9
  • 10. View •  Visualizzano la User Interface •  Richiedono dati ai Modelli (attraverso i controller)‫‏‬ •  Inviano eventi e richieste ai controller | | 31 mar Zend Framework dalla A alla Zend 1 2008 0
  • 11. Flusso della nostra applicazione BOOTSTRAP index.php Tutte le richieste vengono inviate a un file di bootstrap che istanzia un oggetto Front Controller Lista dei post front controller per elaborare le richieste. l'utente richiede la visualizzazione Il Front Controller istanzia il controller che si dei post occupa della gestione dei post e chiama l'azione di visualizzazione class Post Controller: Post PostController extends Zend_Controller_Action Model: Post Action: List listAction()‫‏‬ I dati elaborati dal modello vengono inviati alla vista per la creazione dell'html finale Viene istanziato un oggetto del modello che si occupa di estrarre i View: List list.pthml post dal db. I risultati vengono L'html viene creato e visualizzato restituiti dal modello al controller all'utente | | 31 mar Zend Framework dalla A alla Zend 1 2008 1
  • 12. Il formato della richiesta •  Nell'esempio precedente l'utente richiedeva la lista dei post. •  La richiesta per essere interpretata dal front controller di Zend Framework deve essere composta in questo modo: http:// server / controller / action http:// localhost / post / list | | 31 mar Zend Framework dalla A alla Zend 1 2008 2
  • 13. THANK YOU “ Zend Framework Simplicity, Meet Power massimiliano@zend.com