I may be lost here. Why don't you run php artisan route:clear on the production server while you are testing. Then when you are finished, turn the cache back on php artisan route:cache
Change route file depending on cookie
Hi,
We are in the middle of a redesign / rewrite and we want to deploy changes that are not visible in production. So we can see and test the new features in production by just putting a cookie in the browser. Building an entirely new project was rejected and changing the code in a branch and then merging it after months would be a nightmare of conflicts.
Wat we've tried: The first approach was adding laravel pennant and created a feature flag in the AppServiceProvider
public function boot(Request $request)
{
Feature::deactivate('new-site');
if ($request->hasCookie('new')) {
Feature::activate('new-site');
}
}
In the web.php we then check if the feature is on and load the appropriate routes. The feature flag comes correct in the web.php but when a route is loaded it is cached.
Then we added 2 route files. web.php and web-new.php And in the RouteServiceProvider added something like this
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path(Feature::active('new-site') ? 'routes/web.php' : 'routes/web-new.php'));
}
Cached again...
Then we created a middleware but again it didn't worked. I think we can't bypass this limitation unless i'm missing something. We don't want to cache the routes because it depends in the cookie each time, but i understand why it is the way it is.
Is there any other way to achieve what we want? I don't think its a good idea to check the feature in the controller but to load a different controller. That way we could keep only what we want and throw away junk. Also we want the old site to work until we flip the switch.
Thanks
Please or to participate in this conversation.