SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Foundations of Zend Framework
By:
Adam Culp
Twitter: @adamculp
Foundations of Zend Framework
 About me
 PHP 5.3 Certified
 Consultant at Zend Technologies
 Organizer SoFloPHP (South Florida)
 Organizer SunshinePHP (Miami)
 Long Distance (ultra) Runner
 Judo Black Belt Instructor
Foundations of Zend Framework
 What is...
 90,529,980 installs
(Packagist Dec 5th
, 2016)
 Uses PHP >= 5.6 or 7.0
 Open Source
 On GitHub
 Composer Installation
 Built on MVC design pattern
 Can be used as components or entire framework
(61 packages)
Foundations of Zend Framework
 Skeleton Application
 Git clone Zendframework Skeleton Application
 Github /zendframework/ZendSkeletonApplication
Foundations of Zend Framework
 Composer
 Install Zend Framework
 Collection of 61 packages
 Composer install
 Creates and/or populates '/vendor' directory
 Sets up Composer autoloader (PSR-4)
 composer create-project zendframework/skeleton-
application
 composer require zendframework/zendframework
Foundations of Zend Framework
 Structure
Foundations of Zend Framework
 Zend Framework Usage
 NO MAGIC!!!
 Configuration driven
 No forced structure
 Uses namespaces
Foundations of Zend Framework
 MVC
 Very briefly
Foundations of Zend Framework
 Typical Application Flow - Load
 index.php
 Loads autoloader (PSR-4 = default)
 init Application using application.config.php
Foundations of Zend Framework
 Typical Application Flow – App Config
 application.config.php
 Loads modules one at a time
 (Module.php = convention)
 Specifies where to find modules
 Loads configs in autoload directory (DB settings,
etc.)
Foundations of Zend Framework
 Typical Application Flow – Modules
 Module.php (convention)
 Makes MvcEvent accessible via onBootstrap()
 Giving further access to Application, Event Manager,
and Service Manager.
 Loads module.config.php
 Specifies autoloader and location of files.
 May define services and wire event listeners as
needed.
Foundations of Zend Framework
 Typical Application Flow – Module Config
 module.config.php
 Containers are component specific
 Routes
 Navigation
 Service Manager
 Translator
 Controllers
 View Manager
 Steer clear of Closures (Anonymous Functions)
 Do not cache well within array.
 Less performant (parsed and compiled on every req)
as a factory only parsed when service is used.
Foundations of Zend Framework
 Routes
Foundations of Zend Framework
 Routes
 Carries how controller maps to request
 Types:
 Hostname – 'me.adamculp.com'
 Literal - '/home'
 Method – 'post,put'
 Part – creates a tree of possible routes
 Regex – use regex to match url '/blog/?<id>[0-9]?'
 Scheme – 'https'
 Segment - '/:controller[/:action][/]'
 Query – specify and capture query string params
Foundations of Zend Framework
 Route Example
/module/Application/config/module.config.php
Foundations of Zend Framework
 Event Manager
Foundations of Zend Framework
 Event Manager
 Many Event Managers
 Each is isolated
 Events are actions
 Many custom we create
 Defaults (following slide)
Foundations of Zend Framework
 Diagram of MVC Events
Foundations of Zend Framework
 Event Manager Example
/module/Application/Module.php
Foundations of Zend Framework
 Shared Event Manager
 There is only one!
 Similar to Event Manager
 Obtain from Event Manager
 Allows other lower level
Event Managers to
communicate with each
other.
 Globally available
 Why?
 May want to attach to objects not yet created, such
as attaching to all controllers.
Foundations of Zend Framework
 Shared Event Manager Example
/module/Application/Module.php
Foundations of Zend Framework
 Event Manager Characteristics
 An Object
 Attach Triggers to Events
 Listeners are callbacks when Trigger satisfied
 Function or Anon Function (action)
 Queues by priority (last parameter in call)
 Patterns
 Pub/Sub
 Class that triggers the event is publisher
 Listener is subscribing to the event
 Observer - (Subject/Observer)
 Listener is the observer
 Class Triggering the event is the subject
