简体   繁体   English

ReflectionException类UserController不存在Laravel5.4

[英]ReflectionException Class UserController does not exist Laravel5.4

Everytime i hit the Submit Button i got this problem ReflectionException Class UserController does not exist 每次我按下Submit按钮时,我都会遇到此问题ReflectionException类UserController不存在

 <?php
 namespace app\Http\Controllers;
  use App\User;
  use Illuminate\Http\Request;




   class UserController extends Controller {

   public function postSignUp(Request $request)
        {
       $email = $request['email'];
        $first_name = $request['first_name'];
        $password = bcrypt($request['password']);
        $user = new User();
         $user->email =$email;
         $user->first_name=$first_name;
          $user->password = $password;
           $user->save();

            return redirect()->back();

                   }

               public function postSignIn(Request $request)
                   {

                       }
                       }

My route file: 我的路线文件:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;


class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //

        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapApiRoutes();

        $this->mapWebRoutes();

        //
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
       Route::middleware('web')
             ->namespace($this->namespace)
             ->group(base_path('routes/web.php'));


        Route::post('/signup',[
            'uses'=>'UserController@postSignUp',
            'as'=>'signup'
        ]);



    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
             ->middleware('api')
             ->namespace($this->namespace)
             ->group(base_path('routes/api.php'));
    }
}

You use invalid namespace. 您使用无效的名称空间。 Instead of: 代替:

namespace app\Http\Controllers;

in your UserController you should use: 在您的UserController中,您应该使用:

namespace App\Http\Controllers;
 namespace App\Http\Controllers;
 use Illuminate\Http\Request; 

Use namespace like that and try command php artisan route:cache 使用这样的namespace ,然后尝试命令php artisan route:cache

and php artisan route:clear php artisan route:clear

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel | ReflectionException-类不存在 - Laravel | ReflectionException - Class does not exist 目标 class [UserController] 不存在 Laravel 8 - Target class [UserController] does not exist Laravel 8 Laravel 5.4:Container.php第749行中的ReflectionException:类App \\ Http \\ Controllers \\ Admin \\ ImageGalleryController不存在 - Laravel 5.4 : ReflectionException in Container.php line 749: Class App\Http\Controllers\Admin\ImageGalleryController does not exist ReflectionException: Class ClassName 不存在 - Laravel - ReflectionException: Class ClassName does not exist - Laravel laravel ReflectionException类国家/地区不存在 - laravel ReflectionException Class Country does not exist ReflectionException (-1) Class VoyagerAuth 不存在 - Laravel - ReflectionException (-1) Class VoyagerAuth does not exist - Laravel ReflectionException - 中间件类不存在Laravel 5.5 - ReflectionException - Middleware class does not exist Laravel 5.5 Laravel 4-控制器ReflectionException类/不存在 - Laravel 4 - controller ReflectionException Class / does not exist ReflectionException - 类 DatabaseSeeder 不存在,Laravel Seeder - ReflectionException - Class DatabaseSeeder does not exist , Laravel Seeder ReflectionException-Laravel 5.0中不存在类名 - ReflectionException - Class name does not exist in Laravel 5.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM