Hi all,
My name is Aasawari, and I am creating a Laravel Starter kit for MongoDB which will help you create Laravel applications with MongoDB.
However, I am stuck at one point which I wanted to seek suggestions for.
As a part of creating applications with MongoDB, the extensions should be installed as a prerequisite, and I wanted to perform pecl install mongodb before I created the project. Is there a way I could integrate that within the package?
#Looking for help to create a Starter kit for MongoDB
8 messages · Page 1 of 1 (latest)
I cant think a way to do that. But eventually the user will end up with a missing extension error
The common way to do this is to require ext-mongodb in the starter kit's composer.json.
Then composer will throw an error if the user doesn't have the extension.
I would not recommend running pecl install automatically. It's the user's own responsibility.
Ensuring environment compatibility isn't the task of a starter kit imho. As mono said, add the extension requirement to the composer.json, that's all you'd need to do.
For example, the React/Vue starter kits use npm and Vite, which also have a requirement of having node installed, even a minimal version of node. Similar to if you'd make a starter kit that uses Redis as a default cache, then the user would need to install the Redis extension, the user would need to have a Redis server available.
There are definitely legitimate reasons for including a post-install-cmd script in composer.json, but I find it kind of scary. I haven't heard of any packages that include malicious (or stupid) scripts, but it's probably just a matter of time.
Well, post-install has quite a different use-case. If the extension isn't installed, you can't install composer requirements (also assuming they're using the laravel MongoDB package, as that does have a requirement of its own). Post install scripts should be used to set up the project, such as generating an app key, not modify the environment they're running on
Containerize it
It's a starter kit. It has to work in whatever environment the user has chosen.