Collection of handy Laravel artisan commands that most projects needs
Installs: 13 664
Open Issues: 7
- php: ^7.3|^8.0
- laravel/framework: 8.*
- orchestra/database: 6.*
- orchestra/testbench: 6.*
- phpunit/phpunit: ^9.3.3
Collection of handy Laravel
artisan commands that most projects needs
artisan commands that may find place in most of the Laravel projects regardless of the project type.
How often you wanted to perform some basic tasks like create or drop database, dump database or load from
.sql dump, or to see which fields (and field types) are present in your models? Continue reading and I promise to easy this, and many more tasks to you 🍻
The package is compatible with Laravel versions
Because some commands rely on raw console commands (like
mysqldump), currently only MySql database and Linux environments are supported. Package is designed to easily support multiple OS-es and database types, and it should be easy implementation, so if anyone is interested to help, please feel free to contribute.
Install the package via composer:
If your're using Laravel 8, run:
composer require vkovic/laravel-commando
If your're using Laravel prior version 8, run:
composer require vkovic/laravel-commando "^0.1"
Package is in early stage so there is limited number of commands. I'm planning to add more, so if you have some suggestion you can require feature via issues page (click on
Issues -> New issue -> Feature request)
- model:list ~ List all application
Modelsand related info
- model:fields ~ Show single
Modeland useful info
- db:exist ~ Check for database existance
- db:create ~ Create database
- db:drop ~ Easily drop default or another db
- db:dump ~ Dump database to
- db:import-dump ~ Import db from exported
- db:summon ~ create/drop | migrate | seed
php artisan model:list
Show all models and some basic info.
- Model (model class)
- Table (table used by the model)
- Table count (count of all records in the model related table)
- Scope count (count of records with all scopes applied:
$n = SomeModel::count()
- Soft deleted (show how many soft deleted items model have)
php artisan model:fields <model>
Show model fields info.
- Field (model field / table column)
- Type (db field type)
- Nullable (db value can be null)
- Default (default db value)
- Casts (attribute muttators)
- Guarded (field is not mass assignable)
- Fillable (field is mass assignable)
modeloptional: Model to show fields from (e.g.
"App\User"). If omitted, list of all models will be shown to choose from.
php artisan db:exist <database>
Check if database exists
databaseoptional: Database name to check. If omitted it'll check for default db (defined in
php artisan db:create <database>
databaseoptional: Database to create. If omitted, name from
.envwill be used.
php artisan db:drop <database>
databaseoptional: Database to drop. If omitted, name from
.envwill be used
php artisan db:dump <database> <--dir>
Dump database to
databaseoptional: Database to dump. If omitted, name from
.envwill be used.
--dir: Directory for dump creation. If omitted default filesystem dir will be used.
php artisan db:import-dump <database> <--dir>
Import dump from
databaseoptional: Database to import dump to. If omitted, name from
.envwill be used.
--dir: Directory for dump lookup. If omitted default filesystem dir will be used.
php artisan db:summon
Drop default database, than perform migrate followed with the seed.
Useful in early stages of development when we changing models (migrations and seeds) a lot.
If you plan to modify this Laravel package you should run tests that comes with it.
Easiest way to accomplish this would be with
First, we need to initialize Docker containers (see
docker-composer.yaml for details).
docker-compose up --exit-code-from app
After that, we can run tests and watch the output:
docker-compose run --rm app phpunit