SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
A quick start on
Zend Framework 2
by Enrico Zimuel (enrico@zend.com)

Senior Software Engineer
Zend Framework Core Team
Zend Technologies Ltd




                                     © All rights reserved. Zend Technologies, Inc.
About me

                        • Enrico Zimuel (@ezimuel)
                        • Software Engineer since 1996
                               – Assembly x86, C/C++, Java, Perl, PHP
                        • PHP Engineer at Zend Technologies in
  @ezimuel                           the Zend Framework Team
  enrico@zend.com       • International speaker on PHP and
                                     computer security topics
  www.zimuel.it
                        • Researcher programmer at
                                     Informatics Institute of University
                                     of Amsterdam
                        • Co-founder of the PUG Torino (Italy)


                    © All rights reserved. Zend Technologies, Inc.
ZF2 in a slide

●   New architecture
      ▶   MVC, Di, Events, Service, Module
●   Better performance
●   Requirement: PHP 5.3.3
●   No more CLA (Contributor License Agreement)
●   Git (GitHub) instead of SVN
●   Packaging system
      ▶   pyrus, composer


                    © All rights reserved. Zend Technologies, Inc.
A new core

●   The ZF1 way:
       ▶   Singleton, Registry, and
             Hard-Coded
             Dependencies
●   The ZF2 approach:
       ▶   Aspect Oriented Design
             and Dependency
             Injection




                      © All rights reserved. Zend Technologies, Inc.
MVC is event driven


●   Everything is an event



       bootstrap                  route                             dispatch




       Listeners


                   © All rights reserved. Zend Technologies, Inc.
Releases

●   ZF2.0.0beta4
●   Goal:
     ▶   beta5 at the end of June
     ▶   ZF 2.0 RC this summer!!!




                      © All rights reserved. Zend Technologies, Inc.
Quick start
Zend Skeleton Application




        © All rights reserved. Zend Technologies, Inc.
Zend Skeleton Application

●   A simple, skeleton application using the new MVC
    layer and the module system
●   How to install:
    $   cd my/project/dir
    $   git clone git://github.com/zendframework/ZendSkeletonApplication.git
    $   cd ZendSkeletonApplication
    $   php composer.phar install




                              © All rights reserved. Zend Technologies, Inc.
Output




         © All rights reserved. Zend Technologies, Inc.
Folder's tree

  config
  data
  module
  public
  vendor




                © All rights reserved. Zend Technologies, Inc.
Config folder

  config
         autoload
     application.config.php
  data
  module
  public
  vendor



                    © All rights reserved. Zend Technologies, Inc.
Data folder

  config
  data
         cache
  module
  public
  vendor




                 © All rights reserved. Zend Technologies, Inc.
Module folder
 module
     Application                          Name of the module
             config
                 module.config.php
             src
                    Application
                          Controller
                               IndexController.php
             view
                    application
                          index
                                 index.phtml
                    error
                    layout
          Module.php

                   © All rights reserved. Zend Technologies, Inc.
Public folder

  public
       images
       js
       css
     .htaccess
     index.php




                 © All rights reserved. Zend Technologies, Inc.
Vendor folder

  config
  data
  module
  public
  vendor
         zendframework




                 © All rights reserved. Zend Technologies, Inc.
configuration



    © All rights reserved. Zend Technologies, Inc.
/config/application.config.php




             © All rights reserved. Zend Technologies, Inc.
public folder



    © All rights reserved. Zend Technologies, Inc.
public/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]




                 © All rights reserved. Zend Technologies, Inc.
public/index.php




            © All rights reserved. Zend Technologies, Inc.
ZendServiceManager

 ●   The ServiceManager is a Service Locator
     implementation
 ●   A Service Locator is a well-known object in
     which you may register objects (more in
     general services) and later retrieve them
 ●   Driven by configuration




                    © All rights reserved. Zend Technologies, Inc.
