• Like
zend framework 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

zend framework 2

  • 1,547 views
Published

zend pdf document

zend pdf document

Published in Self Improvement
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,547
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
38
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Zend Framework 2 Documentation Release 2.3.1dev Zend Technologies Ltd. March 22, 2014
  • 2. Contents 1 Overview 1 2 Installation 3 3 Getting Started with Zend Framework 2 5 3.1 Some assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.2 The tutorial application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4 Getting started: A skeleton application 7 4.1 Using the Apache Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.2 Using the Built-in PHP CLI Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.3 Error reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5 Routing and controllers 11 6 Create the controller 13 6.1 Initialise the view scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 7 Database and models 15 7.1 The database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7.2 The model files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 7.3 Using ServiceManager to configure the table gateway and inject into the AlbumTable . . . . . . . . . 17 7.4 Back to the controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 7.5 Listing albums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 8 Styling and Translations 21 9 Forms and actions 23 9.1 Adding new albums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 9.2 Editing an album . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 9.3 Deleting an album . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 9.4 Ensuring that the home page displays the list of albums . . . . . . . . . . . . . . . . . . . . . . . . . 31 10 Conclusion 33 11 Getting Started with Zend Framework 2 35 11.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 11.2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 i
  • 3. 12 A quick tour of the skeleton application 37 12.1 The dispatch cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 13 The MyTaskList application 39 13.1 The Checklist module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 13.2 The Module class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 14 The application’s pages 43 14.1 Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 14.2 The TaskController . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 14.3 The model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 14.4 Using Service Manager to configure the database credentials and inject into the controller . . . . . . 48 15 Listing tasks 51 15.1 Redirect the home page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 16 Styling 53 17 Adding new tasks 55 18 Editing a task 61 19 Deleting a task 65 20 Application Diagnostics 67 21 Step-by-step debugging 69 22 Conclusion 71 23 Zend Framework Tool (ZFTool) 73 23.1 Installation using Composer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 23.2 Manual installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 23.3 Without installation, using the PHAR file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 23.4 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 24 Learning Dependency Injection 77 24.1 Very brief introduction to Di. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 24.2 Simplest usage case (2 classes, one consumes the other) . . . . . . . . . . . . . . . . . . . . . . . . 77 24.3 Simplest Usage Case Without Type-hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 24.4 Simplest usage case with Compiled Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 24.5 Creating a precompiled definition for others to use . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 24.6 Using Multiple Definitions From Multiple Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 24.7 Generating Service Locators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 25 Unit Testing a Zend Framework 2 application 87 25.1 Setting up the tests directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 25.2 Bootstrapping your tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 25.3 Your first controller test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 25.4 A failing test case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 25.5 Configuring the service manager for the tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 25.6 Testing actions with POST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 25.7 Testing model entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 25.8 Testing model tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 25.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 ii
  • 4.