小编Geo*_*gie的帖子

如何解决Laravel 5中的超时错误

我有以下设置:

在我有的路线:

Route :: get('articles','ArticlesController @ index');

控制器中的索引方法很简单:

public function index()
{
   $articles = Article::all();
   return View('articles.index', compact('articles'));
}
Run Code Online (Sandbox Code Playgroud)

并在视图中:

@extends('../app')
@section('content')
<h1>Articles</h1>
<p>
    @foreach($articles as $article)
    <article>
        <h2><a href="{{action('ArticlesController@show', [$article->id])}}">{{$article->title}}</a></h2>
        <p>{{ $article->body }}</p>
    </article>
    @endforeach
</p>
@stop
Run Code Online (Sandbox Code Playgroud)

我试图取代:

$articles = Article::all();
Run Code Online (Sandbox Code Playgroud)

$article = Article::latest()->get();
Run Code Online (Sandbox Code Playgroud)

这样我才能真正展示最新的文章.我收到了错误:

FatalErrorException in Str.php line 322:
Maximum execution time of 30 seconds exceeded
Run Code Online (Sandbox Code Playgroud)

并且调用堆栈是:

in Str.php line 322
at FatalErrorException->__construct() in HandleExceptions.php line 131
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 116
at HandleExceptions->handleShutdown() in HandleExceptions.php …
Run Code Online (Sandbox Code Playgroud)

php laravel

37
推荐指数
5
解决办法
11万
查看次数

标签 统计

laravel ×1

php ×1