Types of Services

 ●   Explicit (name => object pairs)
 ●   Invokables (name => class to instantiate)
 ●   Factories (name => callable returning object)
 ●   Aliases (name => some other name)
 ●   Abstract Factories (unknown services)
 ●   Scoped Containers (limit what can be created)
 ●   Shared (or not; you decide)



                   © All rights reserved. Zend Technologies, Inc.
module



 © All rights reserved. Zend Technologies, Inc.
Modules by default



 A module is all related code and assets
     that solve a specific problem.
Modules inform the MVC about services
          and event listeners




              © All rights reserved. Zend Technologies, Inc.
Modules for ZF2

●   The basic unit in a ZF2 application
    is a Module
●   Modules are “Plug and play” technology
●   Modules are simple:
       ▶   A namespace
       ▶   Containing a single classfile: Module.php




                      © All rights reserved. Zend Technologies, Inc.
Develop Modules

●   Modules contain all logic related to a
    discrete application problem.
       ▶   Controllers
       ▶   Entities
       ▶   Plugins
       ▶   Etc.
●   99% of the time, you will write modules


                      © All rights reserved. Zend Technologies, Inc.
moduleApplicationModule.php




            © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php
(routing part)




                © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php
(controller part)




                © All rights reserved. Zend Technologies, Inc.
/module/Application/config/module.config.php
(view)




                © All rights reserved. Zend Technologies, Inc.
/module/Application/src/Application/
    Controller/IndexController.php




                Passing array() of variables to the view


                 © All rights reserved. Zend Technologies, Inc.
Packaging system




     © All rights reserved. Zend Technologies, Inc.
Pyrus

●   http://packages.zendframework.com/
●   Download or use pyrus, a PEAR2 installer
●   Pyrus packages:
     ▶   Pyrus setup
     ▶   wget http://packages.zendframework.com/pyrus.phar
     ▶   pyrus.phar .
     ▶   pyrus.phar . channel­discover packages.zendframework.com

     ▶   Install a Zend_<component>
     ▶   pyrus.phar . install zf2/Zend_<component>




                        © All rights reserved. Zend Technologies, Inc.
Composer

●   New package management and distribution
    tool
●   http://packagist.org/
●   http://getcomposer.org/




                   © All rights reserved. Zend Technologies, Inc.
composer.json




          © All rights reserved. Zend Technologies, Inc.
From ZF1 to ZF2




     © All rights reserved. Zend Technologies, Inc.
From ZF1 to ZF2

●   Goal: migrate without rewriting much code!
●   Main steps
       ▶   Namespace: Zend_Foo => ZendFoo
       ▶   Autoloading: 3 options
       ▶   MVC: module, event based, dispatchable
       ▶   DB: new ZendDb
       ▶   Form: new ZendForm
●   Can run in parallel (instant migration!)


                     © All rights reserved. Zend Technologies, Inc.
Conclusion:
ZF2 rocks!



   © All rights reserved. Zend Technologies, Inc.
Why ZF2 rocks!

●   Based on solid architecture principles
●   Very fast (focused on optimization)
●   Open architecture (event driven)
●   Support of modules (reuse of the code)
●   Driven by the community
    (100% open source)
●   Completed tested (PHPUnit, Travis CI)
●   Packages (pyrus, composer)



                      © All rights reserved. Zend Technologies, Inc.
We want you!

●   How to contribute:
    ▶   Write code
    ▶   Documentation
    ▶   Testing
    ▶   Feedbacks/comments




         https://github.com/zendframework/zf2

                     © All rights reserved. Zend Technologies, Inc.
Helping out

●   http://framework.zend.com/zf2
●   http://github.com/zendframework
●   https://github.com/zendframework/ZendSkeletonApplication
●   Getting Started with Zend Framework 2
    by Rob Allen, http://www.akrabat.com
●   Weekly IRC meetings (#zf2-meeting on
    Freenode)
