Build a highly available WEB application using the InitPHP framework 01: Create a project

Source: Internet
Author: User

InitPHP framework is a lightweight PHP open source framework, framework documentation and: http://initphp.com

Create a Hello World project
1. Download the framework

Select the latest version to download. Framework: http: // initphp

 

2. Create a project directory

Create a project directory. directory:

1. the folder initphp is the latest downloaded initphp framework folder.

2. conf/comm. conf. php: place the project configuration file

3. Place the controller file in the web/controller/folder

4. index. php is the project entry file.

Note: The project developed using initphp is a single portal, and all requests are distributed through index. php.

 

3. index. php entry file

Index. php code example


 

The entry file is very simple. Define an APP_PATH variable, import the framework initphp. php file, and call InitPHP: init () in the framework to run the framework.

 

4. configuration file comm. conf. php

The comm. conf. php configuration file has been imported into the index. php entry file. If you do not configure the conf. php file, the Framework automatically uses the default configuration file initphp. conf. php.

The custom configuration can copy the configuration information in initphp. conf. php. There are a lot of configuration information, you can filter as needed.

Since we only need to use Hello World in the first tutorial, the configuration is as follows:




We mainly configure configuration parameters related to $ InitPHP_conf ['url'] and controller.

 

5. indexController. php controller File

The index. php entry file must inherit the Controller base class. Controller is a class defined in InitPHP.

You need to define a run method, which is a default Action method. The method name can be defined in the configuration.

 

6. build and run the project.

In this case, when we access http: // 127.0.0.1/test/, the browser will output HelloWorld

You can also access http: // 127.0.0.1/test/index. php through parameters? C = index & a = run access. Parameter c indicates the name of the corresponding Controller, and run indicates the name of the accessible Action Method in the Controller.

 

 

Entry file and APP Separation Project
1. project directory structure

 

 

2. Why?

 

1. The entry file and the app project file are separated to ensure security first. When configuring the apache or Nginx virtual machine, you only need to point the www directory to the test/www directory. For the external layer, you cannot access the files in the app folder through the URL.

2. Multiple portals can be implemented. Through multiple portals, different portals can be easily accessed into different project modules.

3. Make the implementation of second-level domain names easier.

 

 

3. What is the difference between this deployment and the above deployment?

 

You only need to modify the index. php file to deploy the separated entry file. Below is index. php

 

 

The deployment method of this project will be used later.

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.