Container.php第749行的ReflectionException

时间:2019-05-27 06:23:29

标签: laravel laravel-5

我刚刚安装了一个基于Laravel的应用程序,该应用程序似乎可以在其中的某些页面上工作,但是许多其他页面都会抛出错误,从而使访问设置或配置文件变得完全不可能。我已经看到网上有很多解决方案,例如检查写入权限等。但是,目前似乎没有任何解决方案对我有用,因此,一定会得到一些专家帮助。

这是我的错误:

    ReflectionException in Container.php line 749:
    Class App\Http\Controllers\UserController does not exist
    in Container.php line 749
    at ReflectionClass->__construct('App\Http\Controllers\UserController') in Container.php line 749
    at Container->build('App\Http\Controllers\UserController', array()) in Container.php line 644
    at Container->make('App\Http\Controllers\UserController', array()) in Application.php line 709
    at Application->make('App\Http\Controllers\UserController') in Route.php line 203
    at Route->getController() in Route.php line 316
    at Route->controllerMiddleware() in Route.php line 278
    at Route->gatherMiddleware() in Router.php line 666
    at Router->gatherRouteMiddleware(object(Route)) in Router.php line 646
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 629
    at Router->dispatchToRoute(object(Request)) in Router.php line 607
    at Router->dispatch(object(Request)) in Kernel.php line 268
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
    at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
    at Pipeline->then(object(Closure)) in Kernel.php line 150
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
    at Kernel->handle(object(Request)) in index.php line 53

这是UserController:

    <?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;
    use Illuminate\Support\Facades\Auth;
    use App\User;
    use App\Contact;
    use Storage;
    use File;

    class Usercontroller extends Controller
    {
        //

        private $rules = [

                'name' => ['required' , 'min:5'],
                'email' => ['required' , 'email'],

                'photo'=>   ['mimes:jpg,jpeg,png,gif,bmp']


            ];
            private $upload_dir = 'public/uploads' ;

            public function __construct()
            {
                $this->middleware('auth');
                $this->upload_dir = base_path() .'/'. $this->upload_dir;

            }


        private function getRequest(Request $request)
        {

            $data = $request->all();
            if($request->hasFile('photo'))
            {

            $photo       = $request->file('photo');
            $filename    ="laravel-contact-".time()."-".uniqid()."-".$photo->getClientOriginalName();
            Storage::put($filename, File::get($photo->getRealPath()));

            $data = $request->all();
            $data ['photo'] = $filename;

            }

            return $data;
        }


            public function profile()
            {
            //return view('user.profile', ['user' => User::findOrFail($id)]);
            $id = Auth::id();

            $user = User::findOrFail($id);
            //$this->authorize('modify',$contact);
            return view('user.profile',compact('user'));    
            }

        public function show($id)
            {
            //return view('user.profile', ['user' => User::findOrFail($id)]);

            $user = Contact::findOrFail($id);
            //$this->authorize('modify',$contact);
            return view('user.index',compact('user'));  
            }


        public function update(Request $request)
        {

            $this->validate($request,$this->rules);
            $data = $this->getRequest($request);

            $id = Auth::id();

            $user = User::findOrFail($id);
            $user->update($data);
            $oldPhoto = $user->photo;

            if ($oldPhoto !== $user->photo){
                $this->removePhoto($oldPhoto);
            }
            return redirect('profile/settings')->with('message','profile updated');

        }





     public function password()
        {
            return view('user.password');
        }

    public function resetPassword(Request $request)
    {
            $this->validate($request, [
                'password' => 'required|confirmed|min:6',
            ]);

            $user = $request->user();
            $user->password = bcrypt($request->get('password'));
            $user->save();
            $id = Auth::id();

            $user = User::findOrFail($id);

            return view('user.index',compact('user'));  

    }

        public function removePhoto($photo)
        {

            if (! empty($photo))
            {
            $path = storage_path('app/public/images/' . $photo);

             if (File::exists($path)) {
                File::Delete($path);
            }
        }





        }



    }

这是我的.env文件(我检查其中是否包含空格):

    APP_ENV=local
    APP_KEY=base64:hcoymkbh8WxkAuetCUOPI3TJ30DrjVzkvNBOigjwopw=
    APP_DEBUG=true
    APP_LOG_LEVEL=debug
    APP_URL=http://myurl.com

    DB_CONNECTION=mysql
    DB_HOST=localhost
    DB_PORT=3306
    DB_DATABASE=xxxx
    DB_USERNAME=xxxx
    DB_PASSWORD=xxxx

    BROADCAST_DRIVER=log
    CACHE_DRIVER=file
    SESSION_DRIVER=file
    QUEUE_DRIVER=sync

    REDIS_HOST=127.0.0.1
    REDIS_PASSWORD=null
    REDIS_PORT=6379

    MAIL_DRIVER=smtp
    MAIL_HOST=mailtrap.io
    MAIL_PORT=2525
    MAIL_USERNAME=null
    MAIL_PASSWORD=null
    MAIL_ENCRYPTION=null

    PUSHER_APP_ID=
    PUSHER_KEY=
    PUSHER_SECRET=

最后但并非最不重要的是,该项目的我的nginx配置文件:

    server {
        listen 80;
        server_name myurl.com;
        root /var/www/html/public;

        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
        add_header X-Content-Type-Options "nosniff";

        index index.html index.htm index.php;

        charset utf-8;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }

        error_page 404 /index.php;

        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
            include fastcgi_params;
        }

        location ~ /\.(?!well-known).* {
            deny all;
        }
    }

我们将不胜感激一些专家的见解,非常感谢

0 个答案:

没有答案