Windframework Lightweight PHP Open source framework

Source: Internet
Author: User
Tags implement php class access root directory

Windframework is a lightweight PHP open source framework. It takes a component factory as its core and provides applications such as MVC, data persistence, view template engines, and more. In addition, Windframework has adopted a modular development model. Although the current component library is not very rich and robust, it is based on this development pattern that makes the extension of the component very easy. Windframework has a robust kernel that implements a configuration based IOC control reversal technology. Is that developers need only simple configuration, you can implement class dependency injection, fully implement the class and the loose coupling of classes. Of course its beauty is not only here.

Open Source project Address: Https://github.com/phpwind/windframework

The classic Hello World application example, with a very familiar application to open a new framework of learning applications! This application example will always print ' Hello world ' in the browser window. To complete this application we will learn:

1. How to obtain the Windframework framework source code

2. Windframework Framework Environmental Requirements

3. Windframework base directory structure and default run rules

4. You will also create your own first action controller

Of course this application is very simple, we should be able to quickly complete the application and see the ' Hello World ' output. I think this should be a quick way to close the gap between us, but it's not enough to make a strong application.

First: Download Framework source code

* If you already have a frame code on hand, you can skip this step

Windframework is published and shared on the GitHub. Access Https://github.com/phpwind/windframework/downloads Gets the latest source code for the frame, and you can also find the previous release version here. Download decompression, or use git@github.com:phpwind/windframework.git directly.

Environmental requirements:

php5.1.2 and above version.

A web environment that can be published, Apache or Aginx

Then: Start our HelloWorld journey

1. Create an application directory file

We create a folder in the Web's root directory (/var/www or elsewhere), named HelloWorld. Unzip the downloaded frame and place it in the application directory. Create a good directory structure as follows:

/var/www/helloworld/

wind/Framework Directory

controller/Application Controller directory, business code placed in this directory

controller/indexcontroller.php application controller with default access

template/page Template Catalog

template/index.htm template file

index.php Portal Script File

2. Edit Entry Script index.php

Create the portal script index.php in the application directory, its main task is to load the frame and start the application. The code is as follows:

Require_once ('.. /.. /wind/wind.php ');

Wind::application ()->run ();

* Of course, you can also set the error level in the index.php, Wind_debug mode and so on. The relevant content is described later.

3. Create indexcontroller.php

Create the controller/directory under the application directory. The controller directory is the directory that is stored by the Windframework default-defined application controller, and we can change the access path of the application by manually configuring it. Create the Indexcontroller.php class file under the controller/directory we created. The contents of the document are as follows:

<?php

/**

* The last known user to the repository < $LastChangedBy: Long.shi $>

* @author Qiong Wu

* @version $Id: indexcontroller.php 2806 2011-09-23 03:28:55z Long.shi $

* @package

*/

Class Indexcontroller extends Windcontroller {

Public Function run () {

echo ' Hello World ';

}

}

?>

* The file name and class name are the same in Windframework, which is somewhat similar to Java. Windframework provides two types of application controllers ' Windsimplecontroller ', ' Windcontroller '. Here we inherit from ' Windcontroller ', the difference between the two application controllers, which will be specifically described later.

At this point, our HelloWorld application has been completed. Quickly through the browser to visit our HelloWorld bar:

http://localhost/helloworld/index.php



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.