Composer Installers for phpbb-extension

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
Blitze
Registered User
Posts: 385
Joined: Tue Nov 29, 2005 5:06 pm

Composer Installers for phpbb-extension

Post by Blitze » Tue Jun 18, 2019 1:19 pm

I am a little confused about why it is recommended to require composer installers mainly because the installation path specified for the phpbb-extension type points to 'ext/{$vendor}/{$name}/'.

I understand that the plan is for phpbb4 to manage extensions using composer. So I can understand why phpBB itself will need composer installers seeing as it is pointing to the ext/ folder. I don't understand why the extensions themselves will need the installers seeing as, relative to the extension, the specified path for 'phpbb-extension' would be incorrect. In other words, from my extension directory, if I require another phpBB extension (say foo_vendor/bar_extension), it gets installed in phpBB/ext/my-vendor/my-extension/ext/foo_vendor/bar_extension instead of the expected phpBB/ext/foo_vendor/bar_extension.

So I have the following questions:
  • Is there a need for another customer installer for extensions to use so they can install other extensions relative to the current extension?
  • should extensions provide custom paths if they require other extensions?
  • Could the composer installer for 'phpbb-extension' be made to determine if it is in phpBB or in an extension and provide the appropriate path?
  • Or do I have this whole thing wrong?
Thanks
My Extensions: phpBB SiteMaker

User avatar
Autumn Shade
Registered User
Posts: 29
Joined: Thu May 30, 2019 12:38 pm

Re: Composer Installers for phpbb-extension

Post by Autumn Shade » Wed Jun 19, 2019 8:08 am

Greetings. Welp, let's make some clairvoyance, since I've went in-depth within this topic a while ago. FIrst thing first, the composer installers are probably for the third-party libraries(that's how I understand it myself), so we can manage the modularity of composer. (That's why it's package manager) Another thing, usually when you run the composer install into the directory and update the autoloading of the composer(since phpbb currently don't have one and you have to do it manually) you get your third-party libraries into phpbb/ext/foo_vendor/bar_ext/vendor folder.

About your first question, well not really. All you need is to explicitly define the path to the package, so you can autoload its' classes. The second question is answered partly by the first, but let's go past it again, You need to provide the path whatsoever, not sure if you want to include an extension of phpbb or some package from composer, though, please clarify. About the third question, I am not sure if I can answer that, so I will skip it and let it slide to the next subordinate of the forum. And no, you did not got the whole thing wrong, that's just how it works for now, at least until the new PHPBB 4 comes out.

Best Regards!

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4882
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Composer Installers for phpbb-extension

Post by VSE » Thu Jun 20, 2019 1:26 am

composer/installers is required because it directs composer where to install an extension correctly - that is, into phpBB's ext directory, as well as styles and languages into their correct directories, as you can see in the composer/installers source code here:

https://github.com/composer/installers/ ... taller.php

When composer installs an extension, it reads the extension's composer.json file, (not phpBB's) so that's why the extension needs the composer/installer requirement. Without it in the extension's composer.json, then composer won't know the extension needs to be installed by the direction of composer/installers rules. But, composer is smart enough to see that the extension is a component/child of phpBB, so phpBB will have composer/installers in its own verndor dir, it will not be part of the extension's package.

If you have an extension that requires another validated extension, you just need to put that extension in your required section of your composer.json, and composer will also download that extension to the correct place too.
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

User avatar
david63
Registered User
Posts: 16328
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Composer Installers for phpbb-extension

Post by david63 » Thu Jun 20, 2019 5:59 am

VSE wrote:
Thu Jun 20, 2019 1:26 am
If you have an extension that requires another validated extension, you just need to put that extension in your required section of your composer.json, and composer will also download that extension to the correct place too.
How does it manage the order in which extensions need to be installed?

For example if I had "extension B" that was being installed but that extension required "extension A" to be installed first how would this work (extension B, say, modifies extension A's new table)?
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4882
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Composer Installers for phpbb-extension

Post by VSE » Thu Jun 20, 2019 2:55 pm

david63 wrote:
Thu Jun 20, 2019 5:59 am
How does it manage the order in which extensions need to be installed?

For example if I had "extension B" that was being installed but that extension required "extension A" to be installed first how would this work (extension B, say, modifies extension A's new table)?
Composer does not enable extensions. It just downloads them into place.

If you have an extension that depends on another being installed first, then extension "B" should have things in place to prevent it being installed before the extension "A", either via the ext.php or migration files, or both.

An example is provided here: https://github.com/phpbb-extensions/aut ... recautions
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

Blitze
Registered User
Posts: 385
Joined: Tue Nov 29, 2005 5:06 pm

Re: Composer Installers for phpbb-extension

Post by Blitze » Thu Jun 20, 2019 6:03 pm

I did not realize that composer uses the installers from the dependency to determine the installation path.
Still, say I have an extension, my/foo, that depends on another extension, some/bar. If I add some/bar to my composer.json file and run composer install from the phpBB/ext/my/foo/ directory, the some/bar extension gets installed in phpBB/ext/my/foo/ext/some/bar/ directory instead of phpBB/ext/some/bar since composer installers in the some/bar extension is pointing to ext/{$vendor}/{$name}. From the phpBB root directory that would work but from an extension directory, the dependent extension is installed in the wrong directory.
My Extensions: phpBB SiteMaker

User avatar
VSE
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 4882
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: Composer Installers for phpbb-extension

Post by VSE » Fri Jun 21, 2019 3:40 pm

Blitze wrote:
Thu Jun 20, 2019 6:03 pm
From the phpBB root directory that would work but from an extension directory, the dependent extension is installed in the wrong directory.
But composer should not normally be run from an extension's directory. The only real reason to run composer inside an extension, is like with a build script. But in that case, the dependent extension it downloaded should be removed as part of the build script's clean up process (because you aren't going to be submitting your extension to CDB with somebody else's extension bundled inside it).

To see how it all really works, you need to be trying phpBB 3.3's extension manager. Composer is run in a special manner - as a "live" download manager. If you downloaded extension "B" from that, you'd see it would also download the dependency extension "A" too - and they'd all go to the right place in the ext folder.

But bottom line is all extension submitted to CDB get Composer installers added to their JSON because it's just required for exts to be installed correctly.
Dictated but not read.
Official phpBB Extensions My Extensions & MODs
Please do not PM me for support.

Post Reply

Return to “Extension Writers Discussion”