Getting Started with Zend Framework MVC applications
This tutorial was intended to give an introduction to using Zend Framework 2 by creating a simple database driven Applicati On using the Model-view-controller paradigm. By the end you'll have a working ZF2 application and you can then poke around the code to find out more about what it all Works and fits together.
Some Assumptions
This tutorial assumes is running at least PHP 5.6 with the Apache Web server and MySQL, accessible via the PDO E XTension. Your Apache installation must has the mod_rewrite
extension installed and configured.
You must also ensure this Apache is configured to the support .htaccess
files. This is usually do by changing the setting:
AllowOverride None
To
AllowOverride FileInfo
In your httpd.conf
file. Check with your distribution ' s documentation for exact details. You are not being able to navigate-to-page other than the home page in this tutorial if you had not configured an mod_rewrite
D .htaccess
usage correctly.
Getting started faster
Alternatively, you can use any of the following as well:
- The built-in Web server in PHP. Run in
php -S 0.0.0.0:8080 -t public/ public/index.php
your application root-to-start a Web server listening on port 8080.
- Use the shipped
Vagrantfile
, by executing from the vagrant up
application root. This binds the host machine's port 8080 to the Apache server instance running on the Vagrant image.
- Use the shipped Docker-compose integration, by executing from the
docker-compose up -d --build
application root. This binds the host machine's port 8080 to the Apache server instance running container.
The tutorial Application
The application that we were going to build was a simple inventory system to display which albums we own. The main page would list our collection and allow us to add, edit and delete CDs. We is going to need four pages in our website:
Page |
Description |
List of albums |
This would display the list of albums and provide links to edit and delete them. Also, a link to enable adding new albums would be provided. |
ADD new Album |
This page would provide a form for adding a new album. |
Edit Album |
This page would provide a form for editing an album. |
Delete Album |
This page would confirm that we want to delete a album and then delete it. |
We'll also need to store We have data into a database. We'll only need one table with these fields in it:
Field name |
Type |
Null? |
Notes |
Id |
Integer |
No |
Primary Key, Auto-increment |
Artist |
varchar (100) |
No |
|
Title |
varchar (100) |
No |
|
Getting Started with Zend Framework MVC applications