2014-09-23 45 views
0

無法繼續前進,我下面laracasts larabook的教程,但對我面對這個異常截圖附我無法動彈,加上我粘貼代碼ReflectionException類Larabook 表格 RegistrationForm不存在

<?php 
    // RegistrationForm.php location Larabook\App\Forms 
    namespace Larabook\Forms; 

    use Laracasts\Validation\FormValidator; 

    class RegistrationForm extends FormValidator{ 
     /* 
      validation rules 
     */ 
     protected $rules = [ 
      'username'=>'required|unique:users', 
      'email'=>'required|email|unique:users', 
      'password'=>'required|confirmed' 
     ]; 
    } 

<?php 
// controller 
use Larabook\Forms\RegistrationForm; 

class RegistrationController extends \BaseController { 
    /* 
     show a form to register the user 
    */ 
    private $registrationForm; 

    function __construct(RegistrationForm $registrationForm){ 
     $this->registrationForm = $registrationForm; 
    } 

    public function create(){ 
     return View::make('registration.create'); 
    } 

    public function store(){ 
     $this->registrationForm->validate(Input::all()); 
     $user = User::create(
      Input::only('username','email','password') 
     ); 
     Auth::login($user,false); 
     return Redirect::home(); 
    } 
} 
<?php 
// app.php 
return array(

    /* 
    |-------------------------------------------------------------------------- 
    | Application Debug Mode 
    |-------------------------------------------------------------------------- 
    | 
    | When your application is in debug mode, detailed error messages with 
    | stack traces will be shown on every error that occurs within your 
    | application. If disabled, a simple generic error page is shown. 
    | 
    */ 

    'debug' => true, 

    /* 
    |-------------------------------------------------------------------------- 
    | Application URL 
    |-------------------------------------------------------------------------- 
    | 
    | This URL is used by the console to properly generate URLs when using 
    | the Artisan command line tool. You should set this to the root of 
    | your application so that it is used when running Artisan tasks. 
    | 
    */ 

    'url' => 'http://localhost', 

    /* 
    |-------------------------------------------------------------------------- 
    | Application Timezone 
    |-------------------------------------------------------------------------- 
    | 
    | Here you may specify the default timezone for your application, which 
    | will be used by the PHP date and date-time functions. We have gone 
    | ahead and set this to a sensible default for you out of the box. 
    | 
    */ 

    'timezone' => 'UTC', 

    /* 
    |-------------------------------------------------------------------------- 
    | Application Locale Configuration 
    |-------------------------------------------------------------------------- 
    | 
    | The application locale determines the default locale that will be used 
    | by the translation service provider. You are free to set this value 
    | to any of the locales which will be supported by the application. 
    | 
    */ 

    'locale' => 'en', 

    /* 
    |-------------------------------------------------------------------------- 
    | Application Fallback Locale 
    |-------------------------------------------------------------------------- 
    | 
    | The fallback locale determines the locale to use when the current one 
    | is not available. You may change the value to correspond to any of 
    | the language folders that are provided through your application. 
    | 
    */ 

    'fallback_locale' => 'en', 

    /* 
    |-------------------------------------------------------------------------- 
    | Encryption Key 
    |-------------------------------------------------------------------------- 
    | 
    | This key is used by the Illuminate encrypter service and should be set 
    | to a random, 32 character string, otherwise these encrypted strings 
    | will not be safe. Please do this before deploying an application! 
    | 
    */ 

    'key' => 'key', 

    'cipher' => MCRYPT_RIJNDAEL_128, 

    /* 
    |-------------------------------------------------------------------------- 
    | Autoloaded Service Providers 
    |-------------------------------------------------------------------------- 
    | 
    | The service providers listed here will be automatically loaded on the 
    | request to your application. Feel free to add your own services to 
    | this array to grant expanded functionality to your applications. 
    | 
    */ 

    'providers' => array(

     'Illuminate\Foundation\Providers\ArtisanServiceProvider', 
     'Illuminate\Auth\AuthServiceProvider', 
     'Illuminate\Cache\CacheServiceProvider', 
     'Illuminate\Session\CommandsServiceProvider', 
     'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 
     'Illuminate\Routing\ControllerServiceProvider', 
     'Illuminate\Cookie\CookieServiceProvider', 
     'Illuminate\Database\DatabaseServiceProvider', 
     'Illuminate\Encryption\EncryptionServiceProvider', 
     'Illuminate\Filesystem\FilesystemServiceProvider', 
     'Illuminate\Hashing\HashServiceProvider', 
     'Illuminate\Html\HtmlServiceProvider', 
     'Illuminate\Log\LogServiceProvider', 
     'Illuminate\Mail\MailServiceProvider', 
     'Illuminate\Database\MigrationServiceProvider', 
     'Illuminate\Pagination\PaginationServiceProvider', 
     'Illuminate\Queue\QueueServiceProvider', 
     'Illuminate\Redis\RedisServiceProvider', 
     'Illuminate\Remote\RemoteServiceProvider', 
     'Illuminate\Auth\Reminders\ReminderServiceProvider', 
     'Illuminate\Database\SeedServiceProvider', 
     'Illuminate\Session\SessionServiceProvider', 
     'Illuminate\Translation\TranslationServiceProvider', 
     'Illuminate\Validation\ValidationServiceProvider', 
     'Illuminate\View\ViewServiceProvider', 
     'Illuminate\Workbench\WorkbenchServiceProvider', 
     'Way\Generators\GeneratorsServiceProvider', 
     'Laracasts\Commander\CommanderServiceProvider', 
     'Laracasts\Validation\ValidationServiceProvider' 
    ), 

    /* 
    |-------------------------------------------------------------------------- 
    | Service Provider Manifest 
    |-------------------------------------------------------------------------- 
    | 
    | The service provider manifest is used by Laravel to lazy load service 
    | providers which are not needed for each request, as well to keep a 
    | list of all of the services. Here, you may set its storage spot. 
    | 
    */ 

    'manifest' => storage_path().'/meta', 

    /* 
    |-------------------------------------------------------------------------- 
    | Class Aliases 
    |-------------------------------------------------------------------------- 
    | 
    | This array of class aliases will be registered when this application 
    | is started. However, feel free to register as many as you wish as 
    | the aliases are "lazy" loaded so they don't hinder performance. 
    | 
    */ 

    'aliases' => array(

     'App'    => 'Illuminate\Support\Facades\App', 
     'Artisan'   => 'Illuminate\Support\Facades\Artisan', 
     'Auth'   => 'Illuminate\Support\Facades\Auth', 
     'Blade'   => 'Illuminate\Support\Facades\Blade', 
     'Cache'   => 'Illuminate\Support\Facades\Cache', 
     'ClassLoader'  => 'Illuminate\Support\ClassLoader', 
     'Config'   => 'Illuminate\Support\Facades\Config', 
     'Controller'  => 'Illuminate\Routing\Controller', 
     'Cookie'   => 'Illuminate\Support\Facades\Cookie', 
     'Crypt'   => 'Illuminate\Support\Facades\Crypt', 
     'DB'    => 'Illuminate\Support\Facades\DB', 
     'Eloquent'  => 'Illuminate\Database\Eloquent\Model', 
     'Event'   => 'Illuminate\Support\Facades\Event', 
     'File'   => 'Illuminate\Support\Facades\File', 
     'Form'   => 'Illuminate\Support\Facades\Form', 
     'Hash'   => 'Illuminate\Support\Facades\Hash', 
     'HTML'   => 'Illuminate\Support\Facades\HTML', 
     'Input'   => 'Illuminate\Support\Facades\Input', 
     'Lang'   => 'Illuminate\Support\Facades\Lang', 
     'Log'    => 'Illuminate\Support\Facades\Log', 
     'Mail'   => 'Illuminate\Support\Facades\Mail', 
     'Paginator'  => 'Illuminate\Support\Facades\Paginator', 
     'Password'  => 'Illuminate\Support\Facades\Password', 
     'Queue'   => 'Illuminate\Support\Facades\Queue', 
     'Redirect'  => 'Illuminate\Support\Facades\Redirect', 
     'Redis'   => 'Illuminate\Support\Facades\Redis', 
     'Request'   => 'Illuminate\Support\Facades\Request', 
     'Response'  => 'Illuminate\Support\Facades\Response', 
     'Route'   => 'Illuminate\Support\Facades\Route', 
     'Schema'   => 'Illuminate\Support\Facades\Schema', 
     'Seeder'   => 'Illuminate\Database\Seeder', 
     'Session'   => 'Illuminate\Support\Facades\Session', 
     'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait', 
     'SSH'    => 'Illuminate\Support\Facades\SSH', 
     'Str'    => 'Illuminate\Support\Str', 
     'URL'    => 'Illuminate\Support\Facades\URL', 
     'Validator'  => 'Illuminate\Support\Facades\Validator', 
     'View'   => 'Illuminate\Support\Facades\View', 

    ), 

); 
{ 
    /* composer.json */ 
    "name": "laravel/laravel", 
    "description": "The Laravel Framework.", 
    "keywords": ["framework", "laravel"], 
    "license": "MIT", 
    "require": { 
     "laravel/framework": "4.2.*", 
     "laracasts/commander":"~1.0", 
     "laracasts/validation": "1.1.*" 
    }, 
    "autoload": { 
     "classmap": [ 
      "app/commands", 
      "app/controllers", 
      "app/models", 
      "app/database/migrations", 
      "app/database/seeds", 
      "app/tests/TestCase.php" 
     ], 
     "psr-4": { 
      "Larabook\\":"app/Larabook" 
     } 
    }, 
    "scripts": { 
     "post-install-cmd": [ 
      "php artisan clear-compiled", 
      "php artisan optimize" 
     ], 
     "post-update-cmd": [ 
      "php artisan clear-compiled", 
      "php artisan optimize" 
     ], 
     "post-create-project-cmd": [ 
      "php artisan key:generate" 
     ] 
    }, 
    "config": { 
     "preferred-install": "dist" 
    }, 
    "minimum-stability": "stable", 
    "require-dev": { 
     "way/generators": "~2.0", 
     "codeception/codeception":"~2.0", 
     "laracasts/testdummy":"~1.0" 
    } 
} 

我不知道這段代碼有什麼問題,我嘗試了所有改變拼寫錯誤再次重新創建項目,但我卡在這裏,我不知道我在這裏錯過了什麼。 enter image description here

+0

你的'Larabook \ Forms \ RegistrationForm'類定義了什麼文件? – 2014-09-23 20:53:28

回答

1

你應該嘗試運行:

composer dump-autoload 

生成新類的地圖爲您的項目

2

我相信這是一個錯字錯誤,如果我是正確的。

RegistrationForm.php位置= Larabook \軟件\表單,讓命名空間應該是

namespace Larabook\App\Forms;

+0

不管是那個還是'​​namespace App \ Forms;'取決於他如何設置作曲家。 – Marwelln 2014-09-23 20:07:44

0

使用namespace Larabook\App\Forms;

或在文件app>Larabook>Forms>RegistrationForm.php內定義larabook,然後只需使用namespace Larabook\Forms;

不要忘記使用composer dump-autoload -o,其中-o用於優化。

相關問題