Foundations of Zend Framework
 Services
 ALL THE THINGS!
Foundations of Zend Framework
 Service Manager
 Recommended alternative to ZendDi
 Di pure DIC, SM is factory-based container
 Everything is a service, even Controllers
 Can be created from:
 Application configuration
 Module classes
 Useful if anon functions desired
 Module configuration (most common)
 No anon functions due to caching issues
 Local override configuration
 For times when vendor keys need over-written
 Specified in application config
Foundations of Zend Framework
 Defining Services
 Beware key name overwritting
 Use fully qualified class name when applicable
 MyAppControllerProductIndex
 Or be descriptive
 {module}-{name}
 'product-category' instead of 'category'
 All keys get normalized
 AppControllerProductIndex == app-controller-
product-index
 Hierarchy of definitions
 Module.php – initial
 module.config.php over-rides Module.php
 Local over-rides module.config.php
Foundations of Zend Framework
 Service Types
 Types:
 Services – Explicit
 key => value pairs (string, boolean, float, object)
 Invokables
 key => class (class/object with no needed
dependencies)
 Factories
 key => object (class/object with needed dependencies)
 Aliases (name => some other name)
 Abstract Factories (unknown services)
 Scoped Containers (limit what can be created)
 Shared (or not; you decide)
Foundations of Zend Framework
 Service Config Example
/module/Application/config/module.config.php
Foundations of Zend Framework
 Service Module Example
/module/Application/config/module.php
Foundations of Zend Framework
 Using Service Example
/module/Application/Module.php
/module/Application/view/layout/layout.phtml
Foundations of Zend Framework
 Using Service In Factory Example
/module/Application/Factory/CategoryControllerFactory.php
Foundations of Zend Framework
 Module Manager
Foundations of Zend Framework
 Module Manager
 Gets directives from application.config.php
 Modules to load
 Order is important if module depends on another
 Where to find modules (convention found in)
 Modules directory
 Vendor directory
 Loads each module
 Module.php
 For dynamic content/settings
 module.config.php (if getConfig() in Module.php)
 Over-rides Module.php
 Then hand off to MvcEvent process to Bootstrap.
Foundations of Zend Framework
 Module Basics
 Relative to a specific “problem”.
 Logical separation of application functionality
 Reusable
 Removing a module doesn't kill the application
 Contains everything specific to given module
 Keep init() and onBootstrap() in modules light.
 Do not add data to module structure.
Foundations of Zend Framework
 Module Contents
 Contents
 PHP Code
 MVC Functionality
 Library Code
 Though better in Application or via Composer
 May not be related to MVC
 View scripts
 Public assets (images, css, javascript)
 More?
Foundations of Zend Framework
 Module Skeleton
 Easy creation using Zend Skeleton Module
 GitHub /zendframework/ZendSkeletonModule
Foundations of Zend Framework
 Other Things Worth Investigating
 Views
 Forms
 Databases
 Navigation
 View Strategies (Action or Restful)
Sorry, just not enough time in a regular talk.
Foundations of Zend Framework
 Resources
 http://framework.zend.com
 http://www.zend.com/en/services/training/course-catal
og/zend-framework-2
 http://www.zend.com/en/services/training/course-cata
log/zend-framework-2-advanced
 http://zendframework2.de/cheat-sheet.html
 https://docs.zendframework.com/tutorials/migration/to-v
3/overview/
 https://olegkrivtsov.github.io/using-zend-framework-3-bo
ok/html/index.html
Foundations of Zend Framework
 Thank You!
 Code: https://github.com/adamculp/foundations-zf2-talk
Adam Culp
http://www.geekyboy.com
http://RunGeekRadio.com
Twitter @adamculp

Weitere ähnliche Inhalte

Was ist angesagt?

Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginnersAdam Englander
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad WoodOrtus Solutions, Corp
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEGavin Pickin
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Tim Bunce
 
Zend con what-i-learned-about-mobile-first
Zend con what-i-learned-about-mobile-firstZend con what-i-learned-about-mobile-first
Zend con what-i-learned-about-mobile-firstClark Everetts
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration StoryAnton Serdyuk
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsAdam Culp
 
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014Chen-en Lu
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...Fwdays
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring applicationJimmy Lu
 
