一、安装Tideways
git clone https://github.com/tideways/php-xhprof-extension.git
cd php-profiler-extension
phpize
./configure
make && make install
php.ini加入 extension=tideways.so
service php-fpm restart
二、添加中间件 ProfilerMiddleware
文件位置:app/Http/Middleware/ProfilerMiddleware.php
直接上代码:
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\DB;
class ProfilerMiddleware
{
public function handle($request, Closure $next)
{
$extension = extension_loaded('tideways_xhprof');
if (!$extension) {
return $next($request);
}
tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_CPU | TIDEWAYS_XHPROF_FLAGS_MEMORY);
$begin