Migrations inside composer scripts |
Hello.
I have a composer package. It's like small cms (with db tables). My target is to start migrations after package install/update from composer. In this case I use composer scripts. But there are no any autoloaded classes exist inside it. composer.json: Code: { Velldoris\Database\Migration::install: Code: try { There is an error like "Codeigniter class not defined" while i try to init my method strict ("composer run-script post-install-cmd"). And it's not surprising. Here are the solutions I see: 1) Load all project classes throught composer autoload.php 2) Use mysql dump instead of migrations (really?)
I would like auto start migrations when "composer require ..." and "composer update". Not manual.
The composer allows to do this. For example: https://getcomposer.org/doc/articles/scr...hp-scripts But the command "spark migrate -all" can be called in the ROOTPATH. How can i call this from project root path? The another way (similar to spark migrate) is to call controller method like this: spark install index spark update index And this is the same question - how to call from root. The way is to create own spark file in the package root. And then we can call it something like this: Code: "scripts": { And how can we pass execution from our package spark to default /project-root-path/spark?
About spark. There is FCPATH definition inside it:
Code: // Path to the front controller What if my public directory named not "public"? Any idea?
(10-17-2021, 12:39 AM)ARAmiss Wrote: About spark. There is FCPATH definition inside it:In that case you need to edit the spark script. There should be a better way to configure this, but at the moment I think it's the only way to do it.
Thank you.
Despite it is not very convenient to edit the spark file on each project, apparently this is the only option for now. What about getting the root folder of the project from the composer scripts? Maybe someone has faced such a task? And in general, how does anyone solve the task of starting migrations after install/update package from the composer? Or is it all done by hand from the command line? |
Welcome Guest, Not a member yet? Register Sign In |