框架的目录结构还是标准的 Laravel 框架结构
项目目录下 composer.json 文件
illuminate 的核心组件: 路由、 事件、视图、数据库
{
"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 自动加载文件
require __DIR__ . '/../vendor/autoload.php';
// Eloquent 数据库管理
use Illuminate\Database\Capsule\Manager;
// 流式接口(fluent interface)是软件工程中面向对象API的一种实现方式,以提供更为可读的源代码。
use Illuminate\Support\Fluent;
// 容器实例
$app = new Illuminate\Container\Container;
Illuminate\Container\Container::setInstance($app);
// 事件、 路由
with(new Illuminate\Events\EventServiceProvider($app))->register();
with(new Illuminate\Routing\RoutingServiceProvider($app))->register();
// 数据库实例
$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();
// 配置实例
$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();