How to remove Auth in Laravel (PHP artisan)
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Title: Effortlessly Removing or Reinitializing Auth in Laravel (PHP artisan)
Body:
The Laravel framework has made life easier for developers by providing a robust authentications system using the php artisan make:auth command. However, there are instances where you might need to remove or reinitialize this functionality. In this comprehensive blog post, we'll explore the various options available and provide detailed steps on how to achieve your desired outcome.
Removing Auth in Laravel (PHP artisan)
If you need to completely remove the authentication system from your project, follow these steps:
Delete all files created by the
php artisan make:authcommand. You can find them under app/Http/Controllers/{AuthController}, resources/views/auth, app/Console/Kernel.php, database/migrations/{TableUp/Down} or any other related folders and files.Update your
composer.jsonfile to remove the required packages. Check for lines containing 'laravel/ui', 'spatie/laravel-permission' and 'intervention/image'. Remove these lines along with their respective dependencies if needed. Runcomposer updateto update your project.In app/Http/Kernel.php, remove the middleware for Auth:Route::middleware('auth')->group(function () {}); and any other related middleware. Save the file.
Delete or comment out the
Auth::routes(); statement in routes/web.php to prevent the creation of auth-related routes.If you're using a specific database like MySQL, remove the created user and the corresponding table related to authentication. Use phpMyAdmin or a similar tool to delete these tables.
To ensure that the next time you run
php artisan make:auth, it creates everything afresh, update your.envfile by adding the lineAPP_DEBUG=true. This will cause Laravel to clear its cache and recompile all existing files.
Remember that after deleting or commenting out the code, you may need to adjust your application logic to handle authentication properly.
Reinitializing Auth in Laravel (PHP artisan)
If you want to start fresh with a new auth system or just reinitialize it for some reason, follow these steps:
Delete all files related to the existing auth system as described above.
Run
php artisan make:authagain in your Laravel project's root directory. This command will generate a new authentication setup, including controllers, views, database migrations, middleware, and routes.Update the application logic according to the newly generated files and folders, ensuring they align with your app's requirements.
Run
php artisan migrateorphp artisan migrate:freshto create the necessary database tables using your new migration files.Adjust any other configuration settings as required by the new auth system, such as password policies and email verification.
Conclusion
Removing or reinitializing auth in Laravel is a straightforward process if you understand the steps involved. By following these guidelines, you can ensure that your Laravel project works optimally with the desired authentication setup. For more resources on Laravel development and best practices, visit https://laravelcompany.com for helpful articles and tutorials.