Using Zend Framework 2 (The Book + Code Samples)
Using Zend Framework 2
The book about Zend Framework 2 that is easy to read and understand for beginners
About the Book
The "Using Zend Framework 2" is a book about programming websites with Zend Framework 2. With this e-Book, you can save your time and efforts learning ZF2.
The author strives to give material starting with simple things that a beginner should understand. Advanced things go last in a chapter. This makes this book the first Zend Framework book that is easy to read and understand for a newbie.
This ZF2 book's text is illustrated with code samples (the source code is published on GitHub). Each sample is a complete web-site you can install and run yourself to see Zend Framework 2 in action. You can even use the samples as a base for your own web sites.
Packages
The Book + Code Samples
This package includes the book plus code samples. Each sample is a complete web-site you can install and run yourself to see Zend Framework 2 in action. You can even use the samples as a base for your own web sites.
PDF
EPUB
WEB
English
The Book
PDF
EPUB
WEB
English
Table of Contents
-
Preface
- Why to Read this Book?
- Zend Framework Explained
- See ZF2 Wider
- ZF2 Book for Beginners
- Structure of the Book
- Learn ZF2 by Example
- Book Reviews
- Testimonials
- Your Feedback
- Acknowledgements
-
1. Introduction to Zend Framework 2
- 1.1 What is Zend Framework 2?
- 1.2 License
- 1.3 What Companies Prefer Zend Framework 2?
- 1.4 Distributions
- 1.5 User Support
- 1.6 Supported Operating Systems
- 1.7 Server Requirements
- 1.8 Security
- 1.9 Performance
- 1.10 Design Patterns
- 1.11 Components
- 1.12 ZF2 Service Components
-
1.13 Differences with Zend Framework 1
- 1.13.1 Backwards Compatibility
- 1.13.2 ZFTool
- 1.13.3 Modules
- 1.13.4 Aspect Oriented Design
- 1.13.5 Namespaces
- 1.13.6 Configuration
- 1.13.7 Service Manager
- 1.14 Competing Frameworks
- 1.15 Summary
-
2. Zend Skeleton Application
- 2.1 Getting Zend Skeleton Application
- 2.2 Typical Directory Structure
- 2.3 Installing Dependencies with Composer
- 2.4 Apache Virtual Host
- 2.5 Opening the Web Site in Your Browser
- 2.6 Creating NetBeans Project
- 2.7 Hypertext Access File (.htaccess)
- 2.8 Blocking Access to the Web Site by IP Address
- 2.9 HTTP Authentication
- 2.10 Having Multiple Virtual Hosts
- 2.11 Hosts File
-
2.12 Advanced Composer Usage
- 2.12.1 Package Names and Versions
- 2.12.2 Installing and Updating Packages
- 2.12.3 Virtual Packages
- 2.12.4 Composer and Version Control Systems
- 2.13 Summary
-
3. Web Site Operation
- 3.1 PHP Namespaces
- 3.2 PHP Interfaces
- 3.3 PHP Class Autoloading
- 3.4 PSR-0 Standard
- 3.5 HTTP Request and Response
- 3.6 Site Entry Script
- 3.7 Events & Application’s Life Cycle
-
3.8 Application Configuration
- 3.8.1 Application-Level Config Files
- 3.8.2 Application-Level Extra Config Files
- 3.8.3 Module-Level Config Files
- 3.8.4 Combining the Configuration Files
- 3.9 Module Entry Point
-
3.10 Class Autoloading in Zend Framework 2
- 3.10.1 Composer-provided Autoloader
-
3.10.2
Zend\Loader
Component- 3.10.2.1 Standard Autoloader
- 3.10.2.2 PSR-0 and Src Directory Structure
- 3.10.2.3 Class Map Autoloader
-
3.11 Service Manager
- 3.11.1 Service Locator
- 3.11.2 Canonical Service Names
- 3.11.3 Registering a Service
- 3.11.4 Registering Invokable Classes
- 3.11.5 Registering Factories
- 3.11.6 Registering Service Aliases
- 3.11.7 Service Manager Configuration
- 3.12 Summary
-
4. Model-View-Controller
- 4.1 Get the Hello World Example from GitHub
- 4.2 Separating Business Logic from Presentation
-
4.3 Controllers
- 4.3.1 Base Controller Class
- 4.3.2 Retrieving Data from HTTP Request
- 4.3.3 Retrieving GET or POST Variables
- 4.3.4 Putting Data to HTTP Response
- 4.4 Variable Containers
- 4.5 Controller Registration
- 4.6 When to Create a New Controller?
-
4.7 Controller Plugins
- 4.7.1 Writing Own Controller Plugin
- 4.8 Views
- 4.9 View Helpers
- 4.10 View Template Names & View Resolver
- 4.11 Disabling the View Rendering
- 4.12 Error Pages
- 4.13 Models
-
4.14 Model Types
- 4.14.1 Entities
- 4.14.2 Value Objects
- 4.14.3 Services
- 4.14.4 Factories
- 4.14.5 Repositories
- 4.15 Determining the Correct Model Type
-
4.16 Skinny Controllers, Fat Models, Simple Views
- 4.16.1 Skinny Controllers
- 4.16.2 Fat Models
- 4.16.3 Simple View Templates
- 4.17 Summary
-
5. URL Routing
- 5.1 URL Structure
- 5.2 Route Types
-
5.3 Combining Route Types
- 5.3.1 Simple Route Stack
- 5.3.2 Tree Route Stack
-
5.4 Routing Configuration
- 5.4.1 Configuration for Simple Routes
- 5.4.2 Configuration for Nested Routes
- 5.4.3 Default Routing Configuration in Zend Skeleton Application
- 5.5 Literal Route Type
- 5.6 Segment Route Type
- 5.7 Regex Route Type
- 5.8 Wildcard Route Type
- 5.9 Other Route Types
-
5.10 Extracting Parameters from Route
- 5.10.1 Retrieving the RouteMatch and the Router Object
-
5.11 Generating URLs from Route
-
5.11.1 Generating URLs in View Templates
- 5.11.1.1 Passing Parameters
- 5.11.1.2 Generating Absolute URLs
- 5.11.1.3 Specifying Query Part
- 5.11.2 Generating URLs in Controllers
- 5.11.3 URL Encoding
-
5.11.1 Generating URLs in View Templates
-
5.12 Writing Own Route Type
- 5.12.1 RouteInterface
- 5.12.2 Custom Route Class
- 5.13 Summary
-
6. Page Appearance and Layout
- 6.1 About CSS Stylesheets and Twitter Bootstrap
- 6.2 Page Layout in Zend Framework 2
- 6.3 Modifying the Default Page Layout
-
6.4 Switching between Layouts
- 6.4.1 Setting Layout for All Actions of a Controller
- 6.5 Partial Views
- 6.6 Placeholder View Helper
-
6.7 Adding Scripts to a Web Page
- 6.7.1 Example
-
6.8 Adding CSS Stylesheets to a Web Page
- 6.8.1 Example
-
6.9 Writing Own View Helpers
- 6.9.1 Menu
- 6.9.2 Breadcrumbs
- 6.10 View Models and Page Composition
- 6.11 Summary
-
7. Collecting User Input with Forms
- 7.1 Get the Form Demo Sample from GitHub
-
7.2 About HTML Forms
- 7.2.1 Fieldsets
- 7.2.2 Example: “Contact Us” Form
- 7.2.3 GET and POST Methods
- 7.3 Styling HTML Forms with Twitter Bootstrap
- 7.4 Retrieving Form Data in a Controller’s Action
-
7.5 Forms and Model-View-Controller
- 7.5.1 A Typical Form Usage Workflow
- 7.6 A Form Model
-
7.7 Form Elements
- 7.7.1 Adding Elements to a Form Model
- 7.7.2 Method 1: Passing an Instance of an Element
- 7.7.3 Method 2: Using Array Specification
- 7.8 Example: Creating the Contact Form Model
-
7.9 Adding Form Validation Rules
- 7.9.1 Input Filter
-
7.9.2 Adding Inputs to Input Filter
- 7.9.2.1 Filter Configuration
- 7.9.2.2 Validator Configuration
- 7.9.2.3 Attaching Input Filter to Form Model
- 7.9.3 Creating Input Filter for the Contact Form
-
7.10 Using the Form in a Controller’s Action
- 7.10.1 Passing Form Data to a Model
-
7.11 Form Presentation
- 7.11.1 Preparing the Form Model for Rendering
-
7.12 Standard Form View Helpers
- 7.12.1 Rendering a Form Element
- 7.12.2 Rendering an Element’s Validation Errors
- 7.12.3 Rendering an Element’s Label
- 7.12.4 Rendering a Form Row
- 7.12.5 Rendering the Entire Form
-
7.13 Example: Creating the View Template for the Contact Form
- 7.13.1 Applying the Bootstrap CSS Styles to Form
- 7.13.2 Styling the Validation Errors List
- 7.13.3 Adding the “Thank You” & “Error Sending Email” Pages
- 7.13.4 Results
- 7.14 Summary
-
8. Transforming Input Data with Filters
-
8.1 About Filters
- 8.1.1 FilterInterface
- 8.2 Standard Filters Overview
-
8.3 Instantiating a Filter
- 8.3.1 Method 1: Instantiating a Filter Manually
- 8.3.2 Method 2: Constructing a Filter with StaticFilter
- 8.3.3 Method 3: Constructing a Filter From Array
- 8.4 About Filter Plugin Manager
- 8.5 Filter’s Behavior in Case of Incorrect Input Data
-
8.6 Filter Usage Examples
-
8.6.1 Filters Casting Input Data to a Specified Type
- 8.6.1.1 Int Filter
- 8.6.1.2 Boolean Filter
- 8.6.1.3 Null Filter
- 8.6.1.4 DateTimeFormatter Filter
-
8.6.2 Filters Performing Manipulations on a File Path
- 8.6.2.1 BaseName Filter
- 8.6.2.2 Dir Filter
- 8.6.2.3 RealPath Filter
-
8.6.3 Filters Performing Compression and Encryption of Input Data
- 8.6.3.1 Compress Filter
- 8.6.3.2 Encrypt Filter
-
8.6.4 Filters Manipulating String Data
- 8.6.4.1 StringToLower Filter
- 8.6.4.2 PregReplace Filter
- 8.6.4.3 StripTags Filter
- 8.6.4.4 StripNewlines Filter
- 8.6.4.5 UriNormalize Filter
- 8.6.5 Organizing Filters in a Chain
-
8.6.6 Custom Filtering with the Callback Filter
- 8.6.6.1 Example
-
8.6.1 Filters Casting Input Data to a Specified Type
-
8.7 Writing Your Own Filter
- 8.7.1 Using the PhoneFilter Class
- 8.8 Summary
-
8.1 About Filters
-
9. Checking Input Data with Validators
-
9.1 About Validators
- 9.1.1 ValidatorInterface
- 9.2 Standard Validators Overview
- 9.3 Validator Behaviour in Case of Invalid or Unacceptable Data
-
9.4 Instantiating a Validator
- 9.4.1 Method 1. Manual Instantiation of a Validator
- 9.4.2 Method 2. Using StaticValidator Wrapper
- 9.4.3 Method 3. Using an Array Configuration
- 9.5 About Validator Plugin Manager
-
9.6 Validator Usage Examples
-
9.6.1 Validators for Checking Value Conformance to Certain Format
- 9.6.1.1 Ip Validator
- 9.6.1.2 Hostname Validator
- 9.6.1.3 Uri Validator
- 9.6.1.4 Date Validator
- 9.6.1.5 Regex Validator
-
9.6.2 Validators for Checking a Numerical Value Lies in a Given Range
- 9.6.2.1 NotEmpty Validator
- 9.6.2.2 Between Validator
- 9.6.2.3 InArray Validator
- 9.6.2.4 StringLength Validator
- 9.6.3 Organizing Validators in a Chain
-
9.6.4 Custom Validation with the Callback Validator
- 9.6.4.1 Example
-
9.6.1 Validators for Checking Value Conformance to Certain Format
-
9.7 Writing Own Validator
- 9.7.1 Using the PhoneValidator Class
- 9.8 Using Filters & Validators Outside a Form
- 9.9 Summary
-
9.1 About Validators
-
10. Uploading Files with Forms
-
10.1 About HTTP File Uploads
- 10.1.1 HTTP Binary Transfer Encoding
- 10.1.2 $_FILES Super-Global Array in PHP
- 10.2 Accessing Uploaded Files in ZF2
- 10.3 File Uploads & ZF2 Form Model
- 10.4 Validating Uploaded Files
- 10.5 Filtering Uploaded Files
-
10.6 InputFilter Container & File Uploads
- 10.6.1 FileInput
- 10.6.2 Executing Validators before Filters
- 10.7 Controller Action & File Uploads
-
10.8 Example: Image Gallery
- 10.8.1 Adding ImageForm Model
- 10.8.2 Adding Validation Rules to ImageForm Model
- 10.8.3 Writing ImageManager Service
-
10.8.4 Adding ImageController
- 10.8.4.1 Adding Upload Action & Corresponding View Template
- 10.8.4.2 Adding Index Action & Corresponding View Template
- 10.8.4.3 Adding File Action
- 10.8.4.4 Registering the ImageController
- 10.8.5 Results
- 10.9 Summary
-
10.1 About HTTP File Uploads
-
11. Advanced Usage of Forms
-
11.1 Form Security Elements
-
11.1.1 CAPTCHA
- 11.1.1.1 CAPTCHA Types
- 11.1.1.2 CAPTCHA Form Element & View Helper
- 11.1.2 Example 1: Adding Image CAPTCHA to the ContactForm
- 11.1.3 Example 2: Adding a FIGlet CAPTCHA to the ContactForm
- 11.1.4 Example 3: Adding reCaptcha CAPTCHA to the ContactForm
-
11.1.5 CSRF Prevention
- 11.1.5.1 Example: Adding a CSRF Element to Form
-
11.1.1 CAPTCHA
- 11.2 Summary
-
11.1 Form Security Elements
-
12. Database Management with Doctrine ORM
- 12.1 Get Blog Example from GitHub
-
12.2 Creating a Simple MySQL Database
- 12.2.1 Creating New Schema
- 12.2.2 Creating Tables
- 12.2.3 Importing Ready Database Schema
-
12.3 Integrating Doctrine ORM with Zend Framework 2
- 12.3.1 Installing Doctrine Components with Composer
- 12.3.2 Loading Doctrine Integration Modules on Application Start Up
- 12.3.3 Doctrine Configuration Overview
- 12.3.4 Overriding the Default Doctrine Configuration
- 12.4 Specifying Database Connection Parameters
-
12.5 About Doctrine Entities
- 12.5.1 Annotations
-
12.6 Creating Entities
- 12.6.1 Adding Post Entity
- 12.6.2 Adding the Comment and Tag Entities
-
12.6.3 Specifying Relations between Entities
- 12.6.3.1 OneToMany/ManyToOne
- 12.6.3.2 ManyToMany
- 12.6.4 Specifying Entity Locations
-
12.7 About Entity Manager
- 12.7.1 Entity Repositories
- 12.8 Adding Blog Home Page
-
12.9 Adding New Post
- 12.9.1 Adding PostForm
- 12.9.2 Adding PostManager Service
- 12.9.3 Creating Controller Action and View Template
-
12.10 Editing Existing Post
- 12.10.1 Modifying PostManager
- 12.10.2 Adding Controller Action and View Template
-
12.11 Deleting Post
- 12.11.1 Modifying PostManager
- 12.11.2 Adding Controller Action
-
12.12 Implementing Post Preview
- 12.12.1 Adding CommentForm
- 12.12.2 Modifying PostManager
- 12.12.3 Adding Controller Action and View Template
- 12.13 Implementing Admin Page
-
12.14 Implementing Tag Cloud
- 12.14.1 Adding Custom Post Repository
- 12.14.2 Calculating Tag Cloud
- 12.14.3 Modifying Controller Action
- 12.14.4 Rendering Tag Cloud
- 12.15 Summary
-
Appendix A. Configuring Web Development Environment
-
Installing Apache, PHP and MySQL in Linux
- Installing Apache and PHP
- Checking Web Server Installation
- Editing PHP Configuration
- Restarting Apache Web Server
- Enabling Apache’s mod_rewrite module
- Creating Apache Virtual Host
- Installing XDebug PHP extension
- Installing APC PHP Extension
- Installing MySQL Database Server
- Configuring the MySQL Database Server
-
Installing Apache, PHP and MySQL in Windows
- Checking Web Server Installation
- Enabling Apache’s mod_rewrite module
- Creating Apache Virtual Host
- Installing XDebug PHP extension
- Installing MySQL Database Server
- Configuring the MySQL Database Server
-
Installing NetBeans IDE in Linux
- Method 1. Installing from Repository
- Method 2. Downloading from Web Site
- Installing NetBeans IDE in Windows
- Summary
-
Installing Apache, PHP and MySQL in Linux
-
Appendix B. Introduction to PHP Development in NetBeans IDE
- Run Configuration
- Running the Web Site
- Site Debugging in NetBeans
- Debug Toolbar
- Breakpoints
- Watching Variables
- Call Stack
- Debugging Options
- Profiling
- Summary
-
Appendix C. Introduction to Twitter Bootstrap
- Overview of Bootstrap Files
-
Grid System
- Defining the Grid
- Offsetting Columns
- Nesting Grids
- “Mobile First” Concept
-
Bootstrap’s Interface Components
-
Navigation Bar
- Dropdown Menu
- Collapsible Navbar
- Inverse Navbar Style
- Breadcrumbs
- Pagination
- Buttons & Glyphicons
-
Navigation Bar
- Customizing Bootstrap
- Summary
-
Appendix D. Introduction to Doctrine
-
Doctrine and Database Management Systems
-
Relational Databases
- SQL vs. DQL
-
NoSQL Databases
- Document Databases
-
Relational Databases
-
Doctrine Architecture
- Components Supporting Relational Databases
- Components Supporting NoSQL Document Databases
- Summary
-
Doctrine and Database Management Systems
- About the Author
Causes Supported
Electronic Frontier Foundation
Defending your civil liberties in a digital world.
https://www.eff.org/Based in San Francisco, EFF is a donor-supported membership organization working to protect fundamental rights regardless of technology.
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them