Last active
September 10, 2020 10:08
-
-
Save devmsh/2cdd2a9f8eba19271821f7bc55bbd5a1 to your computer and use it in GitHub Desktop.
Easily change laravel routes from strings to static class references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Easily change laravel routes from strings to static class references | |
1. Open your route file in your prefered IDE | |
2. Find and replace using regex | |
3. Find \'([A-Za-z]*)\@([A-Za-z]*)\' | |
4. Replace with [App\\Http\\Controllers\\$1::class,'$2'] | |
5. Find \'([A-Za-z]*Controller)\' | |
6. Replace with App\\Http\\Controllers\\$1::class | |
5. Done! | |
# Don't miss to: | |
1. Remove protected $namespace = 'App\Http\Controllers'; from your RouteServiceProvider | |
2. Remove the 'namespace' from your route groups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment