Run Composer in the container
$ grim composer require league/csv
A project needs a PHP library that is not a module: a CSV reader, an SDK, a dev tool. Installing it with the Composer on your machine resolves it against your machine's PHP and extensions, not the app's. grim composer runs Composer in the app container, so what it resolves is what the app can load.
It is for plain PHP packages. Modules and themes are not Composer's business: grim require adds them and grim update moves them.
Usage
$ grim composer require league/csv # add a library
$ grim composer -- require phpunit/phpunit --dev
$ grim composer dump-autoload # rebuild the autoloader
$ grim composer -- show --outdated # options go after a double dashRun it from the project directory, with the stack up.
Arguments and options
Run composer command in app container
Usage
grim composer [<cmd>...]Arguments
| Argument | Description |
|---|---|
cmd |
Composer command and arguments (optional, repeatable) |
What it actually does
It runs docker compose exec app composer followed by what you typed, with your terminal attached, so Composer can ask its questions. Output and exit code are Composer's own. composer.json, composer.lock and vendor/ change in the project directory, because it is mounted into the container.
Pitfalls
An option without -- never reaches Composer
grim reads the command line first. An option it does not know, such as --dev, is dropped without a word, together with everything typed after it. grim composer require phpunit/phpunit --dev installs the package as a regular dependency. Put a double dash first: grim composer -- require phpunit/phpunit --dev.
The stack has to be up
The command enters a running container. service "app" is not running means there is none; run grim up. On a fresh clone that same grim up installs the dependencies by itself, so there is no need to run install by hand.
After it finishes
Commit composer.json and composer.lock together. Colleagues get the package with their next grim composer install.
Related spells
grim artisan
Run artisan in the container
Run an artisan command inside the app container, where the app's PHP, extensions and environment are.
grim shell
Step inside a container
Open an interactive bash session in the app container, or in another service of the local stack.
grim require
Summon a module or theme
Add a module or theme to grim.json, install it with everything it depends on, and rewrite grim.lock, all inside the train the project is on.
grim install
Assemble the whole project
Turn grim.json into a working project by fetching core, every module and theme, writing grim.lock, building the image and starting the stack.
grim update
Board the newest train
Move core, every module and every theme onto the newest release train grim.json allows, or a single module within the train it is on.