官方说 lumen 比 laravel快,那我们直接来测试 lumen

首先安装:

composer create-project --prefer-dist laravel/lumen blog

进入blog目录修改3个文件
1.   app/Http/Controllers/ExampleController.php
加个index方法

<?php

namespace App\Http\Controllers;

class ExampleController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    public function index(){
        global $start_time;
        echo 'hello word'.PHP_EOL;
        echo microtime(true) - $start_time;
    }

    //
}


2.    public/index.php

<?php
$start_time = microtime(true);
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/

$app = require __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$app->run();


3.   routes/web.php

<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/

$router->get('/', 'ExampleController@index');

看结果吧:

来看看 laravel/lumen  的速度-LMLPHP

什么都没有干 就消耗了15ms左右 还是php7下面测试lumen,laravel我就懒得测了

说一下我的环境 

MacBook Pro (Retina, 13-inch, Early 2015)
2.9 GHz Intel Core i5
8 GB 1867 MHz DDR3

05-05 00:26