vertex
1.0.0
一个由Laravel启发的简单PHP框架
Vertex利用作曲家自动加载其依赖性。下载框架后,请确保运行以下命令。
composer install
然后,您可以运行以下命令来启动内置的PHP服务器。
php -S localhost:8000 -t public
所有配置选项均在根目录中的.env文件中指定。默认情况下,您将获得一个示例文件以使您启动。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=databasename
DB_USERNAME=root
DB_PASSWORD=root
还可以在/config Directory中手动声明您的设置。只需进入此目录中的任何文件,然后用所需的配置手动替换getenv()函数。
您可以使用Config::get()方法轻松访问顶点中的任何配置选项。向方法(例如Config::get('database') )提供字符串,它将返回该文件中指定的所有值的数组,在这种情况下,它将为/config/database.php 。
Vertex使用FastRoute满足其所有路由需求。路由存储在app/routes.php文件中。请访问以下存储库以获取完整文档https://github.com/nikic/fastroute。
这是一些示例路线:
/* standard routes */
$route->get('/test', 'ControllerName@MethodName');
$route->post('/test', 'ControllerName@MethodName');
$route->put('/test', 'ControllerName@MethodName');
$route->delete('/test', 'ControllerName@MethodName');
/* route with parameters */
$route->get('/test/{parameter}', 'ControllerName@MethodName');
/* route with closure */
$route->get('/test', function(){
return 'Test!';
});
/* route group */
$route->addGroup('/admin', function ($route) {
$route->get('/dashboard', 'AdminController@dashboard'); // admin/dashboard
$route->get('/pages', 'AdminController@pages'); // admin/pages
$route->get('/posts', 'AdminController@posts'); // admin/posts
});
Vertex使用Laravels奇妙的刀片模板引擎。视图存储在app/resources/views/目录中,必须具有.blade.php的文件扩展名。请访问https://laravel.com/docs/5.3/blade,以获取完整文档。
这是一个示例刀片模板:
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>