I'm currently upgrading a custom CMS from Laravel 3 to Laravel 4 (this upgrade is important for various reasons).
In the existing version, it has routing set up so that routes can be individually defined--but if someone tries to load a route that is not specifically defined, the system catches it and sends it to a "page processor"--which essentially checks to see if the CMS page/post exists in the database.
The "fallback" or "default" route processing line in Laravel 3 looked like this:
Route::get('(.*)', array('uses' => 'myPageLoading@method'));
My problem is that this syntax is not supported in Laravel 4. How do I do this in Laravel 4?
Using the Route::fallback method, you may define a route that will be executed when no other route matches the incoming request. Since you may define the fallback route within your routes/web. php file, all middleware in the web midddleware group will apply to the route.
The Default Route Files All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.
Now that you are familiar with the purpose of a Router, you will now learn about the Fallback Route which is a route a bundle passes through only when it cannot pass through any other route within a scenario hence the name fallback.
Got it.
Laravel 4 Syntax:
Route::any('{all}', array('uses' => 'myPageLoading@method'))->where('all', '.*');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With