Run artisan in the container
$ grim artisan migrate
Migrations, a tinker session, a cache to clear, a generator to run. Artisan belongs to the app, and the app lives in a container: the PHP on your machine may be another version, lacks the extensions, and cannot resolve the hostnames in .env. grim artisan runs the command where it works, without you opening a shell first.
Usage
$ grim artisan migrate # a plain command
$ grim artisan tinker # interactive ones work too
$ grim artisan -- migrate --seed # options go after a double dash
$ grim artisan # artisan's own list of commandsRun it from the project directory, with the stack up.
Arguments and options
Run artisan command in app container
Usage
grim artisan [<cmd>...]Arguments
| Argument | Description |
|---|---|
cmd |
Artisan command and arguments (optional, repeatable) |
What it actually does
It runs docker compose exec app php artisan followed by what you typed, with your terminal attached, so prompts, tinker and coloured output behave as they do natively. The output is artisan's, and so is the exit code, which makes it usable in a script.
Pitfalls
An option without -- never reaches artisan
grim reads the command line first. An option it does not know, such as --seed, is dropped without a word, together with everything typed after it. grim artisan migrate --seed runs a plain migrate and says nothing. Put a double dash in front and the rest passes through untouched: grim artisan -- migrate --seed.
-v, -q and -n are taken by grim
Verbosity, quiet and no-interaction flags exist on grim itself, so without the double dash they change grim's behaviour and artisan never sees them. --help prints this command's help, not artisan's. The same remedy applies: grim artisan -- migrate:status -v.
The stack has to be up
service "app" is not running comes from Docker. Run grim up first.
After it finishes
Nothing is left behind by grim. Files that artisan generates, a migration or a model, appear in the project directory, because it is mounted into the container.
On a deployed app the counterpart is grim remote:artisan.
Related spells
grim composer
Run Composer in the container
Run Composer inside the app container, against the PHP version and extensions the app really runs on.
grim shell
Step inside a container
Open an interactive bash session in the app container, or in another service of the local stack.
grim test
Run the test suite
Run the project's tests in the app container against a separate test database that grim creates and migrates for you.
grim remote:artisan
Run artisan on the server
Run one artisan command inside the app container of the deployed project, from your own terminal.
grim user
Create an admin user
Create an administrator account in the app, on your machine or on a deployed server, and print the password once.