Composer requirements

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Ger
Registered User
Posts: 1103
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Composer requirements

Post by Ger » Wed Sep 13, 2017 11:40 am

I'm working on an extension (early dev) that requires the following the be available:
  1. cURL
  2. Libxml
  3. DOMDocument
  4. DOMXPath
I'm checking for these in ext.php:

Code: Select all

if (! function_exists('curl_init') || !function_exists('libxml_use_internal_errors')|| !class_exists("\DOMXPath")  || !class_exists("\DOMDocument") )
That works, however: I think this should also be in composer.json?
I can't find the right packages on packagist though, I only found ext-curl. Do I need the others also to be in the composer file (and what are their names in that case?) or can I leave the out?
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
canonknipser
Registered User
Posts: 1139
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Composer requirements

Post by canonknipser » Wed Sep 13, 2017 12:25 pm

I'm not sure if those belong into composer,json.
Packages mentioned in composer should (afaik) go to the vendor folder, but those libs you need are php packages; they needs to be installed and setup in the web server
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

User avatar
david63
Jr. Extension Validator
Posts: 12993
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Composer requirements

Post by david63 » Wed Sep 13, 2017 1:10 pm

I would be inclined to agree with Frank.

One thing to do is to make sure that you also check that they are available at the time that you want to use them, just in case the server configuration has changed.
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 or as they will be ignored

User avatar
Ger
Registered User
Posts: 1103
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger » Wed Sep 13, 2017 1:35 pm

david63 wrote:
Wed Sep 13, 2017 1:10 pm
I would be inclined to agree with Frank.
Alright, thanks both.
david63 wrote:
Wed Sep 13, 2017 1:10 pm
One thing to do is to make sure that you also check that they are available at the time that you want to use them, just in case the server configuration has changed.
Hmm... that would be while posting... You raise a valid point.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
AbaddonOrmuz
Registered User
Posts: 211
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo Ramos
Contact:

Re: Composer requirements

Post by AbaddonOrmuz » Wed Sep 13, 2017 5:30 pm

The check should be in composer.json, it will only test whether it can be installed, in composer everything is a dependency if you put it in require or require-dev, it doesn't matter if it won't be installed, as you are aware you can also check the PHP version, they don't need to be packages.
Ger wrote:
Wed Sep 13, 2017 11:40 am
[...] what are their names in that case? [...]
You only need the extension filename that appears inside the extension path*
  • "ext-curl": "*"
  • "ext-dom": "*"
  • "ext-libxml": "*"
And as said above, you should check for runtime exeptions too.

___
* Usually /usr/lib/php/modules/
A proudly user of Arch Linux :: /r/sddm_themes

User avatar
david63
Jr. Extension Validator
Posts: 12993
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Composer requirements

Post by david63 » Wed Sep 13, 2017 5:56 pm

There are currently no dependency checks made on composer requirements
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 or as they will be ignored

User avatar
3Di
Registered User
Posts: 11821
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Composer requirements

Post by 3Di » Wed Sep 13, 2017 8:08 pm

In fact, not to mention that a single message should be thrown to the user for each of the missing requirements. The user should know exactly what's wrong instead of swimming in the dark in case of failure and with multiple requirements. As already said you should check those requirements at runtime too.

In an extension of mine all of this has been implemented and more
This requirements will be checked on install and during the whole life of your board at every refresh, if only one of this requirements will fail the extension will automatically go in a dormant status, it will wake up again once the issue(s) will be fixed and after a new refresh (which is scheduled in ACP). No need to act, basicly. The dormant/awake statuses are logged in ACP/maintenance if occurs. If the extension goes dormant the last succesfull data still will be used, avoiding a total break.
You may want to have a look at this one to see how all of this has been implemented
viewtopic.php?f=456&t=2436126
or - at your choice - at github
https://github.com/3D-I/Steam-Group-Suite
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1103
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger » Wed Sep 13, 2017 8:32 pm

Yeah, I have the checks sorted. However, I only throw an error during install. When the checks fail during usage I simply silently discard the process. I'm still in doubt about logging...

I see you haven't added the requirements to your composer file.

Anyway, I expect to put a first working example on GitHub tomorrow, I'll post a topic about it here.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
david63
Jr. Extension Validator
Posts: 12993
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Composer requirements

Post by david63 » Wed Sep 13, 2017 8:52 pm

Ger wrote:
Wed Sep 13, 2017 8:32 pm
Yeah, I have the checks sorted. However, I only throw an error during install. When the checks fail during usage I simply silently discard the process. I'm still in doubt about logging...
Personally I would "error log" any missing resource. Depending on how often it is likely to be an issue you may want to consider a time limit (say once an hour or once a day)
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 or as they will be ignored

User avatar
3Di
Registered User
Posts: 11821
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milano - Frankfurt
Name: Marco
Contact:

Re: Composer requirements

Post by 3Di » Wed Sep 13, 2017 9:09 pm

Ger wrote:
Wed Sep 13, 2017 8:32 pm
However, I only throw an error during install.
ext.php
https://github.com/3D-I/Steam-Group-Sui ... hp#L18-L56
language related
https://github.com/3D-I/Steam-Group-Sui ... equire.php
Ger wrote:
Wed Sep 13, 2017 8:32 pm
I'm still in doubt about logging...
Me too I am with the log-all bit
https://github.com/3D-I/Steam-Group-Sui ... hp#L29-L48
Ger wrote:
Wed Sep 13, 2017 8:32 pm
I see you haven't added the requirements to your composer file.
I don't know why I should. :) I don't think that's necessary.
Ger wrote:
Wed Sep 13, 2017 8:32 pm
When the checks fail during usage I simply silently discard the process.
In this case what remains of your extension if the admin has not a fast and visual clue?
The extension linked provides a message in ACP stating the extension is in dormant status and the exact reason why, once the issue has been fixed autmatically awakes and logs the success.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades

User avatar
Ger
Registered User
Posts: 1103
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger » Thu Sep 14, 2017 8:52 am

Well thanks to everyone, it's now incorporated in this extension.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: SalazarAG and 11 guests

cron