Composer requirements

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

Composer requirements

Post by Ger »

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?
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

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

-Don't PM me for support-
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Composer requirements

Post by canonknipser »

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 - no support via PM or mail
New arrival - Extensions and scripts for phpBB
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Composer requirements

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger »

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.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

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

-Don't PM me for support-
User avatar
AlfredoRamos
Recognised Extension Developer
Posts: 1302
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo
Contact:

Re: Composer requirements

Post by AlfredoRamos »

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/
Some of my phpBB extensions:
:chart_with_upwards_trend: SEO Metadata | Image Markdown | :shield: hCaptcha
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user | Linux Boards :penguin:
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Composer requirements

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Composer requirements

Post by 3Di »

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
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger »

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.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

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

-Don't PM me for support-
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Composer requirements

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Composer requirements

Post by 3Di »

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.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Composer requirements

Post by Ger »

Well thanks to everyone, it's now incorporated in this extension.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

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

-Don't PM me for support-
Post Reply

Return to “Extension Writers Discussion”