PHPackages                             hetao29/slightphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. hetao29/slightphp

ActiveLibrary[Framework](/categories/framework)

hetao29/slightphp
=================

SlightPHP PHP FrameWork

4.3.0(1mo ago)113510↓100%38MITPHP

Since Mar 4Pushed 1mo ago14 watchersCompare

[ Source](https://github.com/hetao29/slightphp)[ Packagist](https://packagist.org/packages/hetao29/slightphp)[ Docs](https://github.com/hetao29/slightphp)[ RSS](/packages/hetao29-slightphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (56)Used By (0)

SlightPHP 高效的PHP敏捷开发框架
======================

[](#slightphp-高效的php敏捷开发框架)

### 安装方法

[](#安装方法)

- 方法一 ，执行下面的命令

```
//使用中国镜像
composer config -g repo.packagist composer https://packagist.phpcomposer.com
//下载安装最新
composer require "hetao29/slightphp:^4.0.0"
```

- 方法二 ，新增 composer.json，然后 composer install就可以了

```
{
    "require": {
        "hetao29/slightphp": "^4.0.0"
    },
    "repositories": {
        "packagist": {
             "type": "composer",
             "url": "https://mirrors.aliyun.com/composer/"
        }
    }
}
```

### 主要特点：

[](#主要特点)

- 独有的"框架"与"plugins"分离方式，与现在主流框架完全不同，把核心框架与其它功能独立分开，灵活性大，耦合度小，很方便移植
- 支持命令行(cli)模式 可以直接执行SlightPHP::run($path\_info) ，可以用于WorkerMan,Swoole 等PHP 服务端项目
- 框架本身核心代码非常小
- 框架支持nginx,lighttpd,apache,iis等web服务器
- 插件SDb，基于PDO支持mysql,mssql,oracle等主流数据库，同时更支持数据库读写库分离，特适合大流量网站
- 插件SRoute 支持各种简洁路由支持，精简URL
- 插件STpl模板类，高效与灵活，比Smarty轻量级不少！
- 其它更多灵活可定制的插件，请查看wiki或者samples下的例子

### Hello, world!

[](#hello-world)

#### 第一步

[](#第一步)

在网站根目录下，建立index.php

```

```

#### 第二步

[](#第二步)

第二步 请在index.php所在目录下新建zone目录，在zone目录下新建page.page.php

```

```

#### 第三步

[](#第三步)

请在你的地址栏里访问index.php，如

```
http://localhost/index.php
```

### 基本概念

[](#基本概念)

```
zone 映射为一个目录名，默认为"zone"
page 映射为一个文件名，以.page.php为扩展名，默认为"page"
entry 映射为方法名，以Page开头的方法名，默认为"entry"
appDir 应用程序目录，默认为"."，就是当前目录
splitFlag 分割符，默认为"/"
inPath entry入口参数，数组，下面会有更详细的介绍
```

#### 地址解析

[](#地址解析)

这个地址  实际上和  一样 会执行你的$appDir/zone/page.page.php下的pageEntry方法

你可以改变其默认规则

```

```

当访问  时，就会执行 $appDir/user/profile.page.php里的pageUpdate方法，其实就是 这个URL

#### 高级地址解析-别名

[](#高级地址解析-别名)

如果加了这代码

```
SlightPHP::setZoneAlias("user","u");
SlightPHP::setPageAlias("profile","p");
```

你访问这个地址 和会是一样的效果 它的作用是增加user一个别名u

#### 分隔符(splitFlag)

[](#分隔符splitflag)

zone,page,entry的分隔默认是用/来分的，你可以改成自己想要的，如

```
SlightPHP::setSplitFlag(".")
```

就可以这样访问了 或者更好看，加上.html 这样的方式你也可以这样,用多个分割符

```
SlightPHP::setSplitFlag("-.")
```

和上面的是一样

#### Apache Rewrite

[](#apache-rewrite)

在你的.htaccess里或者apache的配置文件里加下类似代码

```
RewriteEngine   on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

```

你就可以直接这样访问了 如果你还加上了

```
SlightPHP::setSplitFlag(".");
```

那么就可以用这样的方式

#### 短路由

[](#短路由)

如你要直接这样，更短的地址 请在apache的配置文件里加上类似这样的代码

```
RewriteRule   ^(/profile/.*)$ /index.php/user/profile/update/$1 [E=PATH_INFO:$1,L]
```

#### 关于$inPath

[](#关于inpath)

- $inPath\[0\] 就是当前的 zone的名字
- $inPath\[1\] 就是当前的 page的名字
- $inPath\[2\] 就是当前的 entry的名字
- $inPath\[...\] 超过以前的就是后面更多的参数，如html

如 ... inPath是这样的 $inPath=array("user","profile","update","other1","other2","...")

#### appDir，程序目录设置

[](#appdir程序目录设置)

你可以自定义你的程序目录

```
SlightPHP::setAppDir("/home/www/myAppdir");
```

如

就会执行

/home/www/myAppdir/user/profile.page.php下的pageUpdate方法

建议你的appDir目录不要让外部访问到

#### 插件导航

[](#插件导航)

Wiki文档地址：
API文档地址：

STpl 模板插件
SDb 数据库插件

SRedis 缓存Redis插件
SConfig 配置文件插件
SRoute 路由插件
SError 错误插件
...

更多插件功能请看samples下的示例

#### Nginx配置

[](#nginx配置)

```
root /var/www/slightphp/samples/www;
location / {
	try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
	fastcgi_pass   127.0.0.1:9000;
	fastcgi_index  index.php;
	fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	include        fastcgi_params;
}
```

### Version

[](#version)

4.0.0

**Free Software, MIT License!**

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance94

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 99% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~75 days

Total

55

Last Release

59d ago

Major Versions

3.7.8 → 4.0.02024-11-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/b835c445e79339f6c8401b78b03cc22776c850189c94fddb93fa685d7986a168?d=identicon)[hetao29](/maintainers/hetao29)

---

Top Contributors

[![hetao29](https://avatars.githubusercontent.com/u/8010298?v=4)](https://github.com/hetao29 "hetao29 (98 commits)")[![csk83](https://avatars.githubusercontent.com/u/240821?v=4)](https://github.com/csk83 "csk83 (1 commits)")

---

Tags

apccomposerdatabaseframeworkmysqlpeclphpslightphpswooleworkermanphpframeworkslightphp

### Embed Badge

![Health badge](/badges/hetao29-slightphp/health.svg)

```
[![Health](https://phpackages.com/badges/hetao29-slightphp/health.svg)](https://phpackages.com/packages/hetao29-slightphp)
```

###  Alternatives

[dingo-d/wp-pest

A package that will add WordPress integration test suite with Pest framework

12923.9k7](/packages/dingo-d-wp-pest)[hypervel/framework

The Hypervel framework.

1012.1k6](/packages/hypervel-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
