laminas-api-tools / api-tools-skeleton

Skeleton Application for Laminas API Tools
https://api-tools.getlaminas.org/documentation
BSD 3-Clause "New" or "Revised" License
50 stars 64 forks source link

Missing Zend-i18n package #1

Closed weierophinney closed 2 years ago

weierophinney commented 4 years ago

Hello,

I just installed a fresh install of Apigility with curl -sS https://apigility.org/install | php (according to documentation).

I started playing with it (it's my first time using Apigility) but I couldn't add an alpha validator on my field. Looking at the console I realized I had the following error:

PHP Fatal error:  Uncaught Error: Class 'Zend\I18n\Validator\Alpha' not found

To fix the issue, I added the zendframework/zend-i18n package with composer require zendframework/zend-i18n and added 'Zend\\I18n' in modules.config.php (it was done by composer but there was a \ missing).

I hope it helps :)


Originally posted by @jbelien at https://github.com/zfcampus/zf-apigility-skeleton/issues/170

weierophinney commented 4 years ago

@jbelien Thanks for reporting the issue. I believe zend-i18n should be added then to skeleton, so user has smooth experience when using default installation.

Can you explain what's wrong with 'Zend\I18n' (with single slash)? It was not working for you properly when it was injected like that? What was the error? Why you had to change it to double? I've just tried install the skeleton and I see in config/module.config.php:

return [
    'Zend\Db',
    'Zend\Filter',
    'Zend\Hydrator',
    'Zend\InputFilter',
    'Zend\Paginator',
    'Zend\Router',
    'Zend\Validator',
    'ZF\Apigility',
    'ZF\Apigility\Documentation',
    'ZF\ApiProblem',
    'ZF\Configuration',
    'ZF\OAuth2',
    'ZF\MvcAuth',
    'ZF\Hal',
    'ZF\ContentNegotiation',
    'ZF\ContentValidation',
    'ZF\Rest',
    'ZF\Rpc',
    'ZF\Versioning',
    'Application',
];

so all modules are with single \ and it doesn't cause any issues.

Also see: https://3v4l.org/vmEge


Originally posted by @michalbundyra at https://github.com/zfcampus/zf-apigility-skeleton/issues/170#issuecomment-557925757

weierophinney commented 4 years ago

Can you explain what's wrong with 'Zend\I18n' (with single slash)?

It indeed works with on single slash Zend\I18n, sorry ! I mentioned it because all the others have a double slash in my config/modules.config.php and Zend\I18n was the single one with one single slash (with auto injection via composer). So not really an issue indeed (and probably related to my environment - WSL -) and a simple composer require zendframework/zend-i18n is enough to fix this issue!


Originally posted by @jbelien at https://github.com/zfcampus/zf-apigility-skeleton/issues/170#issuecomment-557933186