Build a highly available WEB application using the InitPHP Framework 01: Create a project_php tutorial

Source: Internet
Author: User
Build a highly available WEB application using the InitPHP Framework 01: create a project. The InitPHP framework is a lightweight PHP open-source framework. The Framework documentation and: initphp.com create the HelloWorld project. 1. select the latest version to download the framework. Framework 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.

Create a Hello World Project 1. download the framework and select the latest version. Framework...

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.