Getting Started with Zend Framework MVC Applications

This tutorial is intended to give an introduction to using Zend Framework 2 by creating a simple database driven application using the Model-View-Controller paradigm. By the end you will have a working ZF2 application and you can then poke around the code to find out more about how it all works and fits together.

Some assumptions

This tutorial assumes that you are running at least PHP 5.6 with the Apache web server and MySQL, accessible via the PDO extension. Your Apache installation must have the mod_rewrite extension installed and configured.

You must also ensure that Apache is configured to support .htaccess files. This is usually done by changing the setting:

AllowOverride None

to

AllowOverride FileInfo

in your httpd.conf file. Check with your distribution’s documentation for exact details. You will not be able to navigate to any page other than the home page in this tutorial if you have not configured mod_rewrite and .htaccess usage correctly.

Getting started faster

Alternatively, you can use any of the following as well:

  • The built-in web server in PHP. Runphp -S 0.0.0.0:8080 -t public/ public/index.php in your application root to start a web server listening on port 8080.
  • Use the shipped Vagrantfile, by executing vagrant up from the 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 executingdocker-compose up -d --build from the application root. This binds the host machine's port 8080 to the Apache server instance running container.

The tutorial application

The application that we are going to build is a simple inventory system to display which albums we own. The main page will list our collection and allow us to add, edit and delete CDs. We are going to need four pages in our website:

Page Description
List of albums This will display the list of albums and provide links to edit and delete them. Also, a link to enable adding new albums will be provided.
Add new album This page will provide a form for adding a new album.
Edit album This page will provide a form for editing an album.
Delete album This page will confirm that we want to delete an album and then delete it.

We will also need to store our data into a database. We will 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的更多相关文章

  1. Zend Framework MVC的结构

    The Zend Framework MVC Architecture 一.概述: In this chapter, we will cover the following topics:1. Zen ...

  2. Zend Framework 留言本实战(转)

    一.环境搭建和ZF安装              *[注]本节内容大部分来至Zend Framework官方手册       1.1 Zend Framework下载 Zend Framework 使 ...

  3. Zend Framework 框架搭建

    通过手工方法搭建Zend Framework的MVC框架结构.首先看一下zend framework mvc的目录结构 1. 在根目录下面创建 public ,并在 public 下创建 index. ...

  4. 【原创】Zend Framework 2框架之MVC

    ZendFramework 2框架之MVC 作者:sys(360电商技术组) 1.前言 Zend Framework 2是zend官方推出的php开源框架,基于php5.3.他全然採用面向对象的代码实 ...

  5. Zend Framework 入门(4)—页面布局

    Zend Framework 的页面布局模块——Zend_Layout——既可以跟 MVC 一起使用,也可以单独使用.本文只讨论与 MVC 一起使用的情况. 1. 布局脚本 在 application ...

  6. Zend Framework

    参考:http://www.php100.com/manual/ZendFramework/index.html 1.1. 概述 Zend Framework (ZF) 是一个开放源代码的 PHP5 ...

  7. Zend Framework学习日记(2)--HelloWorld篇(转)

    Zend Framework学习日记(2)--HelloWorld篇 这一篇主要演示如何用zf命令行工具建立一个基于Zend Framework框架的工程,也是我初学Zend Framework的小练 ...

  8. zend framework 1 安装教程

    网上的安装教程总是一笔带过,本人结合已经爬过的坑,为大家展示最简单的安装方式: 博主环境如下: 操作系统:win7 64bit 开发环境:lnmp(phpstudy) 注意: zftest:官方下载的 ...

  9. Zend Framework 3.0 安装及创建初始化项目教程

    前言: 最近开始接触关于PHP的框架的学习,然而PHP的框架少说也有七八种. 百度了一下,有人说ThinkPHP简单暴力的,有人说Laravel高大上的,等等等等,难以抉择. 最终我还是选择先从接触Z ...

随机推荐

  1. Linux性能监控之Memory篇

    首先说说虚拟内存和物理内存: 虚拟内存就是采用硬盘来对物理内存进行扩展,将暂时不用的内存页写到硬盘上而腾出更多的物理内存让有需要的进程来用.当这些内存页需要用的时候在从硬盘读回内存.这一切对于用户来说 ...

  2. PHP中的替代语法

    今天看了一下wordpress的代码,里面有些少见的php替代语法, <?php else : ?> <div class="entry-content"> ...

  3. HDU-3864 D_num Miller_Rabin和Pollard_rho

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3864 题意:给定一个数n,求n的因子只有四个的情况. Miller_Rabin和Pollard_rho ...

  4. hive常见问题解决干货大全

    本人,苦心多时,历经磨难和心血,与大家共同攻克问题难关! 问题一: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive ...

  5. jxse2.6连接外网rdv一直连接不上,而相同的代码用jxse2.7却能连上

    一直以为2.6中的bug会少一些,所以用2.6做开发:之前测试一直是在同一台 机器上,所以没啥问题:最近在外网设置了一个rdv,却一直连不上,困扰了n久,尝试各种方式都不起作用.最后想起以前开发的代码 ...

  6. CodeForces 455C Civilization (并查集+树的直径)

    Civilization 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/B Description Andrew plays a ...

  7. [iOS微博项目 - 1.8] - 各种尺寸图片加载 & 控件不显示研究

    A. 图片的加载:  [UIImage imageNamed:@"home"];  加载png图片    一.非retina屏幕  1.3.5 inch(320 x 480)  * ...

  8. 159. Longest Substring with At Most Two Distinct Characters

    最后更新 二刷 08-Jan-17 回头看了下一刷的,用的map,应该是int[256]的意思,后面没仔细看cuz whatever I was doing at that time.. wasnt ...

  9. CSS构造超链接

    超链接边框 派生超链接 属性选择器超链接 动态超链接 图像翻转超链接 CSS工具提示 1.给链接加上边框     A:link {         Color: #f00;         Text- ...

  10. python中objects的all和get方法的区别

    all返回的是QuerySet: get返回的是模型对象. 想要获取查询结果的字段值: 从QuerySet中获取对象可以通过for in的形式遍历,之后通过对象获取对象的具体值: get 返回的是对象 ...