●   #zftalk.2 on Freenode IRC



                       © All rights reserved. Zend Technologies, Inc.
Thank you!

 ●   Comment this talk at:
       ▶   https://joind.in/6237
 ●   Direct contact:
       ▶   enrico@zend.com
       ▶   @ezimuel




                      © All rights reserved. Zend Technologies, Inc.

Mais conteúdo relacionado

Mais procurados

Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentation
yamcsha
 
20120722 word press
20120722 word press20120722 word press
20120722 word press
Seungmin Sun
 
A Zend Architecture presentation
A Zend Architecture presentationA Zend Architecture presentation
A Zend Architecture presentation
techweb08
 
How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11
Stephan Hochdörfer
 

Mais procurados (20)

Cryptography with Zend Framework
Cryptography with Zend FrameworkCryptography with Zend Framework
Cryptography with Zend Framework
 
ZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of itZF2 Modular Architecture - Taking advantage of it
ZF2 Modular Architecture - Taking advantage of it
 
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
ZFConf 2012: Zend Framework 2, a quick start (Enrico Zimuel)
 
Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)
Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)
Manage cloud infrastructures in PHP using Zend Framework 2 (and 1)
 
Zend Framework 2 Patterns
Zend Framework 2 PatternsZend Framework 2 Patterns
Zend Framework 2 Patterns
 
ZF2 Presentation @PHP Tour 2011 in Lille
ZF2 Presentation @PHP Tour 2011 in LilleZF2 Presentation @PHP Tour 2011 in Lille
ZF2 Presentation @PHP Tour 2011 in Lille
 
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
ZFConf 2012: Dependency Management в PHP и Zend Framework 2 (Кирилл Чебунин)
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
 
Introduction to Zend Framework
Introduction to Zend FrameworkIntroduction to Zend Framework
Introduction to Zend Framework
 
Instant ACLs with Zend Framework 2
Instant ACLs with Zend Framework 2Instant ACLs with Zend Framework 2
Instant ACLs with Zend Framework 2
 
Zend Framework 2 - presentation
Zend Framework 2 - presentationZend Framework 2 - presentation
Zend Framework 2 - presentation
 
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
 
When dynamic becomes static
When dynamic becomes staticWhen dynamic becomes static
When dynamic becomes static
 
20120722 word press
20120722 word press20120722 word press
20120722 word press
 
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
Ростислав Михайлив "Zend Framework 3 - evolution or revolution"
 
2007 Zend Con Mvc Edited Irmantas
2007 Zend Con Mvc Edited Irmantas2007 Zend Con Mvc Edited Irmantas
2007 Zend Con Mvc Edited Irmantas
 
A Zend Architecture presentation
A Zend Architecture presentationA Zend Architecture presentation
A Zend Architecture presentation
 
How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11How to build customizable multitenant web applications - PHPBNL11
How to build customizable multitenant web applications - PHPBNL11
 
Authentication with zend framework
Authentication with zend frameworkAuthentication with zend framework
Authentication with zend framework
 
Zend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterZend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiter
 

Semelhante a Quick start on Zend Framework 2

Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applications
Etisbew Technology Group
 

Semelhante a Quick start on Zend Framework 2 (20)

How to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend FrameworkHow to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend Framework
 
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applications
 
Zend
ZendZend
Zend
 
green
greengreen
green
 
High performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructureHigh performance PHP: Scaling and getting the most out of your infrastructure
High performance PHP: Scaling and getting the most out of your infrastructure
 
Better Bug Stomping with Zend Studio and Zend Server
Better Bug Stomping with Zend Studio and Zend ServerBetter Bug Stomping with Zend Studio and Zend Server
Better Bug Stomping with Zend Studio and Zend Server
 
Zend Framework 1.8 workshop
Zend Framework 1.8 workshopZend Framework 1.8 workshop
Zend Framework 1.8 workshop
 
