{"id":19771171,"url":"https://github.com/hetao29/slightphp","last_synced_at":"2025-04-12T15:36:49.771Z","repository":{"id":29970805,"uuid":"33517748","full_name":"hetao29/slightphp","owner":"hetao29","description":"SlightPHP 高效的PHP敏捷开发框架","archived":false,"fork":false,"pushed_at":"2025-02-19T03:03:24.000Z","size":13117,"stargazers_count":114,"open_issues_count":0,"forks_count":38,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-03T16:11:47.253Z","etag":null,"topics":["apc","composer","database","framework","mysql","pecl","php","slightphp","swoole","workerman"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hetao29.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-04-07T02:34:38.000Z","updated_at":"2025-03-25T15:36:47.000Z","dependencies_parsed_at":"2023-01-14T16:01:23.229Z","dependency_job_id":"87075fcd-8323-4e4e-8271-13e5cbfae1d0","html_url":"https://github.com/hetao29/slightphp","commit_stats":{"total_commits":600,"total_committers":9,"mean_commits":66.66666666666667,"dds":"0.43833333333333335","last_synced_commit":"29629e9fe424da95c91f41d03ab16b1b4abc29c0"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hetao29%2Fslightphp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hetao29%2Fslightphp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hetao29%2Fslightphp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hetao29%2Fslightphp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hetao29","download_url":"https://codeload.github.com/hetao29/slightphp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248590429,"owners_count":21129818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apc","composer","database","framework","mysql","pecl","php","slightphp","swoole","workerman"],"created_at":"2024-11-12T05:01:11.474Z","updated_at":"2025-04-12T15:36:49.749Z","avatar_url":"https://github.com/hetao29.png","language":"PHP","readme":"# SlightPHP 高效的PHP敏捷开发框架\n\n### 安装方法\n  - 方法一 ，执行下面的命令\n```bash\n//使用中国镜像\ncomposer config -g repo.packagist composer https://packagist.phpcomposer.com\n//下载安装最新\ncomposer require \"hetao29/slightphp:^4.0.0\"\n```\n\n  - 方法二 ，新增 composer.json，然后 composer install就可以了\n```json\n{\n    \"require\": {\n        \"hetao29/slightphp\": \"^4.0.0\"\n    },\n    \"repositories\": {\n        \"packagist\": {\n             \"type\": \"composer\",\n             \"url\": \"https://mirrors.aliyun.com/composer/\"\n        }\n    }\n}\n```\n  \n### 主要特点：\n  - 独有的\"框架\"与\"plugins\"分离方式，与现在主流框架完全不同，把核心框架与其它功能独立分开，灵活性大，耦合度小，很方便移植\n  - 支持命令行(cli)模式 可以直接执行SlightPHP::run($path_info) ，可以用于WorkerMan,Swoole 等PHP 服务端项目\n  - 框架本身核心代码非常小\n  - 框架支持nginx,lighttpd,apache,iis等web服务器\n  - 插件SDb，基于PDO支持mysql,mssql,oracle等主流数据库，同时更支持数据库读写库分离，特适合大流量网站\n  - 插件SRoute 支持各种简洁路由支持，精简URL\n  - 插件STpl模板类，高效与灵活，比Smarty轻量级不少！\n  - 其它更多灵活可定制的插件，请查看wiki或者samples下的例子\n\n### Hello, world!\n#### 第一步\n在网站根目录下，建立index.php\n\n```php\n\u003c?php\n//加载方式1，直接加载框架\n//require_once(\"SlightPHP.php\");\n\n//加载方式2，使用composer的autoload\nrequire_once(\"vendor/autoload.php\");\n\nSlightPHP::run();\n?\u003e\n```\n#### 第二步\n第二步 请在index.php所在目录下新建zone目录，在zone目录下新建page.page.php\n```php\n\u003c?php \nclass zone_page{ \n    function PageEntry($inPath){\n        echo \"Hello, world!\";\n    } \n} \n?\u003e\n```\n#### 第三步\n请在你的地址栏里访问index.php，如\n```html\nhttp://localhost/index.php\n```\n\n\n### 基本概念\n\n```sh\nzone 映射为一个目录名，默认为\"zone\"\npage 映射为一个文件名，以.page.php为扩展名，默认为\"page\"\nentry 映射为方法名，以Page开头的方法名，默认为\"entry\"\nappDir 应用程序目录，默认为\".\"，就是当前目录\nsplitFlag 分割符，默认为\"/\"\ninPath entry入口参数，数组，下面会有更详细的介绍\n```\n\n#### 地址解析\n这个地址 http://localhost/index.php 实际上和 http://localhost/index.php/zone/page/entry 一样\n会执行你的$appDir/zone/page.page.php下的pageEntry方法\n\n\n你可以改变其默认规则\n```php\n\u003c?php\nSlightPHP::setDefaultZone(\"user\");\nSlightPHP::setDefaultPage(\"profile\");\nSlightPHP::setDefaultEntry(\"update\");\n?\u003e\n```\n当访问 http://localhost/index.php 时，就会执行\n$appDir/user/profile.page.php里的pageUpdate方法，其实就是 \nhttp://localhost/index.php/user/profile/update \n这个URL\n#### 高级地址解析-别名\n如果加了这代码\n```php\nSlightPHP::setZoneAlias(\"user\",\"u\");\nSlightPHP::setPageAlias(\"profile\",\"p\");\n```\n你访问这个地址\nhttp://localhost/index.php/u/p/update\n和http://localhost/index.php/user/profile/update\n会是一样的效果\n它的作用是增加user一个别名u\n\n#### 分隔符(splitFlag)\nzone,page,entry的分隔默认是用/来分的，你可以改成自己想要的，如\n```php\nSlightPHP::setSplitFlag(\".\")\n```\n就可以这样访问了\nhttp://localhost/index.php/user.profile.update\n或者更好看，加上.html\nhttp://localhost/index.php/user.profile.update.html\n这样的方式你也可以这样,用多个分割符\n```php\nSlightPHP::setSplitFlag(\"-.\")\n```\nhttp://localhost/index.php/user-profile-update.html\n和上面的是一样\n#### Apache Rewrite\n在你的.htaccess里或者apache的配置文件里加下类似代码\n```conf\nRewriteEngine   on\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^(.*)$ index.php/$1 [L]\n```\n你就可以直接这样访问了\nhttp://localhost/user/profile/update\n如果你还加上了\n```php\nSlightPHP::setSplitFlag(\".\");\n```\n那么就可以用这样的方式 http://localhost/user.profile.update\n#### 短路由\n如你要直接这样，更短的地址\nhttp://localhost/profile/update\n请在apache的配置文件里加上类似这样的代码\n```php\nRewriteRule   ^(/profile/.*)$ /index.php/user/profile/update/$1 [E=PATH_INFO:$1,L]\n```\n#### 关于$inPath\n\n  - $inPath[0] 就是当前的 zone的名字\n  - $inPath[1] 就是当前的 page的名字\n  - $inPath[2] 就是当前的 entry的名字\n  - $inPath[...] 超过以前的就是后面更多的参数，如html\n\n如 http://localhost/index.php/user/profile/update/other1/other2/... inPath是这样的\n$inPath=array(\"user\",\"profile\",\"update\",\"other1\",\"other2\",\"...\")\n#### appDir，程序目录设置\n你可以自定义你的程序目录\n```php\nSlightPHP::setAppDir(\"/home/www/myAppdir\");\n```\n如http://localhost/index.php/user/profile/update\n\n就会执行\n\n/home/www/myAppdir/user/profile.page.php下的pageUpdate方法\n\n建议你的appDir目录不要让外部访问到\n\n#### 插件导航 \n\nWiki文档地址：https://github.com/hetao29/slightphp/tree/master/wiki  \nAPI文档地址：http://hetao29.github.io/slightphp/\n  \nSTpl 模板插件 https://github.com/hetao29/slightphp/blob/master/wiki/STpl.md  \nSDb 数据库插件 https://github.com/hetao29/slightphp/blob/master/wiki/SDb.md  \n\nSRedis 缓存Redis插件 https://github.com/hetao29/slightphp/blob/master/wiki/SRedis.md  \nSConfig 配置文件插件 https://github.com/hetao29/slightphp/blob/master/wiki/SConfig.md  \nSRoute 路由插件 https://github.com/hetao29/slightphp/blob/master/wiki/SRoute.md  \nSError 错误插件 https://github.com/hetao29/slightphp/blob/master/wiki/SError.md  \n...  \n \n更多插件功能请看samples下的示例  \n\n\n#### Nginx配置\n```php\n\nroot /var/www/slightphp/samples/www;\nlocation / {\n\ttry_files $uri $uri/ /index.php$is_args$args;\n}\nlocation ~ \\.php$ {\n\tfastcgi_pass   127.0.0.1:9000;\n\tfastcgi_index  index.php;\n\tfastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\n\tinclude        fastcgi_params;\n}\n```\n\n### Version\n4.0.0\n\n**Free Software, MIT License!**\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhetao29%2Fslightphp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhetao29%2Fslightphp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhetao29%2Fslightphp/lists"}