I'm making a CakePHP3 plugin and I'm using a library that I wrote that uses PSR-4 autoloading. If I require the library in the application's composer.json it autoloads correctly and I can use it anywhere in my app including the plugin. When I try requiring it through my plugin's composer.json it installs fine and composer gives no errors but it doesn't seem to autoload. When I go a page controlled by the plugin that uses the library I get the error that the class is not found.
Am I doing something wrong? I checked vendor/composer/autoload_psr4.php
in my plugin folder and my class is in that file. I also ran composer dump-autoload
in both the application directory and the plugin directory but it didn't help.
I baked the plugin with cake bake plugin MyPlugin
and then edited the require section of the plugin's composer.json to include my library. Then I ran composer update
and it installed the library to plugins/MyPlugin/vendor/mylibrary
without errors.