Add a cache-clear dev console command; document dev console commands

This commit is contained in:
Christopher C. Wells 2021-11-10 14:58:06 -08:00
parent f17fb757ef
commit c42cfdb531
2 changed files with 43 additions and 6 deletions

View File

@ -508,6 +508,25 @@ Navigate to [http://127.0.0.1:8080](http://127.0.0.1:8080) to log in!
Create a `docker-compose.override.yml` file to override any of the default settings
provided for this environment.
### Custom console commands
#### `dev:cache-clear`
Executes the various cache clearing artisan commands:
- `cache:clear`
- `config:clear`
- `route:clear`
- `view:clear`
#### `dev:reset`
Resets and seeds the database by executing the following artisan commands:
- `db:wipe`
- `migrate`
- `db:seed`
### Testing
Ensure that Sail is running (primarily to provide ElasticSearch):

View File

@ -15,18 +15,36 @@ use Illuminate\Support\Facades\Artisan;
*/
if (!App::isProduction()) {
/**
* Clear all caches.
*/
Artisan::command('dev:cache-clear', function () {
/** @phpstan-ignore-next-line */
assert($this instanceof ClosureCommand);
$commands = [
'cache:clear',
'config:clear',
'route:clear',
'view:clear',
];
foreach ($commands as $command) {
Artisan::call($command);
$this->info(trim(Artisan::output()));
}
$this->info('All caches cleared!');
})->purpose('Clear all caches.');
/**
* Wipe, migrate, and seed the database.
*/
Artisan::command('dev:reset', function () {
/** @phpstan-ignore-next-line */
assert($this instanceof ClosureCommand);
Artisan::call('db:wipe');
$this->info(Artisan::output());
Artisan::call('migrate');
$this->info(Artisan::output());
Artisan::call('db:seed');
$this->info(Artisan::output());
$commands = ['db:wipe', 'migrate', 'db:seed'];
foreach ($commands as $command) {
Artisan::call($command);
$this->info(trim(Artisan::output()));
}
$this->info('Database reset complete!');
})->purpose('Wipe, migrate, and seed the database.');
}