You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with some old ZF2 framework application code. It has been a challenge to say the least. My latest task has been a migration to PHP8 with Laminas 3. That's where the abandoned laminas-console was to be upgrade to laminas-cli. This is a summary of some of the issues I hit along the way. This is for feedback purposes.
The first thing to note that our paths are not standard. The Vendor directory is proper cased "Vendor", not "vendor". We also have a non-standard location for it. Our working directory is usually the framework directory, while public_html is the public document root.
./Vendor/bin/laminas test
Command "test" is not defined.
Cannot detect PSR-11 container to configure the laminas-cli application. You can use the --container option to provide a file which returns a PSR-11 container instance.
I noticed that framework/Infrastructure/Vendor/laminas/laminas-cli/src/ContainerResolver.php Line 68 - Looks for {projectRoot}/config/application.config.php
We don't have a config directory in our path. Our application.config.php file is located at:
/apps/htdocs/myapp/framework/Infrastructure/Domain/application.config.php
So, I created a directory at: /apps/htdocs/myapp/framework/Infrastructure/config/ and then copied the application.config.php to the config directory. This might not be a bad thing, as we now have a separate application.config.php file for CLI commands. I kind of wanted two separate configs anyway.
Then I get error:
Command "test" is not defined.
Could not create temporary file in directory "/apps/htdocs/myapp/framework/Infrastructure/../data/cache"
This data/cache is actually located at /apps/htdocs/myapp/data/cache/, so now that path is off one level for some reason. So, in the framework/config/application.config.php I had to make some more adjustments.
Some path issues were fixed with a chdir():
/** Set working directory to the framework directory: '/apps/htdocs/myapp/framework' **/
chdir(dirname(__DIR__).DIRECTORY_SEPARATOR."..");
I also had to include the autoloading setup file. Maybe mine is in an unusual location again.
Most of these path issues are probably due to the unusual directory structure. It would be nice if I could have defined the path to the application.config.php file, but for now I'm good. I'm loving the functionality and features of having parameter inputs! It makes rewriting some of our old cron jobs more fun. Of course, some the old code need to be restructured a bit, but that's almost always the case with old code.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm working with some old ZF2 framework application code. It has been a challenge to say the least. My latest task has been a migration to PHP8 with Laminas 3. That's where the abandoned laminas-console was to be upgrade to laminas-cli. This is a summary of some of the issues I hit along the way. This is for feedback purposes.
The first thing to note that our paths are not standard. The Vendor directory is proper cased "Vendor", not "vendor". We also have a non-standard location for it. Our working directory is usually the framework directory, while public_html is the public document root.
./Vendor/bin/laminas test
I noticed that framework/Infrastructure/Vendor/laminas/laminas-cli/src/ContainerResolver.php Line 68 - Looks for {projectRoot}/config/application.config.php
We don't have a config directory in our path. Our application.config.php file is located at:
/apps/htdocs/myapp/framework/Infrastructure/Domain/application.config.php
So, I created a directory at: /apps/htdocs/myapp/framework/Infrastructure/config/ and then copied the application.config.php to the config directory. This might not be a bad thing, as we now have a separate application.config.php file for CLI commands. I kind of wanted two separate configs anyway.
Then I get error:
This data/cache is actually located at /apps/htdocs/myapp/data/cache/, so now that path is off one level for some reason. So, in the framework/config/application.config.php I had to make some more adjustments.
Some path issues were fixed with a chdir():
I also had to include the autoloading setup file. Maybe mine is in an unusual location again.
Most of these path issues are probably due to the unusual directory structure. It would be nice if I could have defined the path to the application.config.php file, but for now I'm good. I'm loving the functionality and features of having parameter inputs! It makes rewriting some of our old cron jobs more fun. Of course, some the old code need to be restructured a bit, but that's almost always the case with old code.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions