cms icon indicating copy to clipboard operation
cms copied to clipboard

Adds the craft cli as a composer bin file

Open markhuot opened this issue 3 years ago • 4 comments

There are some times (specifically during plugin development) where I don't need the full craftcms/craft setup and all I really need is the Craft CLI so I can run a queue or execute a one-off task. Adding the bin to composer.json ships the CLI with the craftcms/cms dev so dependent projects can easily run Craft via ./vendor/bin/craft install, for example.

With the new Craft 4 ENV changes, too, I don't even need any config/ dir or anything like that.

After this change it is possible (in a new directory) to do something like this and have a full Craft CLI running.

$ composer require craftcms/cms
$ CRAFT_DB_NAME=craft ./vendor/bin/craft install

Optionally, you could explore shortening the craftcms/craft CLI even more and just pointing to this in the vendor directory.

This is a proof of concept and for your consideration. There are probably downsides (but I can't think of them) and other changes that must be made before this merges in. Just something I was working on and found helpful of late.

markhuot avatar Aug 18 '22 19:08 markhuot

{
    "config": {
        "bin-dir": "./"
    }
}

...would put craft (and any other binaries) in the project root, too

khalwat avatar Aug 20 '22 00:08 khalwat

Baby steps. bin-dir seems a bit heavy handed to me, personally.

Whatever the outcome—being able to run ./craft without cloning down all of craftcms/craft would be a very welcome addition.

markhuot avatar Aug 22 '22 14:08 markhuot

Also, you can do composer exec craft and it'll run it... no need to specify the kind of annoying to type ./vendor/bin/craft

(just putting this here as a hint to others)

khalwat avatar Aug 22 '22 18:08 khalwat

Yup, composer exec craft is 😈 (devilishly awesome)

markhuot avatar Aug 22 '22 18:08 markhuot