Composer install and vendor folder

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Composer install and vendor folder

Post by lexlf » Sat Jun 22, 2019 1:34 pm

Hello everyone.

I have found multiple post like this one (which is active), but I thought it would be better to open another one for more visibility.

In a recent extension I published, I needed to use a websocket client to communicate with a Python server.

For this client, I used Textalk's websocket-php repository which requires a "git clone" and next a "composer install".

Working around the composer.js of the extension, I have not been able to get any results to perform both the download and the install I needed.
I have thought about using an exec from the extension the first time it is loaded... but I would rather look for the expected way to proceed. Should it be in "required-dev" ? "required" key of the json? How to correctly call for the download installation of the composer?

Thank you.

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

Re: Composer install and vendor folder

Post by david63 » Sat Jun 22, 2019 2:35 pm

I have answered that in your other topic.

An extension has to be "self contained" - that is all files that are required for the extension must be within the extension package (in a future version of phpBB you will be able to use composer to install dependencies). Obviously while an extension is at [ALPHA] stage then there is no requirement to provide all/any of the dependencies.
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

lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Re: Composer install and vendor folder

Post by lexlf » Sat Jun 22, 2019 2:47 pm

david63 wrote:
Sat Jun 22, 2019 2:35 pm
I have answered that in your other topic.

An extension has to be "self contained" - that is all files that are required for the extension must be within the extension package (in a future version of phpBB you will be able to use composer to install dependencies). Obviously while an extension is at [ALPHA] stage then there is no requirement to provide all/any of the dependencies.
Hello again David!

Thank you for these details... I thought it was possible to run the composer install directly with the composer.js and to have the "vendor" folder may be downloaded into the root folder.

I do not have much experience for extensions (only did one with limited use) and my next question will thus be the following : For a more developed version, would you recommend to use an "exec" from php to perform the composer install (but this would require it installed), which would mean you have all elements downloaded from the server host and created (around 18Mo in my case for 2443 files) or should I create a zip file with all the dependencies (which might not be the most optimized way to proceed).

In either case, is there any element I should add through the composer.js?

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

Re: Composer install and vendor folder

Post by david63 » Sat Jun 22, 2019 2:56 pm

lexlf wrote:
Sat Jun 22, 2019 2:47 pm
would you recommend to use an "exec" from php
No - many hosts do not allow it and there are security issues with it.

As I said before your extension needs to be "self contained" - whether you need over 2k files I would not know, perhaps do some "pruning".
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

lexlf
Registered User
Posts: 13
Joined: Fri Apr 12, 2019 3:50 pm

Re: Composer install and vendor folder

Post by lexlf » Sat Jun 22, 2019 3:04 pm

Thank you!

User avatar
Toxyy
Registered User
Posts: 697
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: Composer install and vendor folder

Post by Toxyy » Sat Jun 22, 2019 5:49 pm

david63 wrote:
Sat Jun 22, 2019 2:35 pm
(in a future version of phpBB you will be able to use composer to install dependencies)
Can you not already do this? I installed a github dependency for an extension just like he needs using it and it worked great.

viewtopic.php?t=2374621#p14505611
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][BETA] Sticky Ad || [3.2][RC] Show User Activity ||
[3.2][DEV] User Delete Topics

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

Re: Composer install and vendor folder

Post by david63 » Sat Jun 22, 2019 8:39 pm

Toxyy wrote:
Sat Jun 22, 2019 5:49 pm
Can you not already do this? I installed a github dependency for an extension just like he needs using it and it worked great.
Not, as far as I am aware, from within a phpBB extension. Yes you can do it outside of phpBB core but not all (in fact I would go so far as to say not many) users would be able to do this.
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
Toxyy
Registered User
Posts: 697
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: Composer install and vendor folder

Post by Toxyy » Sun Jun 23, 2019 1:30 am

david63 wrote:
Sat Jun 22, 2019 8:39 pm
Not, as far as I am aware, from within a phpBB extension. Yes you can do it outside of phpBB core but not all (in fact I would go so far as to say not many) users would be able to do this.
Well, all I had done was add a line "username/reponame" after a couple of tries using the thread I linked, and I was able to use the functions from the package as if I had used require, it included the files in the vendor folder within my extension folder. It's worth a shot I guess
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][BETA] Sticky Ad || [3.2][RC] Show User Activity ||
[3.2][DEV] User Delete Topics

User avatar
3Di
Former Team Member
Posts: 13780
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Composer install and vendor folder

Post by 3Di » Mon Jun 24, 2019 7:22 am

Yeah.
lexlf wrote:
Sat Jun 22, 2019 1:34 pm
Hello everyone.

--- SNIP ---

In a recent extension I published, I needed to use a websocket client to communicate with a Python server.

For this client, I used Textalk's websocket-php repository which requires a "git clone" and next a "composer install".

Working around the composer.js of the extension, I have not been able to get any results to perform both the download and the install I needed.
I have thought about using an exec from the extension the first time it is loaded... but I would rather look for the expected way to proceed. Should it be in "required-dev" ? "required" key of the json? How to correctly call for the download installation of the composer?

Thank you.
No exec().

You can do it the usual way adding this bit to your composer.json

https://github.com/Textalk/websocket-php#installing

Code: Select all

"require": {
  "textalk/websocket": "1.0.*"
}
Explained here (where I did it explained indeed)
Toxyy wrote:
Sat Jun 22, 2019 5:49 pm
viewtopic.php?t=2374621#p14505611
Just accurately read my post and apply it.

Once done, the library will be at your disposal and you will use it as per https://github.com/Textalk/websocket-php#client-usage
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Post Reply

Return to “Extension Writers Discussion”