I want to add some actions for installing/updating/removing modules by composer, for example when anyone installs a module by composer, the installer creates a database and imports access information for RBAC to the database. in update process do new changes in database and more and same
I see I can use composer script like this
"scripts": {
"post-install-cmd": [
"php -r 'if (file_exists(\"bin/post-install.php\")) include \"bin/post-install.php\";'"
],
"post-update-cmd": [
"php -r 'if (file_exists(\"bin/post-update.php\")) include \"bin/post-update.php\";'"
],
"post-package-uninstall": [
"php -r 'if (file_exists(\"bin/post-remove.php\")) include \"bin/post-remove.php\";'"
]
},
I have some questions:
1- Do you have any plan to add features like this for managing modules in MVC?
2- What is the best practice?
3- In bin/post-install.php, I run PHP codes out of MVC, If I write installer service in my modules and want to call it in this PHP file, it’s very hard and I have to load most of my written class in the file. Does any shortcut or method available for doing it?
Sorry I was short of time when I replied earlier. As @froschdesign pointed out the cli loads like any other component so you have access to everything you will need. Ive only barely tested it but from the initial testing I did it will work exactly as you need it too. I am 100% certain it will meet my needs, which is pretty much the same as yours.
Thank you very much, In next week I will start work on writing the installer on CLI.
I just read CLI docs very short and I see it’s very useful. I can handle some of my problems by using it