Laravel Role Permission Setup Command Slow – Problem & Solution (2026 Guide)
Agar aap Laravel project me Role & Permission system setup kar rahe hain aur artisan command slow chal rahi hai, to yeh common problem hai. Bahut developers yeh issue face karte hain, especially jab wo Spatie Role & Permission package use karte hain.
Is article me hum detail me samjhenge ki command slow kyu hoti hai aur uska complete solution kya hai.
Problem Kya Hoti Hai?
Jab aap yeh commands run karte ho:
php artisan migrate
php artisan permission:cache-reset
php artisan db:seed
To:
Command bahut slow chalti hai
Kabhi hang ho jati hai
CPU usage high ho jata hai
Server response slow ho jata hai
Main Reasons
Cache issue
Database me zyada records
Shared hosting performance issue
APP_DEBUG true hona
Composer autoload optimize na hona
Step-by-Step Solution
Step 1: Cache Clear Kare
php artisan optimize:clear
Step 2: Config & Cache Clear Kare
php artisan config:clear
php artisan cache:clear
Step 3: Composer Optimize Kare
composer dump-autoload -o
Step 4: .env File Check Kare
Ensure kare:
APP_DEBUG=false
Step 5: Database Optimize Kare
Ensure kare ki yeh columns indexed ho:
role_id
permission_id
model_id
Indexes hone se queries fast chalti hain.
Step 6: Production Optimization Commands Run Kare
php artisan config:cache
php artisan route:cache
php artisan view:cache