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>