手动构建 Laravel 框架

框架的目录结构还是标准的 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

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();

你可能感兴趣的:(手动构建 Laravel 框架)