PHP QA Tools
PHP QA ToolsPHP QA Tools
PHP QA Tools
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Zend framework 01 - introduction
Zend framework 01 - introductionZend framework 01 - introduction
Zend framework 01 - introduction
 
Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1Debugging PHP with xDebug inside of Eclipse PDT 2.1
Debugging PHP with xDebug inside of Eclipse PDT 2.1
 
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInDataModel serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
Model serving made easy using Kedro pipelines - Mariusz Strzelecki, GetInData
 
Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applications
 
Cryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use CasesCryptography in PHP: Some Use Cases
Cryptography in PHP: Some Use Cases
 
Multiconf - Python Configuration API
Multiconf - Python Configuration APIMulticonf - Python Configuration API
Multiconf - Python Configuration API
 
Dev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the CloudDev & Prod - PHP Applications in the Cloud
Dev & Prod - PHP Applications in the Cloud
 
PhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 PluginPhpStorm: Symfony2 Plugin
PhpStorm: Symfony2 Plugin
 
Turbocharging php applications with zend server
Turbocharging php applications with zend serverTurbocharging php applications with zend server
Turbocharging php applications with zend server
 

Mais de Enrico Zimuel

Mais de Enrico Zimuel (20)

Password (in)security
Password (in)securityPassword (in)security
Password (in)security
 
Integrare Zend Framework in Wordpress
Integrare Zend Framework in WordpressIntegrare Zend Framework in Wordpress
Integrare Zend Framework in Wordpress
 
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecnicheIntroduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
Introduzione alla Posta Elettronica Certificata (PEC): le regole tecniche
 
PHP goes mobile
PHP goes mobilePHP goes mobile
PHP goes mobile
 
Zend Framework 2
Zend Framework 2Zend Framework 2
Zend Framework 2
 
Cryptography in PHP: use cases
Cryptography in PHP: use casesCryptography in PHP: use cases
Cryptography in PHP: use cases
 
Framework software e Zend Framework
Framework software e Zend FrameworkFramework software e Zend Framework
Framework software e Zend Framework
 
Strong cryptography in PHP
Strong cryptography in PHPStrong cryptography in PHP
Strong cryptography in PHP
 
Velocizzare Joomla! con Zend Server Community Edition
Velocizzare Joomla! con Zend Server Community EditionVelocizzare Joomla! con Zend Server Community Edition
Velocizzare Joomla! con Zend Server Community Edition
 
Zend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applicationsZend_Cache: how to improve the performance of PHP applications
Zend_Cache: how to improve the performance of PHP applications
 
XCheck a benchmark checker for XML query processors
XCheck a benchmark checker for XML query processorsXCheck a benchmark checker for XML query processors
XCheck a benchmark checker for XML query processors
 
Introduzione alle tabelle hash
Introduzione alle tabelle hashIntroduzione alle tabelle hash
Introduzione alle tabelle hash
 
Crittografia quantistica: fantascienza o realtà?
Crittografia quantistica: fantascienza o realtà?Crittografia quantistica: fantascienza o realtà?
Crittografia quantistica: fantascienza o realtà?
 
Introduzione alla crittografia
Introduzione alla crittografiaIntroduzione alla crittografia
Introduzione alla crittografia
 
Crittografia è sinonimo di sicurezza?
Crittografia è sinonimo di sicurezza?Crittografia è sinonimo di sicurezza?
Crittografia è sinonimo di sicurezza?
 
Sviluppo di applicazioni sicure
Sviluppo di applicazioni sicureSviluppo di applicazioni sicure
Sviluppo di applicazioni sicure
 
Misure minime di sicurezza informatica
Misure minime di sicurezza informaticaMisure minime di sicurezza informatica
Misure minime di sicurezza informatica
 
PHP e crittografia
PHP e crittografiaPHP e crittografia
PHP e crittografia
 
La sicurezza delle applicazioni in PHP
La sicurezza delle applicazioni in PHPLa sicurezza delle applicazioni in PHP
La sicurezza delle applicazioni in PHP
 
