PHP code example of nikolawd / laravel-route-disabling
1. Go to this page and download the library: Download nikolawd/laravel-route-disabling library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nikolawd / laravel-route-disabling example snippets
Route::get('/users', [UserController::class, 'index'])->disabled();
// Returns Laravel's default 503 error page with message: "This route is temporarily disabled."
Route::get('/users', [UserController::class, 'index'])
->disabled('User management is under maintenance');
// Returns Laravel's 503 error page with your custom message
Route::get('/christmas-sale', [SaleController::class, 'christmas'])
->disabled(function ($request) {
$now = now();
if ($now->between('2025-12-24', '2025-12-26')) {
return null; // Enable during Christmas
}
return 'Christmas sale is only available December 24-26';
});
Route::post('/trading/execute', [TradingController::class, 'execute'])
->disabled(function ($request) {
if (now()->isWeekend() || now()->hour < 9 || now()->hour >= 17) {
return response()->json([
'message' => 'Trading is only available 9 AM - 5 PM on weekdays',
], 503);
}
return null; // Enable during business hours
});
Route::get('/new-feature', [FeatureController::class, 'index'])
->disabled(function ($request) {
// Enable for 20% of users based on user ID
if (($request->user()->id % 5) === 0) {
return null;
}
return 'New feature coming soon!';
});
Route::post('/problematic-endpoint', [ProblematicController::class, 'store'])
->disabled('This endpoint is temporarily disabled due to a known issue');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.