A lightweight PHP development framework: LitPHP

Source: Internet
Author: User
Tags php error
A lightweight PHP development framework: LitPHP introduction

LitPHP is a lightweight PHP development framework. based on the MVC architecture, LitPHP is built with a combination of PHP + Apache + smarty. Its feature is to encapsulate common functions as much as possible, while avoiding redundant classes and methods as much as possible, so that all phper can get started as soon as possible.

Environment requirements

Pay attention to the development environment when using this LitPHP version. use PHP5 and later versions, Apache24 and later versions.

Deployment Framework
  • Deploy the framework in the web root directory,
  • Enable the apacherewrite_module modules/mod_rewrite.so module,
  • Access http: // localhost/litphp'
  • 'Welcome to the LitPHP framework! :) 'Indicates that the deployment is successful.
Directory structure

Web root directory

Index. php (application entry file)

. Htaccess (Apache distributed configuration file)

Public)

App (app file directory)

Conf (application configuration file directory)

Controller (application controller directory)

Model (application model Directory)

View (application view directory)

LitPHP (system file directory)

Smarty (smarty Template Engine Directory)

Verify (the verification code directory stores the font and background image of the verification code)

Config. php (default configuration file)

LitPHP. class. php (system initialization class)

Route. class. php (Route parsing class)

Smarty. class. php (rewrite the smarty template class)

Controller. class. php (basic Controller class)

Model. class. php (basic Model class)

Verify. class. php (verification code class)

Page. class. php (paging class)

Image. class. php (Image processing class)

Redis. class. php (redis Cache class)

  • To prevent directory browsing, you only need to comment out the # Options All-Indexes in the. htaccess file, that is, delete the '#' number.
  • To disable all PHP error reports, set the DEBUG constant in the configuration file to 'off.
Basic Litphp framework running process

Application entry file ====> system initialization class (route parsing class) ====> application controller class

About routing
  • The LitPHP route parsing class uses the rewrite method to parse the route
  • LitPHP uses $ _ SERVER ['php _ info'] to obtain parameters and parse them according to the routing rewrite rules.
  • The routing rewrite rule is: entry file/controller/method/parameter 1/parameter 2/, for example, index. php/index/id/123/user/xxx.
  • When the entry file is index. php, the entry file can be omitted in the address bar.
  • When using a route rewrite rule to parse a route, if a parameter is included, make sure that the controller and method in the address bar exist at the same time; otherwise, the resolution will fail.
Create an application
  • Create an entry File (for example, index. php). if the entry file is in the application directory, copy and paste the. htaccess file under the web root directory to the application directory.
  • Update the application path in the entry file.
  • Update the LitPHP file import path in the entry file
  • Create an application directory (note: The Application directory name should be the same as the application name ).
  • Access the entry file in the browser. The system will generate some basic directories and default controller classes under the application directory.
Placement of front-end files
  • Front-end html templates and js and css files should be placed in public files under the web directory to reduce the leakage of the website directory structure.
  • By default, the view folder under the application directory contains the template compilation directory and template cache Directory. you can also place the front-end files in this directory, but be sure to modify the relevant path in the configuration file.
About namespaces
  • LitPHP uses the automatic loading class mode to introduce class files. therefore, pay attention to the namespace definition.
  • The namespace of the LitPHP system class is 'litphp'. when referencing the system class, pay attention to the system class namespace such as 'use LitPHP \ classname; 'where classname is the name of the system class to be referenced.
  • The namespace of the application controller class and model class should be the application name \ controller layer name or model layer name, for example, 'namespace app \ controller; 'or 'namespace app \ model ;'.

Project homepage:Http://www.open-open.com/lib/view/home/1444490114885

Related Article

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.