Firma digitale
Firma digitaleFirma digitale
Firma digitale
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Quick start on Zend Framework 2

  • 1. A quick start on Zend Framework 2 by Enrico Zimuel (enrico@zend.com) Senior Software Engineer Zend Framework Core Team Zend Technologies Ltd © All rights reserved. Zend Technologies, Inc.
  • 2. About me • Enrico Zimuel (@ezimuel) • Software Engineer since 1996 – Assembly x86, C/C++, Java, Perl, PHP • PHP Engineer at Zend Technologies in @ezimuel the Zend Framework Team enrico@zend.com • International speaker on PHP and computer security topics www.zimuel.it • Researcher programmer at Informatics Institute of University of Amsterdam • Co-founder of the PUG Torino (Italy) © All rights reserved. Zend Technologies, Inc.
  • 3. ZF2 in a slide ● New architecture ▶ MVC, Di, Events, Service, Module ● Better performance ● Requirement: PHP 5.3.3 ● No more CLA (Contributor License Agreement) ● Git (GitHub) instead of SVN ● Packaging system ▶ pyrus, composer © All rights reserved. Zend Technologies, Inc.
  • 4. A new core ● The ZF1 way: ▶ Singleton, Registry, and Hard-Coded Dependencies ● The ZF2 approach: ▶ Aspect Oriented Design and Dependency Injection © All rights reserved. Zend Technologies, Inc.
  • 5. MVC is event driven ● Everything is an event bootstrap route dispatch Listeners © All rights reserved. Zend Technologies, Inc.
  • 6. Releases ● ZF2.0.0beta4 ● Goal: ▶ beta5 at the end of June ▶ ZF 2.0 RC this summer!!! © All rights reserved. Zend Technologies, Inc.
  • 7. Quick start Zend Skeleton Application © All rights reserved. Zend Technologies, Inc.
  • 8. Zend Skeleton Application ● A simple, skeleton application using the new MVC layer and the module system ● How to install: $ cd my/project/dir $ git clone git://github.com/zendframework/ZendSkeletonApplication.git $ cd ZendSkeletonApplication $ php composer.phar install © All rights reserved. Zend Technologies, Inc.
  • 9. Output © All rights reserved. Zend Technologies, Inc.
  • 10. Folder's tree config data module public vendor © All rights reserved. Zend Technologies, Inc.
  • 11. Config folder config autoload application.config.php data module public vendor © All rights reserved. Zend Technologies, Inc.
  • 12. Data folder config data cache module public vendor © All rights reserved. Zend Technologies, Inc.
  • 13. Module folder module Application Name of the module config module.config.php src Application Controller IndexController.php view application index index.phtml error layout Module.php © All rights reserved. Zend Technologies, Inc.
  • 14. Public folder public images js css .htaccess index.php © All rights reserved. Zend Technologies, Inc.
  • 15. Vendor folder config data module public vendor zendframework © All rights reserved. Zend Technologies, Inc.
  • 16. configuration © All rights reserved. Zend Technologies, Inc.
  • 17. /config/application.config.php © All rights reserved. Zend Technologies, Inc.
  • 18. public folder © All rights reserved. Zend Technologies, Inc.
  • 19. public/.htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] © All rights reserved. Zend Technologies, Inc.
  • 20. public/index.php © All rights reserved. Zend Technologies, Inc.
  • 21. ZendServiceManager ● The ServiceManager is a Service Locator implementation ● A Service Locator is a well-known object in which you may register objects (more in general services) and later retrieve them ● Driven by configuration © All rights reserved. Zend Technologies, Inc.
  • 22. Types of Services ● Explicit (name => object pairs) ● Invokables (name => class to instantiate) ● Factories (name => callable returning object) ● Aliases (name => some other name) ● Abstract Factories (unknown services) ● Scoped Containers (limit what can be created) ● Shared (or not; you decide) © All rights reserved. Zend Technologies, Inc.
  • 23. module © All rights reserved. Zend Technologies, Inc.
  • 24. Modules by default A module is all related code and assets that solve a specific problem. Modules inform the MVC about services and event listeners © All rights reserved. Zend Technologies, Inc.
  • 25. Modules for ZF2 ● The basic unit in a ZF2 application is a Module ● Modules are “Plug and play” technology ● Modules are simple: ▶ A namespace ▶ Containing a single classfile: Module.php © All rights reserved. Zend Technologies, Inc.
  • 26. Develop Modules ● Modules contain all logic related to a discrete application problem. ▶ Controllers ▶ Entities ▶ Plugins ▶ Etc. ● 99% of the time, you will write modules © All rights reserved. Zend Technologies, Inc.
  • 27. moduleApplicationModule.php © All rights reserved. Zend Technologies, Inc.
  • 28. /module/Application/config/module.config.php (routing part) © All rights reserved. Zend Technologies, Inc.
  • 29. /module/Application/config/module.config.php (controller part) © All rights reserved. Zend Technologies, Inc.
  • 30. /module/Application/config/module.config.php (view) © All rights reserved. Zend Technologies, Inc.
  • 31. /module/Application/src/Application/ Controller/IndexController.php Passing array() of variables to the view © All rights reserved. Zend Technologies, Inc.
  • 32. Packaging system © All rights reserved. Zend Technologies, Inc.
  • 33. Pyrus ● http://packages.zendframework.com/ ● Download or use pyrus, a PEAR2 installer ● Pyrus packages: ▶ Pyrus setup ▶ wget http://packages.zendframework.com/pyrus.phar ▶ pyrus.phar . ▶ pyrus.phar . channel­discover packages.zendframework.com ▶ Install a Zend_<component> ▶ pyrus.phar . install zf2/Zend_<component> © All rights reserved. Zend Technologies, Inc.
  • 34. Composer ● New package management and distribution tool ● http://packagist.org/ ● http://getcomposer.org/ © All rights reserved. Zend Technologies, Inc.
  • 35. composer.json © All rights reserved. Zend Technologies, Inc.
  • 36. From ZF1 to ZF2 © All rights reserved. Zend Technologies, Inc.
  • 37. From ZF1 to ZF2 ● Goal: migrate without rewriting much code! ● Main steps ▶ Namespace: Zend_Foo => ZendFoo ▶ Autoloading: 3 options ▶ MVC: module, event based, dispatchable ▶ DB: new ZendDb ▶ Form: new ZendForm ● Can run in parallel (instant migration!) © All rights reserved. Zend Technologies, Inc.
  • 38. Conclusion: ZF2 rocks! © All rights reserved. Zend Technologies, Inc.
  • 39. Why ZF2 rocks! ● Based on solid architecture principles ● Very fast (focused on optimization) ● Open architecture (event driven) ● Support of modules (reuse of the code) ● Driven by the community (100% open source) ● Completed tested (PHPUnit, Travis CI) ● Packages (pyrus, composer) © All rights reserved. Zend Technologies, Inc.
  • 40. We want you! ● How to contribute: ▶ Write code ▶ Documentation ▶ Testing ▶ Feedbacks/comments https://github.com/zendframework/zf2 © All rights reserved. Zend Technologies, Inc.
  • 41. Helping out ● http://framework.zend.com/zf2 ● http://github.com/zendframework ● https://github.com/zendframework/ZendSkeletonApplication ● Getting Started with Zend Framework 2 by Rob Allen, http://www.akrabat.com ● Weekly IRC meetings (#zf2-meeting on Freenode) ● #zftalk.2 on Freenode IRC © All rights reserved. Zend Technologies, Inc.
  • 42. Thank you! ● Comment this talk at: ▶ https://joind.in/6237 ● Direct contact: ▶ enrico@zend.com ▶ @ezimuel © All rights reserved. Zend Technologies, Inc.