Heim  >  Fragen und Antworten  >  Hauptteil

php - 关于laravel请求响应慢的问题,怎么解决?

使用php7.0,Apache+mysql开发laravel程序,但是每次请求的时间很长,1秒多,扩展了opcache也没能解决,应该怎么办。

代码如下:(数据表中的数据20条)

$test = DB::table('cats')->select('id','price');           
$a= $test->get();
dd($a);

这里 dd($test)的话,时间是380ms,我该怎么做,求指点

世界只因有你世界只因有你2686 Tage vor563

Antworte allen(2)Ich werde antworten

  • 阿神

    阿神2017-05-16 12:04:04

    1. 关掉xDebug扩展

    2. config/app.php中,关掉Barryvdh\Debugbar

    3. config/app.php关闭无用的ServiceProvider

    4. 执行php artisan route:cache 将路由缓存起来

    以上都没解决,那考虑数据库连接是否有问题。

    Antwort
    0
  • 滿天的星座

    滿天的星座2017-05-16 12:04:04

    数据库连接的问题 如果使用的是localhost 换成127.0.0.1试试

    Antwort
    0
  • StornierenAntwort