Page 1 of 1

Including composer package

Posted: Thu Jun 13, 2019 6:51 am
by Autumn Shade
Greetings.

I've tried including composer package into my extension package, but it seems to not autoload the classes correctly, so I am not able to use them correctly. The namespacing is okay, I've tried embedding into the project, although I don't think that's how it works. Can somebody with some experience, who created an extension using some 3rd-party composer packages help up?

Best Regards!

Re: Including composer package

Posted: Thu Jun 13, 2019 7:12 am
by david63
Not quite sure what it is that you are trying to do.

Are you trying to get your extension to auto load via composer - if so then that is not possible at the moment (phpBB 3.3 or 4.0 will have that functionality) for now you have to run composer locally to create a vendor folder that you include with your extension.

If that is not what you mean then please explain exactly what the problem is.

Re: Including composer package

Posted: Thu Jun 13, 2019 7:14 am
by Autumn Shade
Yeah, that's what I was trying to guess, why does phpbb does not load automatically with Symfony kernel the external dependencies. I did it by loading the classmap into the composer.json and making sure the path to the vendor is correctly set.

Re: Including composer package

Posted: Thu Jun 13, 2019 7:22 am
by david63
Autumn Shade wrote:
Thu Jun 13, 2019 7:14 am
why does phpbb does not load automatically with Symfony kernel the external dependencies
Sorry but that decision is above my pay grade.

As I said before it will be in a future version.

Re: Including composer package

Posted: Thu Jun 13, 2019 9:09 am
by Paul
You should run composer install on your extension itself. This will generate a vendor folder within your extension, and this should be included when you add your extension to the ext/ folder. All files from this vendor/ folder are autoloaded by phpBB.

What David is talking about is installing actual extension with composer. That is something that will be included in phpBB 4.0 (And at that moment it is also no longer needed to include the vendor/ folder in the extension itself).