Some phing tasks require the Intl extension but the dependency is not declared
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
- Disable the
intlextension in PHP. Depending on your OS/PHP setup, your steps may vary. For me, I renamed/usr/local/etc/php/ext-20-intl.initoext-20-intl.ini.disabled - Create a phing
build.xmlthat uses the<tstamp>task, which requires the extension - Confirm that build fails.
Expected behavior
- Build fails with error
TstampTask requires Intl extension
Screenshots / terminal output
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
Hello, not a bug, it's like that by design.
This way people not using
TstampTaskare not forced to installIntlextension in vain. There are other Tasks that have the same behaviour.I kindly suggest to add Intl extension as a dev dependency (
require-devsection) 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.
We can add it to the suggest section.
Thank you!
Is it possible to add intl dependency if we are using docker image phing/phing:3.0.0 or even nightly?
Good idea. Continuing in #1875.