src/Commands/RoutesCommand.php
public function fire()
    {
        $this->line('');
        $this->info('Routes file: app/routes.php');

        $message = 'This will rebuild routes.php with all of the packages that'
            . ' subscribe to the `toolbox.routes` event.';
        $this->comment($message);
        $this->line('');

        if ($this->confirm('Proceed with the rebuild? [Yes|no]')) {
            $this->line('');

            $this->info('Backing up routes.php ...');
            // Remove the last backup if it exists
            if (File::exists('app/routes.bak.php')) {
                File::delete('app/routes.bak.php');
            }

            // Back up the existing file
            if (File::exists('app/routes.php')) {
                File::move('app/routes.php', 'app/routes.bak.php');
            }

            // Generate new routes
            $this->info('Generating routes...');
            $routes = Event::fire('toolbox.routes');

            // Save new file
            $this->info('Saving new routes.php...');
            if ($routes && !empty($routes)) {
                $routes = $this->getHeader() . implode("\n", $routes);
                File::put('app/routes.php', $routes);
                $this->info('Process completed!');
            } else {
                $this->error('Nothing to save!');
            }

            // Done!
            $this->line('');
        }
    }
public function fire()
    {
        $this->line('');
        $this->info('Routes file: app/routes.php');

        $message = 'This will rebuild routes.php with all of the packages that'
            . ' subscribe to the `toolbox.routes` event.';
        $this->comment($message);
        $this->line('');

        if ($this->confirm('Proceed with the rebuild? [Yes|no]')) {
            $this->line('');

            $this->info('Backing up routes.php ...');
            // Remove the last backup if it exists
            if (File::exists('app/routes.bak.php')) {
                File::delete('app/routes.bak.php');
            }

            // Back up the existing file
            if (File::exists('app/routes.php')) {
                File::move('app/routes.php', 'app/routes.bak.php');
            }

            // Generate new routes
            $this->info('Generating routes...');
            $routes = Event::fire('toolbox.routes');

            // Save new file
            $this->info('Saving new routes.php...');
            if ($routes && !empty($routes)) {
                $routes = $this->getHeader() . implode("\n", $routes);
                File::put('app/routes.php', $routes);
                $this->info('Process completed!');
            } else {
                $this->error('Nothing to save!');
            }

            // Done!
            $this->line('');
        }
    }
Execute the console command.