在看实现简单Blog展示[https://www.laravist.com/series/laravel-5-basic/episodes/8],在实验到01:48处,只要执行AppArticle::all() 发现进程直接退出。
请问在5.4版本model的all是有问题的?还会让php进程直接退出?
表现在页面上的效果像下面这样(服务器居然连头部都没有返回):
The localhost page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
下面用tinker测试:
Psy Shell v0.8.8 (PHP 7.1.4 — cli) by Justin Hileman
>>> App\Article::all();
➜ larvael
但下面的语句却可以:
>>> App\Article::find(1);
=> App\Article {#686
id: 1,
title: "my First Title",
content: "my First Content",
published_at: "2017-07-04 07:28:08",
created_at: "2017-07-04 07:28:34",
updated_at: "2017-07-04 07:28:34",
}
>>>
我看到官网上的文档也支持AppFlight::all(); all[http://d.laravel-china.org/docs/5.4/eloquent#取回多个模型]方法的,其它的同学是否也有这个问题?
controller和model通过下面语句创建:
pa make:controller ArticlesController --model=Article
➜ larvael cat app/Http/Controllers/ArticlesController.php
<?php
namespace App\Http\Controllers;
use App\Article;
use Illuminate\Http\Request;
class ArticlesController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
return Article::all();
}
....
➜ larvael cat app/Article.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
//
protected $table = "articles";
}
希望大家交流交流..