Virtual Bolt Workshop, 5 May 2020
Virtual Bolt Workshop, 5 May 2020Virtual Bolt Workshop, 5 May 2020
Virtual Bolt Workshop, 5 May 2020Puppet
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Anton Babenko
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHPMarcos Quesada
 
Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 OSSCube
 
Robotframework
RobotframeworkRobotframework
RobotframeworkElla Sun
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION APIGavin Pickin
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016Gavin Pickin
 

Was ist angesagt? (20)

Zend con 2016 bdd with behat for beginners
Zend con 2016   bdd with behat for beginnersZend con 2016   bdd with behat for beginners
Zend con 2016 bdd with behat for beginners
 
cf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Woodcf.Objective() 2017 - Design patterns - Brad Wood
cf.Objective() 2017 - Design patterns - Brad Wood
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008Perl6 DBDI YAPC::EU 201008
Perl6 DBDI YAPC::EU 201008
 
Zend con what-i-learned-about-mobile-first
Zend con what-i-learned-about-mobile-firstZend con what-i-learned-about-mobile-first
Zend con what-i-learned-about-mobile-first
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration Story
 
Zend Framework 2 - PHPUnit
Zend Framework 2 - PHPUnitZend Framework 2 - PHPUnit
Zend Framework 2 - PHPUnit
 
Practical PHP Deployment with Jenkins
Practical PHP Deployment with JenkinsPractical PHP Deployment with Jenkins
Practical PHP Deployment with Jenkins
 
Automate Thyself
Automate ThyselfAutomate Thyself
Automate Thyself
 
Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014Gradle起步走: 以CLI Application為例 @ JCConf 2014
Gradle起步走: 以CLI Application為例 @ JCConf 2014
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
 
Virtual Bolt Workshop, 5 May 2020
Virtual Bolt Workshop, 5 May 2020Virtual Bolt Workshop, 5 May 2020
Virtual Bolt Workshop, 5 May 2020
 
Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)Build & deploy PHP application (intro level)
Build & deploy PHP application (intro level)
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014 Apigility – Lightning Fast API Development - OSSCamp 2014
Apigility – Lightning Fast API Development - OSSCamp 2014
 
Robotframework
RobotframeworkRobotframework
Robotframework
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
 

Andere mochten auch

Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Adam Culp
 
Does Your Code Measure Up?
Does Your Code Measure Up?Does Your Code Measure Up?
Does Your Code Measure Up?Adam Culp
 
Build great products
Build great productsBuild great products
Build great productsAdam Culp
 
Accidental professional
Accidental professionalAccidental professional
Accidental professionalAdam Culp
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101Adam Culp
 

Andere mochten auch (6)

Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2Deprecated: Foundations of Zend Framework 2
Deprecated: Foundations of Zend Framework 2
 
Does Your Code Measure Up?
Does Your Code Measure Up?Does Your Code Measure Up?
Does Your Code Measure Up?
 
Build great products
Build great productsBuild great products
Build great products
 
Accidental professional
Accidental professionalAccidental professional
Accidental professional
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Refactoring 101
Refactoring 101Refactoring 101
Refactoring 101
 

Ähnlich wie Foundations of Zend Framework

Introduction to Zend Framework 2
Introduction to Zend Framework 2Introduction to Zend Framework 2
Introduction to Zend Framework 2John Coggeshall
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughBradley Holt
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityJohn Coggeshall
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tourSeedStack
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend FrameworkJuan Antonio
 
Using Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonUsing Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonJeremy Brown
 
Unit Test for ZF SlideShare Component
Unit Test for ZF SlideShare ComponentUnit Test for ZF SlideShare Component
Unit Test for ZF SlideShare Componentzftalk
 

Ähnlich wie Foundations of Zend Framework (20)

Introduction to Zend Framework 2
Introduction to Zend Framework 2Introduction to Zend Framework 2
Introduction to Zend Framework 2
 
Zend framework 01 - introduction
Zend framework 01 - introductionZend framework 01 - introduction
Zend framework 01 - introduction
 
