phing icon indicating copy to clipboard operation
phing copied to clipboard

Some phing tasks require the Intl extension but the dependency is not declared

Open iambrianreich opened this issue 1 year ago • 2 comments

Describe the bug

See the following image.

Basically, some phing tasks seem to require that intl be enabled, but it is not declared in composer.json. So you can install phing without having the extension compiled in/installed/enabled, and then get runtime failures if you use built-in tasks that depend on it.

I encountered this issue because we noticed we had php-intl installed on our servers though our application doesn't depend on it. So I disabled the extension on my development machine, and confirmed that our application still works and passes all the tests. But then when I went to do a build using phing, the build failed due to the missing dependency. So I cleared my vendor directory and did a fresh composer install to see if phing would install without php-intl being enabled, the install succeeded, and phing builds continued to fail unless I re-enable php-intl.

Steps To Reproduce

  1. Disable the intl extension in PHP. Depending on your OS/PHP setup, your steps may vary. For me, I renamed /usr/local/etc/php/ext-20-intl.ini to ext-20-intl.ini.disabled
  2. Create a phing build.xml that uses the <tstamp> task, which requires the extension
  3. Confirm that build fails.

Expected behavior

  1. Build fails with error TstampTask requires Intl extension

Screenshots / terminal output

image

iambrianreich avatar Jun 12 '24 12:06 iambrianreich

Hello, not a bug, it's like that by design.

This way people not using TstampTask are not forced to install Intl extension in vain. There are other Tasks that have the same behaviour.

I kindly suggest to add Intl extension as a dev dependency (require-dev section) in your own project:

$ composer require ext-intl:* --dev

jawira avatar Jun 12 '24 15:06 jawira

Hello, not a bug, it's like that by design.

This way people not using TstampTask are not forced to install Intl extension in vain. There are other Tasks that have the same behaviour.

I kindly suggest to add Intl extension as a dev dependency (require-dev section) in your own project:

$ composer require ext-intl:* --dev

I guess that makes sense given phing's current structure. If tasks not everyone uses were separate/optional dependencies maybe they'd declare their own requirements, but that isn't the structure today.

Thanks so much for the quick response. I'll do as you suggested in my own project.

brianreichtcs avatar Jun 12 '24 17:06 brianreichtcs

We can add it to the suggest section.

mrook avatar Sep 04 '24 09:09 mrook

Thank you!

brianreichtcs avatar Sep 04 '24 13:09 brianreichtcs

Is it possible to add intl dependency if we are using docker image phing/phing:3.0.0 or even nightly?

pmalay avatar Nov 13 '24 19:11 pmalay

Good idea. Continuing in #1875.

mrook avatar Nov 14 '24 12:11 mrook