box icon indicating copy to clipboard operation
box copied to clipboard

"check-requirements" option fails on Zend OPcache extension

Open Eboubaker opened this issue 4 years ago • 3 comments

I have an app which requires "ext-zend-opcache" in composer.json, when I do box compile and try to run the app with php app.phar box's "check-requirements" option will try to check if all extensions are fulfilled and it will fail on zend-opcache even though it is enabled and opcache.enabled is 1 in php.ini.

The problem is that extension_loaded() function for some reason does not work with parameter "zend-opcache" it will return false, the correct string to pass is "Zend OPcache" then it will give true.

You get this string value by doing php -m option you will see it in enabled extensions with the name "Zend OPcache" but not "zend-opcache" or "opcache"

This is the check to be blamed, it needs a fix to recognize zend extensions such as zend-opcache https://github.com/box-project/box/blob/22a327e06cac8de1b3849058fcba230c3a1b83b1/.requirement-checker/src/IsExtensionFulfilled.php#L14

for now I had to set "check-requirements" to false in box.json

Eboubaker avatar Mar 12 '22 00:03 Eboubaker

Ok this was annoying! The issue is that the extension name is incorrect, you can find them with php -m (the case does not matter). So in your case the extension name is zend opcache so the constraint in your composer.json should be ext-zend opcache

theofidry avatar Jun 24 '22 16:06 theofidry

@theofidry but if the extension name ext-zend-opcache was not correct then composer will fail on the autoload step but it does not, and composer does not allow the name ext-zend opcache after editing composer.json and running composer install:

  [RuntimeException]                                                                                                             
  require.ext-zend opcache is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and packag  
  e name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2  
  })[a-z0-9]+)*$". 

Eboubaker avatar Jul 31 '22 14:07 Eboubaker

ha you are right, Composer handles this one in a hardcoded way:

if ($match[1] === 'zend-opcache') {
                        $match[1] = 'zend opcache';
                    }

theofidry avatar Aug 03 '22 20:08 theofidry