2007 Zend Con Mvc
2007 Zend Con Mvc2007 Zend Con Mvc
2007 Zend Con Mvc
 
Zf2 phpquebec
Zf2 phpquebecZf2 phpquebec
Zf2 phpquebec
 
Zend Framework Quick Start Walkthrough
Zend Framework Quick Start WalkthroughZend Framework Quick Start Walkthrough
Zend Framework Quick Start Walkthrough
 
ZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularityZF2 Modules: Events, Services, and of course, modularity
ZF2 Modules: Events, Services, and of course, modularity
 
TomatoCMS in A Nutshell
TomatoCMS in A NutshellTomatoCMS in A Nutshell
TomatoCMS in A Nutshell
 
SeedStack feature tour
SeedStack feature tourSeedStack feature tour
SeedStack feature tour
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Using Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's SkeletonUsing Zend_Tool to Establish Your Project's Skeleton
Using Zend_Tool to Establish Your Project's Skeleton
 
Zf2
Zf2Zf2
Zf2
 
Demo
DemoDemo
Demo
 
first pitch
first pitchfirst pitch
first pitch
 
werwr
werwrwerwr
werwr
 
sdfsdf
sdfsdfsdfsdf
sdfsdf
 
college
collegecollege
college
 
first pitch
first pitchfirst pitch
first pitch
 
Greenathan
GreenathanGreenathan
Greenathan
 
Unit Test for ZF SlideShare Component
Unit Test for ZF SlideShare ComponentUnit Test for ZF SlideShare Component
Unit Test for ZF SlideShare Component
 
first pitch
first pitchfirst pitch
first pitch
 

Mehr von Adam Culp

Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middlewareAdam Culp
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpowerAdam Culp
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical DebtAdam Culp
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications FasterAdam Culp
 
Containing Quality
Containing QualityContaining Quality
Containing QualityAdam Culp
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpantsAdam Culp
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorialAdam Culp
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAdam Culp
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized DevelopmentAdam Culp
 
Clean application development (talk)
Clean application development (talk)Clean application development (talk)
Clean application development (talk)Adam Culp
 
Using an API
Using an APIUsing an API
Using an APIAdam Culp
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in developmentAdam Culp
 
Refactoring PHP
Refactoring PHPRefactoring PHP
Refactoring PHPAdam Culp
 
Selenium testing IDE 101
Selenium testing IDE 101Selenium testing IDE 101
Selenium testing IDE 101Adam Culp
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Adam Culp
 
Development Environment Tips
Development Environment TipsDevelopment Environment Tips
Development Environment TipsAdam Culp
 
Getting your project_started
Getting your project_startedGetting your project_started
Getting your project_startedAdam Culp
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLibAdam Culp
 

Mehr von Adam Culp (20)

Hypermedia
HypermediaHypermedia
Hypermedia
 
Putting legacy to REST with middleware
Putting legacy to REST with middlewarePutting legacy to REST with middleware
Putting legacy to REST with middleware
 
php-1701-a
php-1701-aphp-1701-a
php-1701-a
 
Release your refactoring superpower
Release your refactoring superpowerRelease your refactoring superpower
Release your refactoring superpower
 
Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical Debt
 
Developing PHP Applications Faster
Developing PHP Applications FasterDeveloping PHP Applications Faster
Developing PHP Applications Faster
 
Containing Quality
Containing QualityContaining Quality
Containing Quality
 
Debugging elephpants
Debugging elephpantsDebugging elephpants
Debugging elephpants
 
Clean application development tutorial
Clean application development tutorialClean application development tutorial
Clean application development tutorial
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
Vagrant for Virtualized Development
Vagrant for Virtualized DevelopmentVagrant for Virtualized Development
Vagrant for Virtualized Development
 
Clean application development (talk)
Clean application development (talk)Clean application development (talk)
Clean application development (talk)
 
Using an API
Using an APIUsing an API
Using an API
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
Refactoring PHP
Refactoring PHPRefactoring PHP
Refactoring PHP
 
