anvilm/php.framework
最新稳定版本:v3.3.4
Composer 安装命令:
composer create-project anvilm/php.framework
包简介
PHP Framework
README 文档
README
PHP Framework
This project is no longer supported see this
Install
composer create-project anvilm/php.framework
Getting started
Routing
All routes are registered in the file routes/Routes.php. This example initializes the Home route with the Home controller, Index action and GET method.
$Route->Add()->get('/home')->controller(HomeController::class)->action('IndexAction');
Controllers
All controllers are stored in app/controllers/ All controllers must be specified in the routes.
namespace App\Controllers; class UserController extends Controller { public function IndexAction() { ... } }
Actions
All actions must be specified in the routes.
namespace App\Controllers; class UserController extends Controller { ... public function Index() { ... } }
Middlewares
To use middleware for a route, you need to specify the middleware to be used in the route, and then create it in the middlewares folder.
All middlewares must be specified in the routes.
[
"URI" => '/home',
"Method" => 'GET',
"Controller" => "App\Controllers\HomeController",
"Action" => "IndexAction",
"Middleware" => [
'App\Middlewares\HomeMiddleware'
]
]
All middlewares are stored in app/middlewares/
namespace App\Middlewares; class AuthMiddleware { public function __construct() { return $auth ? true : false; } }
Models
All models are stored in src/models/
namespace App\Models; use Src\Database\Model; class UserModel extends Model { public function Index() { $this->Query(...); } }
Helpers
All App Helpers are stored in src/helpers/
function debug($data) { var_dump($data); exit(); }
All App Helpers must be specified in the config/helpers.php file.
return [ 'Env', 'Dev' ];
Env
.env is a file in which you can store all the necessary environment variables. To get the value of a variable from .env, you can use the existing ENV Helper or use your own
DB_HOST = "localhost" DB_PORT = "3306" DB_DATABASE = "ghosty" DB_USERNAME = "root" DB_PASSWORD = "root"
To get the value of a variable from .env use
$AppName = env("APP_NAME");
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-05