框架的目錄結(jié)構(gòu)還是標(biāo)準(zhǔn)的 Laravel 框架結(jié)構(gòu)
項(xiàng)目目錄下 composer.json 文件
illuminate 的核心組件: 路由、 事件、視圖、數(shù)據(jù)庫
{
"require": {
"illuminate\routing": "*",
"illuminate\events": "*",
"illuminate\view": "*",
"illuminate\database": "*"
},
"autoload" : {
"psr-4": {
"App\\": "app/"
}
},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
}
入口文件 index.php
<?php
// composer 自動(dòng)加載文件
require __DIR__ . '/../vendor/autoload.php';
// Eloquent 數(shù)據(jù)庫管理
use Illuminate\Database\Capsule\Manager;
// 流式接口(fluent interface)是軟件工程中面向?qū)ο驛PI的一種實(shí)現(xiàn)方式,以提供更為可讀的源代碼艾帐。
use Illuminate\Support\Fluent;
// 容器實(shí)例
$app = new Illuminate\Container\Container;
Illuminate\Container\Container::setInstance($app);
// 事件、 路由
with(new Illuminate\Events\EventServiceProvider($app))->register();
with(new Illuminate\Routing\RoutingServiceProvider($app))->register();
// 數(shù)據(jù)庫實(shí)例
$manager = new Manager;
$manager->addConnection(require '../config/database.php');
$manager->bootEloquent();
// 視圖、 文件
with(new Illuminate\View\ViewServiceProvider($app))->register();
with(new Illuminate\Filesystem\FilesystemServiceProvider($app))->register();
// 配置實(shí)例
$app->instance('config', new Fluent);
$app['config']['view.compiled'] = "D:\\wamp\\www\\lara\\storage\\framework\\views\\";
$app['config']['view.paths'] = ["D:\\wamp\\www\\lara\\resources\\views\\"];
require __DIR__ . '/../app/Http/routes.php';
$request = Illuminate\Http\Request::createFromGlobals();
$response = $app['router']->dispatch($request);
$response->send();