官方說 lumen 比 laravel快,那咱們直接來測試 lumenphp
首先安裝:laravel
composer create-project --prefer-dist laravel/lumen blog
進入blog目錄修改3個文件
1. app/Http/Controllers/ExampleController.php
加個index方法web
<?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.phpbootstrap
<?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.phpphp7
<?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');
看結果吧:app
什麼都沒有幹 就消耗了15ms左右 仍是php7下面測試lumen,laravel我就懶得測了composer
說一下個人環境 測試
MacBook Pro (Retina, 13-inch, Early 2015)
2.9 GHz Intel Core i5
8 GB 1867 MHz DDR3ui