noFrame PHP开发框架
noFrame在oschina托管地址:https://git.oschina.net/yii153/noFrame
noFrame在github托管地址:https://github.com/yii153/noFrame
目前noFrame的结构如下
|-Databases 数据库目录,该目录只能包含数据库类,且除Database类之外的所有类都要实现Database接口【仅供参考】
|-Database.class.php 数据库连接类,应用中链接数据库只需要引用该类并创建该类的对象【仅供参考】
|-Database.interface.php 数据库接口,定义了数据库类要实现的方法【仅供参考】
|-Mysql.class.php mysql数据库类,需要实现Database接口【仅供参考】
|-SqlServer.class.php sqlserver数据库类,需要实现Database接口【仅供参考】
|-Example 示例目录【仅供参考】
|-System.class.php 系统类,提供了欢迎信息,版本信息,入库示例,查询示例。可直接通过$webRoot/entrance.php/Example/System/$method调用获取信息【仅供参考】
|-Utils 工具目录【仅供参考】
|-Util.class.php 工具类,提供了请求执行成功,请求执行失败,请求执行成功并返回数据。可引用Util类并通过Util::$method调用【仅供参考】
|--LICENSE LICENSE文件
|--README.md README文件
|--entrance.php 入口文件【核心文件】
注:【仅供参考】部分可根据实际项目需要修改或删除。
noFrame 实现单一入口,类自动载入,全局类映射(可以通过单一入口映射任意目录中的任意类的任意公用方法,不局限于目录和层级),noFrame提供pathinfo模式和兼容模式两种入口模式,noFrame默认全局开启session,noFrame自带错误处理。noFrame不需要额外安装任何拓展和环境部署,只需拷贝到noFrame到您的web根目录下即可使用。并且,所有这些功能的实现都是通过一个文件来完成的。
noFrame以entrance.php(入口文件)作为核心文件。使用只需将该文件拷贝到应用根目录下,便可以快速开发出一套基于MVC、单一入口、类自动载入的应用。
noFrame基于PSR-0规范,类文件除类外不得有其他执行代码,所有类使用命名空间,命名空间和类的绝对路径一致,类名和路径名首字母大写,所有类自动载入。
下面以调用未知目录下的$Class类的$method方法为例
namespace $Folder_a\$Folder_b\Folder_c\...\$Folder_z; 命名空间与该文件的路径保持一致
use $Folder_d\$Folder_e\Folder_f\...\$IncludeClass; 引用其他目录下的类文件
use $Folder_g\$Folder_h\Folder_i\...\$IncludeStaticClass; 引用其他目录下的静态类文件
class $Class 创建类
{
public function $method() 创建public方法
{
$IC = new $IncludeClass(); 创建引用类的对象
$IC->$method(); 调用该对象的方法
$IncludeStaticClass::$method(); 调用引用静态类的方法
}
}
支持pathinfo的服务器环境调用地址如下
entrance.php/$Folder_a/$Folder_b/Folder_c/.../$Folder_z/$Class/$method
不支持pathinfo的服务器环境调用地址如下
entrance.php?$Folder_a/$Folder_b/Folder_c/.../$Folder_z/$Class/$method
pathinfo模式和兼容模式的调用区别仅仅是在entrance.php后面的/和?的区别。
noFrame对于请求的响应做了如下约定,具体可以参考Example下的System.class.php,当然你可以根据实际情况调整或修改其约定。
1.返回信息一定为json字符串
2.返回信息一定包含请求处理成功为真/假的信息
3.请求处理成功为假则一定包含错误信息。
4.完成请求后,将响应信息转成json对象,如果请求处理成功为假,则打印错误信息并返回。否则打印成功信息或解析数据
服务端示例 //Controller/Test/test
try{
//do some thing...
Util::echo_success();
}catch (Exception $e){
Util::echo_error($e->getMessage());
}
客户端示例 //entrance.php/Controller/Test/test
if(!response.success) {
alert(response.message);
return;
}
alert('success');
在使用过程中出现什么问题或bug可以反馈给我,以便及时更正

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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,

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.

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

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.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

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�...
