0

View:make 関数を呼び出せません。このエラーが発生します:

 return View::make('fb-post.index',['users'=>$users]);

               Class 'App\Http\Controllers\View' not found

ルート

  Route::get('/', 'PostController@test');

コントローラ

public function test()
{
  $customers = 'test';

  return View::make('fb-post.index')->with('customers', $customers);

}

私のテンプレートファイルはview/fb-post/index.blade.phpにあります

私が電話しているとき

 php artisan dump-autoload

取得:

        exception 'InvalidArgumentException' with message 'Command "dump-autoload" is not defined.' in /var/www/html/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php:549
        Stack trace:
        #0 /var/www/html/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php(192): Symfony\Component\Console\Application->find('dump-autoload')
        #1 /var/www/html/laravel-test/vendor/symfony/console/Symfony/Component/Console/Application.php(126): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
        #2 /var/www/html/laravel-test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(91): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
        #3 /var/www/html/laravel-test/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
        #4 {main}

何か案は?

4

1 に答える 1

4

ファサードViewが現在の名前空間にありません。したがって、次のいずれかを先頭に追加します\

return \View::make('fb-post.index', ['users' => $users]);

または、これをコントローラーファイルの先頭に追加します。

use View;

また、取得しているエラーから、Laravel 5 を使用していると思います。その場合、viewヘルパー関数を使用できます。

return view('fb-post.index', ['users' => $users]);
于 2015-02-16T16:29:00.660 に答える