initphp framework to build highly available Web applications 01: Creating Projects

Source: Internet
Author: User

Initphp Framework is a lightweight PHP open source framework, framework documentation and download address: http://initphp.com

Create the Hello World Project

1. Download frame

Select the latest version to download. Frame Download Address: http://initphp

2. Create a project directory

Create a project directory, catalog diagram:

1. Folder initphp is the most recently downloaded initphp frame folder

2. conf/comm.conf.php Placement Project configuration file

3. web/controller/folder Placement Controller file

4. index.php is a project entry document

Description: A project developed using initphp is a single entry, and all requests are distributed through index.php.

3. index.php Entry File

Index.php code Example


The portal file is very simple, define a App_path variable, and then import the frame initphp.php file, and finally invoke the Initphp::init () in the frame to run the frame.

4. configuration file comm.conf.php

The comm.conf.php configuration file has been imported in the index.php entry file. If we do not configure the conf.php file ourselves, the framework automatically uses a default profile from the frame initphp.conf.php

Our customized configuration can copy the configuration information inside the initphp.conf.php. There are a lot of configuration information that you can filter on as needed.

Since our first tutorial only needs to use Hello World, the configuration is as follows:




We mainly configure $initphp_conf[' URL ' and controller-related configuration parameters.

5. indexcontroller.php Controller File



The index.php portal file needs to inherit the controller base class, controller is a class defined in initphp.

You need to define a run method, the Run method is a default action method. This method name can be defined in the configuration name.

6. Complete the project to build, run

This time we visit http://127.0.0.1/test/, the browser will output HelloWorld

We can also access through parameters: Http://127.0.0.1/test/index.php?c=index&a=run access. Parameter C represents the corresponding controller name, and run represents the accessible action method name in controller.

entry file and app Detach project

1. Project directory Structure

2. Why do you do this?

1. The separation of the entry file and the app project file can be more secure first. When configuring Apache or Nginx virtual machines, as long as the WWW directory refers to the Test/www directory, the external layer, the user can not access to the app folder under the URL file.

2. Multiple entrances can be achieved. Through multiple entrances, it is convenient to realize different entry into different project modules.

3. Let the level two domain name achieve simpler.

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

The way in which the portal files are detached is simply to modify the entry file index.php. Here's index.php.

The following introduction uses the way this project is deployed.



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.