Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ycsm's avatar
Level 1

Laravel Forge failure to install repo

I've tried to install a repository but keep getting the following message

"Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: NO)"

This has happened for 3 different repositories, one of which has worked previously.

Support got back to me and said "It sounds like you have a Artisan command or Service Provider that is calling your database on every command. That should be fixed before installing the repository." - but I really am not sure what they mean/it could be?

0 likes
5 replies
bugsysha's avatar

Have you added any code to boot or register methods in files in app/Providers folder? If it is not a problem post the code from those files here and someone will tell you what is causing that issue.

ycsm's avatar
Level 1

Aha... I have added the following code to these:

AuthSP:

    public function boot()
    {
        $this->registerPolicies();

        // Implicitly grant "Super Admin" role all permissions
        // This works in the app by using gate-related functions like auth()->user->can() and @can()
        Gate::before(function ($user, $ability){
            return $user->hasRole('Super Admin') ? true : null;
        });

        //Superadmin check
        Gate::define('isSuperAdmin', function($user){
            return $user->hasRole('Super Admin');
        });

        //PLT Student check
        Gate::define('isPLTStudent', function($user){
            return $user->hasRole('PLT Student');
        });

        //Student check
        Gate::define('isStudent', function($user){
            return $user->hasRole('Student');
        });

        //Logged in?
        Gate::define('logged-in', function($user){
            return Auth::user();
        });

        //SEE Admin Panel
        Gate::define('SEE-admin-panel', function($user){
            return $user->hasAnyRoles(['PLT Student']);
        });

        //SEE Admin Dashboard
        Gate::define('SEE-admin-dashboard', function($user){
            return $user->hasAnyRoles(['PLT Student']);
        });

        //USERS PERMISSIONS

            //Overall
            Gate::define('USERS-manage-users', function($user){
                return $user->hasAnyRoles(['PLT Student']);
            });

            //Specific
            Gate::define('USERS-create-users', function($user){
                return $user->hasRole('PLT Student');
            });
            Gate::define('USERS-view-users', function($user){
                return $user->hasRole('PLT Student');
            });
            Gate::define('USERS-edit-users', function($user){
                return $user->hasRole('PLT Student');
            });
            Gate::define('USERS-delete-users', function($user){
                return $user->hasRole('PLT Student');
            });

        //RUNS PERMISSIONS

        //Overall
        Gate::define('RUNS-manage-runs', function($user){
            return $user->hasAnyRoles(['PLT Student']);
        });

        //Specific
        Gate::define('RUNS-create-runs', function($user){
            return $user->hasRole('PLT Student');
        });
        Gate::define('RUNS-view-runs', function($user){
            return $user->hasAnyRoles(['PLT Student', 'Student']);
        });
        Gate::define('RUNS-edit-runs', function($user){
            return $user->hasRole('PLT Student');
        });
        Gate::define('RUNS-delete-runs', function($user){
            return $user->hasRole('PLT Student');
        });
        Gate::define('RUNS-delete-runs', function($user){
            return $user->hasRole('PLT Student');
        });

    //RUNTYPES PERMISSIONS

        //Overall
        Gate::define('RUNTYPES-manage', function($user){
            //return $user->hasAnyRoles(['PLT Student']);
        });

        //Overall
        Gate::define('RUNTYPES-view', function($user){
            return $user->hasAnyRoles(['PLT Student', 'Student']);
        });

    //RUNTYPES PERMISSIONS

        //Overall
        Gate::define('GROUP-manage', function($user){
            //return $user->hasAnyRoles(['PLT Student']);
        });
    }

AppSP:

    public function boot()
    {
        View::share('run_types', RunType::orderBy('name')->get()); //share with all
    }
bugsysha's avatar
bugsysha
Best Answer
Level 61

Yeah. Those are the ones that give you trouble.

Easiest way is to comment them. Deploy. Then uncomment.

ycsm's avatar
Level 1

Right, so I've pulled from the repo (without composer install), sorted out ENV file, then run composer.. I get a different message

> @php artisan package:discover --ansi

In ProviderRepository.php line 208:
                                                            
  Class 'App\Providers\TelescopeServiceProvider' not found  

I used telescope a while back but removed it. I've used PHPStorm to search all files in my app folder and see no reference to telescope at all...

ycsm's avatar
Level 1

Please ignore above comment, I found a reference to it in app.php :)

Please or to participate in this conversation.