I recently started working on an environment cleanup feature. The goal was very simple: erase data from and databases. Usually as per customer request, a copy of their database had been made somewhere and never removed. Dev Stage I can’t tell if it’s a silly childish fear or a real concern, but I was afraid that someone would end up opening two tabs (production and dev) and mistakenly use the feature in the wrong tab. Have you read the recent incident at GitLab? : I developed a feature that will not be available on production and this is how I did it: Long story short 1- The RouteServiceProvider Inside of , let’s register a new type of route if we’re not on production. map RouteServiceProvider (!$this->app->environment('production'))$this->mapDevelopmentRoutes(); if Next, define rules for this new type of route, such as filename, controllers namespace and prefix. _void*/_ mapDevelopmentRoutes() {Route:: (['web', 'auth'])->namespace($this->namespace . '\Development')->as('development.')->prefix('development')->group(base_path('routes/development.php'));} /*** Define the "development" routes for the application.** These routes all receive "web" middleware.** @return protected function middleware 2- The routes/development.php file Not much to say here besides showing a real-case example. This is what I registered. **<?php use** Illuminate\Support\Facades\Route; // These routes should only be available for development environment. RouteServiceProvider will make sure to only register these// in case the environment is not production. Route:: ('/redactor', 'RedactorController@index')->name('redactor.index');Route:: ('/redactor', 'RedactorController@redact')->name('redactor.redact'); get patch 3- [Optional] The ViewComposer I have a file that builds the menu items for the user. I decided to leverage to tell this component whether to show the dev-only features. menu.blade.php Laravel View Composers ($development) && $development**)** <li><a href="{{route('development.redactor.index')}}"><i class="fa fa-eraser fa-fw"></i>{{ __('Redactor') }}<span class="pull-right text-muted" title="{{ __('Available for Dev only') }}"><i class="fa fa-warning fa-fw"></i></span></a></li> @if(isset @endif The file just sets to DevelopmentComposer development true **<?php namespace** App\Http\ViewComposers; Illuminate\View\View; use DevelopmentComposer TenantComposer { class extends compose(View $view) { :: ($view); public function parent compose $view->with(\['development' => **true**\]); }} And the will only registser the if the environment is not production as well ComposerServiceProvider DevelopmentComposer (!$this->app->environment('production'))View:: ('layouts.development.menu', 'App\Http\ViewComposers\DevelopmentComposer'); if composer And yes, this could be set inside together with the mapping of the routes, but I only realized this now (while writing this article) =) RouteServiceProvider Conclusion Last week I was redacting about 20 databases and halfway through the task I had a mini heart attack thinking whether I was in production or dev. Then I remembered that I had made sure this would never be a problem. Happy ending. is how hackers start their afternoons. We’re a part of the family. We are now and happy to opportunities. Hacker Noon @AMI accepting submissions discuss advertising & sponsorship To learn more, , , or simply, read our about page like/message us on Facebook tweet/DM @HackerNoon. If you enjoyed this story, we recommend reading our and . Until next time, don’t take the realities of the world for granted! latest tech stories trending tech stories