2017-03-09 37 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