Selenium testing IDE 101
Selenium testing IDE 101Selenium testing IDE 101
Selenium testing IDE 101
 
Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3Intro to OOP and new features in PHP 5.3
Intro to OOP and new features in PHP 5.3
 
Development Environment Tips
Development Environment TipsDevelopment Environment Tips
Development Environment Tips
 
Getting your project_started
Getting your project_startedGetting your project_started
Getting your project_started
 
PHP and PDFLib
PHP and PDFLibPHP and PDFLib
PHP and PDFLib
 

Kürzlich hochgeladen

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Kürzlich hochgeladen (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Foundations of Zend Framework

  • 1. Foundations of Zend Framework By: Adam Culp Twitter: @adamculp
  • 2. Foundations of Zend Framework  About me  PHP 5.3 Certified  Consultant at Zend Technologies  Organizer SoFloPHP (South Florida)  Organizer SunshinePHP (Miami)  Long Distance (ultra) Runner  Judo Black Belt Instructor
  • 3. Foundations of Zend Framework  What is...  90,529,980 installs (Packagist Dec 5th , 2016)  Uses PHP >= 5.6 or 7.0  Open Source  On GitHub  Composer Installation  Built on MVC design pattern  Can be used as components or entire framework (61 packages)
  • 4. Foundations of Zend Framework  Skeleton Application  Git clone Zendframework Skeleton Application  Github /zendframework/ZendSkeletonApplication
  • 5. Foundations of Zend Framework  Composer  Install Zend Framework  Collection of 61 packages  Composer install  Creates and/or populates '/vendor' directory  Sets up Composer autoloader (PSR-4)  composer create-project zendframework/skeleton- application  composer require zendframework/zendframework
  • 6. Foundations of Zend Framework  Structure
  • 7. Foundations of Zend Framework  Zend Framework Usage  NO MAGIC!!!  Configuration driven  No forced structure  Uses namespaces
  • 8. Foundations of Zend Framework  MVC  Very briefly
  • 9. Foundations of Zend Framework  Typical Application Flow - Load  index.php  Loads autoloader (PSR-4 = default)  init Application using application.config.php
  • 10. Foundations of Zend Framework  Typical Application Flow – App Config  application.config.php  Loads modules one at a time  (Module.php = convention)  Specifies where to find modules  Loads configs in autoload directory (DB settings, etc.)
  • 11. Foundations of Zend Framework  Typical Application Flow – Modules  Module.php (convention)  Makes MvcEvent accessible via onBootstrap()  Giving further access to Application, Event Manager, and Service Manager.  Loads module.config.php  Specifies autoloader and location of files.  May define services and wire event listeners as needed.
  • 12. Foundations of Zend Framework  Typical Application Flow – Module Config  module.config.php  Containers are component specific  Routes  Navigation  Service Manager  Translator  Controllers  View Manager  Steer clear of Closures (Anonymous Functions)  Do not cache well within array.  Less performant (parsed and compiled on every req) as a factory only parsed when service is used.
  • 13. Foundations of Zend Framework  Routes
  • 14. Foundations of Zend Framework  Routes  Carries how controller maps to request  Types:  Hostname – 'me.adamculp.com'  Literal - '/home'  Method – 'post,put'  Part – creates a tree of possible routes  Regex – use regex to match url '/blog/?<id>[0-9]?'  Scheme – 'https'  Segment - '/:controller[/:action][/]'  Query – specify and capture query string params
  • 15. Foundations of Zend Framework  Route Example /module/Application/config/module.config.php
  • 16. Foundations of Zend Framework  Event Manager
  • 17. Foundations of Zend Framework  Event Manager  Many Event Managers  Each is isolated  Events are actions  Many custom we create  Defaults (following slide)
  • 18. Foundations of Zend Framework  Diagram of MVC Events
  • 19. Foundations of Zend Framework  Event Manager Example /module/Application/Module.php
  • 20. Foundations of Zend Framework  Shared Event Manager  There is only one!  Similar to Event Manager  Obtain from Event Manager  Allows other lower level Event Managers to communicate with each other.  Globally available  Why?  May want to attach to objects not yet created, such as attaching to all controllers.
  • 21. Foundations of Zend Framework  Shared Event Manager Example /module/Application/Module.php
  • 22. Foundations of Zend Framework  Event Manager Characteristics  An Object  Attach Triggers to Events  Listeners are callbacks when Trigger satisfied  Function or Anon Function (action)  Queues by priority (last parameter in call)  Patterns  Pub/Sub  Class that triggers the event is publisher  Listener is subscribing to the event  Observer - (Subject/Observer)  Listener is the observer  Class Triggering the event is the subject
  • 23. Foundations of Zend Framework  Services  ALL THE THINGS!
  • 24. Foundations of Zend Framework  Service Manager  Recommended alternative to ZendDi  Di pure DIC, SM is factory-based container  Everything is a service, even Controllers  Can be created from:  Application configuration  Module classes  Useful if anon functions desired  Module configuration (most common)  No anon functions due to caching issues  Local override configuration  For times when vendor keys need over-written  Specified in application config
  • 25. Foundations of Zend Framework  Defining Services  Beware key name overwritting  Use fully qualified class name when applicable  MyAppControllerProductIndex  Or be descriptive  {module}-{name}  'product-category' instead of 'category'  All keys get normalized  AppControllerProductIndex == app-controller- product-index  Hierarchy of definitions  Module.php – initial  module.config.php over-rides Module.php  Local over-rides module.config.php
  • 26. Foundations of Zend Framework  Service Types  Types:  Services – Explicit  key => value pairs (string, boolean, float, object)  Invokables  key => class (class/object with no needed dependencies)  Factories  key => object (class/object with needed dependencies)  Aliases (name => some other name)  Abstract Factories (unknown services)  Scoped Containers (limit what can be created)  Shared (or not; you decide)
  • 27. Foundations of Zend Framework  Service Config Example /module/Application/config/module.config.php
  • 28. Foundations of Zend Framework  Service Module Example /module/Application/config/module.php
  • 29. Foundations of Zend Framework  Using Service Example /module/Application/Module.php /module/Application/view/layout/layout.phtml
  • 30. Foundations of Zend Framework  Using Service In Factory Example /module/Application/Factory/CategoryControllerFactory.php
  • 31. Foundations of Zend Framework  Module Manager
  • 32. Foundations of Zend Framework  Module Manager  Gets directives from application.config.php  Modules to load  Order is important if module depends on another  Where to find modules (convention found in)  Modules directory  Vendor directory  Loads each module  Module.php  For dynamic content/settings  module.config.php (if getConfig() in Module.php)  Over-rides Module.php  Then hand off to MvcEvent process to Bootstrap.
  • 33. Foundations of Zend Framework  Module Basics  Relative to a specific “problem”.  Logical separation of application functionality  Reusable  Removing a module doesn't kill the application  Contains everything specific to given module  Keep init() and onBootstrap() in modules light.  Do not add data to module structure.
  • 34. Foundations of Zend Framework  Module Contents  Contents  PHP Code  MVC Functionality  Library Code  Though better in Application or via Composer  May not be related to MVC  View scripts  Public assets (images, css, javascript)  More?
  • 35. Foundations of Zend Framework  Module Skeleton  Easy creation using Zend Skeleton Module  GitHub /zendframework/ZendSkeletonModule
  • 36. Foundations of Zend Framework  Other Things Worth Investigating  Views  Forms  Databases  Navigation  View Strategies (Action or Restful) Sorry, just not enough time in a regular talk.
  • 37. Foundations of Zend Framework  Resources  http://framework.zend.com  http://www.zend.com/en/services/training/course-catal og/zend-framework-2  http://www.zend.com/en/services/training/course-cata log/zend-framework-2-advanced  http://zendframework2.de/cheat-sheet.html  https://docs.zendframework.com/tutorials/migration/to-v 3/overview/  https://olegkrivtsov.github.io/using-zend-framework-3-bo ok/html/index.html
  • 38. Foundations of Zend Framework  Thank You!  Code: https://github.com/adamculp/foundations-zf2-talk Adam Culp http://www.geekyboy.com http://RunGeekRadio.com Twitter @adamculp