Closed leogermani closed 2 years ago
In terms of autoloading, but still need to fix up the copy command.
> WorDBless\Composer\InstallDropin::copy
Script WorDBless\Composer\InstallDropin::copy handling the post-update-cmd event terminated with an exception
In InstallDropin.php line 17:
copy(src/dbless-wpdb.php): Failed to open stream: No such file or directory
(after running composer update automattic/wordbless@dev-update/fix-autoload
in Jetpack's projects/packages/abtest
with the updated post-install command.
~Do you think we need to define a constant to define the dir that we're in and use that, e.g. WDBLESS_DIR
so it'll work both ways?~ ignore this
when using WorDBless as a dependency
When a package is a dependency its post-install-cmd
event is not triggered.
README: Add this script to your composer.json:
I see! This is in the main project. Using a dependency's class in a Composer script is a mystery for me!
PHP classes containing defined callbacks must be autoloadable via Composer's autoload functionality. Callbacks can only autoload classes from psr-0, psr-4 and classmap definitions. If a defined callback relies on functions defined outside of a class, the callback itself is responsible for loading the file containing these functions.
(Composer docs)
🖱️ https://github.com/composer/composer/issues/8147#issuecomment-493026423
This worked for me now.
Steps to test:
cd projects/packages/abtest
.composer.json
to look for version "automattic/wordbless": "dev-update/fix-autoload",
composer update
Expected CLI result should include:
...
10 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
36 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> WorDBless\Composer\InstallDropin::copy
and there should be a wordpress/wp-content/db.php
file in the abtest package dir.
I'm going to approve this based on that, but @leogermani can you double-check me on ^ before we cut a new version.
Worked for me as well
Fixes the following error when using WorDBless as a dependency
and updates the README