PHP Framework, part 2nd: Building a sample application

Source: Internet
Author: User
Tags php framework reserved zend zend framework
The
PHP Framework series will introduce three widely used PHP frameworks--zend, Symfony, and cakephp--to study the similarities and differences of three frameworks by building and extending sample applications in three frameworks. Part 1th will list the content covered in this series and configure the prerequisites. In the 2nd part, you will build the sample application in three frames, respectively.
--> --> -->

In the 1th part of this series, we have set the scope of this series and met the prerequisites. The sample application will now be built in three frames, respectively. In the next few articles, you will expand your application, understand exceptions that do not conform to the usual, use Ajax, integrate external tasks, and so on.

This article will guide you through the creation of sample application BLAHG in three frames, respectively. You'll start from scratch to learn the basics of developing simple applications in the Zend framework, Symfony, and cake.

You should have completed part 1th, which describes how to install the three frameworks and the prerequisites that must be met by using the three frameworks. If you have not read this section, you should read it now.

Suppose you already know about PHP, application design, and how to work in a database. You don't need to have experience with the framework, but you should be ready to start using the framework.

Building BLAHG in the Zend framework

First, create the directory/column/htdocs/zend and/column/protected/zend. These directories will save both the Web-accessible files and the application files that the Web cannot access. In/column/htdocs/zend, the following command line is used to create a. htaccess file:

Rewriteengine Onrewriterule! (JS|ICO|GIF|JPG|PNG|CSS) $ index.php

Each framework has its own specific requirements when it comes to the directory structure. For the Zend framework, you need to create directories/column/protected/zend/controllers,/column/protected/zend/models, and/column/protected/zend/views To save the controller, model, and view. In addition, you need to create a directory/column/protected/zend/views/scripts, and for each controller, you need to create a directory to hold some views. For example, you know that BLAHG will need to provide some views for the post controller, then you need to create a directory/column/protected/zend/views/scripts/post to save the view.

The catalog is ready. It's time to build the model.

Building Zend posts tables and models

In part 1th, you create the posts table that will be used. If you skipped that piece of content, view it now and create the table. The model for this table is very simple. It should be named posts.php, and it should be created in/column/protected/zend/models/. Posts.php extends the Zend_Db_Table class, and most of the methods that you will use inherit from the class.

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.