louisgjbertrand / phpfram
超级轻量级的PHP框架
v1.1.0.1
2024-06-29 07:52 UTC
Requires
- php: ^7.3.2 || ^8.0
- pecee/simple-router: ^5.0
Requires (Dev)
- filp/whoops: ^2.14
README
一个包含基本错误处理和路由的超级轻量级PHP框架。
此框架为您开发Web应用程序提供了一个基础。
此框架不包括任何表面性内容,它只包含基础的路由和文件结构。
要求
环境
- php v7.3.2 and above
- Composer
所需库
- pecee/simple-router
- filp/whoops (dev)
安装
要使用此框架创建项目,请执行以下composer命令
composer create-project louisgjbertrand/phpfram
使用
启动服务器
php -S 127.0.0.1:8080 public/index.php
添加路由
在 routes/routes.php 中
<?php // Using Simple Router use Pecee\SimpleRouter\SimpleRouter; // Declaring a route SimpleRouter::get('/', function() { return "Fram, v1.0, Super Lightweight Framework"; }); // Add your routes here: SimpleRouter::get('/example', function() { return "this is an example route"; }); SimpleRouter::start();
有关路由声明的更多信息,请参考 https://github.com/skipperbent/simple-php-router
处理PHP错误
要处理PHP错误,只需在 routes.php 中注册一个回调函数即可
<?php // Using Simple Router use Pecee\SimpleRouter\SimpleRouter; // Declaring a route SimpleRouter::get('/', function() { return "Fram, v1.0, Super Lightweight Framework"; }); // registering Errors SimpleRouter::start();
环境变量
环境变量位于 .env 文件中。env 文件格式为 INI。您可以通过添加新行来添加自己的环境变量。
APP_ENV=production ; either production / debug APP_DEBUG=true APP_TYPE=WWW ; either WWW / API / API-JSON