contao/check

add php-intl check for Contao >=4

Closed this issue · 11 comments

Currently Index::supportsContao4 only checks the PHP version. However, Contao >=4 (or rather Symfony) has more requirements regarding PHP than that - for instance the PHP Intl Extension must be loaded (which is not the case on some cheap hosting environments).

This is not entirely true, as Symfony does not require the Intl extension to be installed. The Intl component can be used without the PHP intl extension in English; only if you want to use a different locale, the PHP intl extension is required. It is therefore a suggestion only:

https://github.com/symfony/intl/blob/master/composer.json#L34

And since we are currently not using the Symfony Intl component at all, the PHP intl extension is not required to run Contao.

Hm, last time I checked there will be a server error when trying to run Contao 4 without PHP intl.

Just to clarify, the PHP Intl extension is bundled with PHP since PHP 5.3.0, however on some Linux distributions, the custom built PHP binary comes without the intl extension - which is why it is missing on some hosters.

@leofeyer without PHP intl you get this errors from dependencies:

composer create-project contao/standard-edition ./contao410.contaodev 4.1.0

Installing contao/standard-edition (4.1.0)
  - Installing contao/standard-edition (4.1.0)
    Downloading: 100%

Created project in ./contao410.contaodev
Loading composer repositories with package information

Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for jeremykendall/php-domain-parser 3.0.0 -> satisfiable by jeremykendall/php-domain-parser[3.0.0].
    - jeremykendall/php-domain-parser 3.0.0 requires ext-intl * -> the requested PHP extension intl is missing from your system.
  Problem 2
    - Installation request for league/uri 4.0.1 -> satisfiable by league/uri[4.0.1].
    - league/uri 4.0.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
  Problem 3
    - league/uri 4.0.1 requires ext-intl * -> the requested PHP extension intl is missing from your system.
    - contao/core-bundle 4.1.0 requires league/uri ~4.0 -> satisfiable by league/uri[4.0.1].
    - Installation request for contao/core-bundle 4.1.0 -> satisfiable by contao/core-bundle[4.1.0].

I can confirm that. And even if you do not use composer create-project … but use the distribution archive from contao.org instead, you will get the following error message after providing a password when executing the web/install.php if your PHP binary or your PHP configuration does not have php-intl enabled:

Fatal error: Call to undefined function Patchwork\grapheme_strlen() in …\contao-4.1.1\vendor\patchwork\utf8\src\Patchwork\Utf8.php on line 234

After enabling php-intl, the Install Tool will continue to work as expected.

See also:

If Contao 4 really is not supposed to require php-intl, then we should report it as a bug instead.

Contao requires "patchwork/utf8": "~1.2" (https://github.com/contao/core-bundle/blob/4.1.1/composer.json#L35). This package has no dependency defined for ext-intl, however its functions use the Grapheme which are only available, if ext-intl is available.

Also Contao requires "league/uri": "~4.0" (https://github.com/contao/core-bundle/blob/4.1.1/composer.json#L30) which in turn requires jeremykendall/php-domain-parser which in turn requires ext-intl. Hence the error that happens if you try to do

composer create-project contao/standard-edition ./contao4 4.1.1

or

composer update

without having an enabled PHP intl extension.

Either both of these dependencies have to be removed, if you do not want to have PHP intl as a requirement - or the requirement should be properly documented and added to the check as proposed in this issue.

Regarding the issue with Patchwork::Utf8, according to tchwork/utf8#58 this happens due to a missing call to

Patchwork\Utf8\Bootup::initAll();

The core-bundle uses Bootup::initAll() in the ContaoCoreBundle::boot function though.

I'd recommend again to put this check for Contao 4.x
It gives
contao 4 Fatal error: Uncaught Error: Call to undefined function Patchwork\grapheme_strlen()

#on Linux in your PHP.ini
php-intl should be installed &
intl.so should be enabled in php.ini

#On Windows uncomment and enable in your PHP.ini
extension=php_intl.dll

http://stackoverflow.com/questions/33869521/how-can-i-enable-php-extension-intl

There is a new PR that would implement that check (as well as more detailed checks for each Contao version), see #108 . However, I still need to update that PR for the most recent Check version, before it can be merged.

Closed in favour of #112