一个轻量级的PHP开发框架:LitPHP
LitPHP简介
LitPHP是一款轻量级PHP开发框架,基于MVC架构,采用PHP+Apache+smarty组合搭建。其特点是尽可能多地封装常用功能,同时又尽可能地避免增加冗杂的类与方法,让所有phper都能尽快上手。
环境要求使用本版本LitPHP时注意开发环境,应采用PHP5及以上版本,Apache24及以上版本。
部署框架- 把框架部署在web根目录下,
- 开启apacherewrite_module modules/mod_rewrite.so模块,
- 访问http://localhost/litphp'
- 页面出现 '欢迎使用LitPHP框架! :)'即是部署成功。
web根目录
index.php (应用入口文件)
.htaccess (Apache分布式配置文件)
public (公共目录)
app (应用文件目录)
conf (应用配置文件目录)
controller (应用控制器目录)
model (应用模型目录)
view (应用视图目录)
LitPHP (系统文件目录)
smarty (smarty模版引擎目录)
verify (验证码目录 存放验证码字体及背景图片)
config.php (系统默认配置文件)
LitPHP.class.php (系统初始化类)
Route.class.php (路由解析类)
Smarty.class.php (重写smarty模版类)
Controller.class.php (基础控制器类)
Model.class.php (基础模型类)
Verify.class.php (验证码类)
Page.class.php (分页类)
Image.class.php (图片处理类)
Redis.class.php (redis缓存类)
- 如要阻止目录浏览,只需把.htaccess文件里的#Options All -Indexes注释掉,即删除'#'号即可。
- 如要关闭PHP所有错误报告,只需将配置文件中的DEBUG常量设置为'off'即可。
应用入口文件=====>系统初始化类(路由解析类)=====>应用控制器类
关于路由- LitPHP路由解析类采用重写方法解析路由
- LitPHP通过 $_SERVER['PHP_INFO']获得参数 并按路由重写规则对参数进行解析。
- 路由重写规则为:入口文件/控制器/方法/参数一/参数二/, 如: index.php/index/index/id/123/user/xxx 。
- 当入口文件为index.php时候,地址栏中可省略该入口文件。
- 当用路由重写规则解析路由时,若带参数,则应保证地址栏中的控制器、方法同时存在,否则解析会出错。
- 新建入口文件 (如:index.php),若入口文件在应用目录下则应将web根目录下的.htaccess文件复制一份粘贴到该应用目录下。
- 更新入口文件中的应用路径。
- 更新入口文件中LitPHP文件引入路径
- 新建应用目录(注意:应用目录名称应与应用名称相同)。
- 在浏览器里访问入口文件,系统会在应用目录下生成一些基础目录及默认控制器类。
- 前端的html模版及js、css文件应放置在web目录下的public文件中 这样可以减少网站目录结构的泄漏。
- 应用目录下的view文件夹中默认放置了模版编译目录、模版缓存目录,也可将前端文件放置在此目录下,但注意修改配置文件中的相关路径。
- LitPHP 采用自动加载类的模式引入类文件 所以应注意命名空间的定义。
- LitPHP系统类的命名空间均为 'LitPHP' ,引用系统类时应注意引入系统类的命名空间 如 'use LitPHP\classname;' 其中classname为要引用的系统类名称。
- 应用控制器类及模型类其命名空间应为 应用名称\控制器层名称或模型层名称; 如: 'namespace app\controller;' 或 'namespace app\model;' 。
项目主页:http://www.open-open.com/lib/view/home/1444490114885

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.
