penguinfeet
4 years ago
177
7
Laravel

Class 'App\Http\Controllers\User' not found' in /home/vagrant/code/vidvalize/app/Http/Controllers/UserController.php

Posted 4 years ago by penguinfeet

I have the following Controller (UserController). I have a "store" function that I am using:

<?php namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request; 
//use Illuminate\Routing\Controller;

class UserController extends Controller {

    /**
     * Store user info.
     *
     * 
     * @return Response
     */
    public function store(Request $request) {

        //$v = User::validate(Input::all());

        $email = $request->input('email');;

        //if ( $v->passes() ) {  

            $user = new User;
            $user->email = $email;
            $user->save();

        //}

        return $email;

    }

}

However, when I run this, I get the following error (specifically in complaint of this line: $user = new User; :

[2015-07-06 19:50:56] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'App\Http\Controllers\User' not found' in /home/vagrant/code/vidvalize/app/Http/Controllers/UserController.php:23
Stack trace:
#0 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(127): Symfony\Component\Debug\Exception\FatalErrorException->__construct()
#1 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(112): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError()
#2 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(0): Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#3 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(255): App\Http\Controllers\UserController->store()
#4 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(255): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:255}()
#5 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(163): Illuminate\Routing\Controller->callAction()
#6 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(111): Illuminate\Routing\ControllerDispatcher->call()
#7 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}()
#8 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:139}()
#9 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#10 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}()
#11 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(113): Illuminate\Pipeline\Pipeline->then()
#12 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack()
#13 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Route.php(200): Illuminate\Routing\ControllerDispatcher->dispatch()
#14 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Route.php(133): Illuminate\Routing\Route->runWithCustomDispatcher()
#15 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Router.php(702): Illuminate\Routing\Route->run()
#16 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#17 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:139}()
#18 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#19 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}()
#20 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Router.php(704): Illuminate\Pipeline\Pipeline->then()
#21 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Router.php(669): Illuminate\Routing\Router->runRouteWithinStack()
#22 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Routing/Router.php(629): Illuminate\Routing\Router->dispatchToRoute()
#23 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(229): Illuminate\Routing\Router->dispatch()
#24 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#25 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:139}()
#26 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#27 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#28 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#29 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(54): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#30 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#31 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#32 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(61): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#33 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Session\Middleware\StartSession->handle()
#34 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#35 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#36 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#37 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#38 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#39 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#40 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#41 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(42): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#42 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#43 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:124}()
#44 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#45 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): call_user_func:{/home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103}()
#46 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(118): Illuminate\Pipeline\Pipeline->then()
#47 /home/vagrant/code/vidvalize/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(86): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#48 /home/vagrant/code/vidvalize/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle()
#49 /home/vagrant/code/vidvalize/public/index.php(0): {main}()
#50 {main}  

What is happening here? Why isn't this working?

Please sign in or create an account to participate in this conversation.