2017-03-09 38 views
0

我开始通过教程来学习学习Laravl 5. https://tutorials.kode-blog.com/laravel-hello-worldLaravel:不产生完整的自动工匠命令生成的代码

我遵循的步骤

当我运行命令:php artisan make:controller Hello

我得到的只是基本代码:

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

use App\Http\Requests; 

class Hello extends Controller 
{ 
    // 
} 

但是,教程spe在课堂中使用一些函数来自动生成代码。

报告说,自动生成的代码,

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

use App\Http\Requests; 
use App\Http\Controllers\Controller; 

class Hello extends Controller 
{ 
    /** 
    * Display a listing of the resource. 
    * 
    * @return Response 
    */ 
    public function index() 
    { 
     // 
    } 

    /** 
    * Show the form for creating a new resource. 
    * 
    * @return Response 
    */ 
    public function create() 
    { 
     // 
    } 

    /** 
    * Store a newly created resource in storage. 
    * 
    * @param Request $request 
    * @return Response 
    */ 
    public function store(Request $request) 
    { 
     // 
    } 

    /** 
    * Display the specified resource. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function show($id) 
    { 
     // 
    } 

    /** 
    * Show the form for editing the specified resource. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function edit($id) 
    { 
     // 
    } 

    /** 
    * Update the specified resource in storage. 
    * 
    * @param Request $request 
    * @param int $id 
    * @return Response 
    */ 
    public function update(Request $request, $id) 
    { 
     // 
    } 

    /** 
    * Remove the specified resource from storage. 
    * 
    * @param int $id 
    * @return Response 
    */ 
    public function destroy($id) 
    { 
     // 
    } 
} 

我无法弄清楚需要哪些配置更改进行更新或者我失去了一些东西非常基本的这个框架,首先,我试图重新安装应用程序又一次和同样的问题再次发生。

回答

2

该教程看起来有些过时。在Laravel 5.2中,默认情况下,该命令已更新为生成纯控制器。

要生成“资源”的控制器,如在本教程中,你现在需要通过“--resource”标志:

php artisan make:controller Hello --resource 
+0

谢谢...因此,任何良好的资源学习更新版本(除了形式文件作为参考文献),这些文件是用一个完整的项目教授的,或者是与它本身共同完成的,因为最终的学习会比创造很多错误观念是好事。 – atjoshi

+1

@atjoshi学习Laravel的最佳资源之一是Laracasts。那里有很多很棒的免费内容,而不仅仅是Laravel。您可能想要从Scratch系列学习Laravel开始,该系列每次发布都会更新,并始终免费:https://laracasts.com/series/laravel-from-scratch-2017 – patricus