Hey everybody!
I built a Laminas MVC web app and have to add an API. After some reasearch, I reckoned that the Laminas API Tools UI should be the best way for this. I am working in a vagrant box with composer and managed to set everything up so that I can access the Laminas API Tools UI main screen.
When I click on New API and insert some name like “NewAPI”, I see the following alert:
I cannot create the API module, please check if already exists
There is no API named like this yet and despite the error message a folder NewAPI has been created in module folder. Its structure looks okay to me:
The line ‘NewAPI’ gets automatically added to modules.config.php. As I’ve read this post (Laminas API Tools - unable to create new API in Admi UI - #2 by gary), I knew that this should not be the case. So if I remove this new line, API Tools Admin UI can be reloaded normally, but the API list is still empty.
Has anyone got an idea on what I need to change in order to create, see and manage my APIs? That’d be we great!
BTW: If I don’t remove the line ‘NewAPI’ from modules.config.php, the following error occurs:
Fatal error: Uncaught Laminas\ModuleManager\Exception\RuntimeException: Module (NewAPI) could not be initialized. in /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:210 Stack trace: #0 /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(182): Laminas\ModuleManager\ModuleManager->loadModuleByName(Object(Laminas\ModuleManager\ModuleEvent)) #1 /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(104): Laminas\ModuleManager\ModuleManager->loadModule(‘NewAPI’) #2 /vagrant__my_app/MyApp/vendor/laminas/laminas-eventmanager/src/EventManager.php(331): Laminas\ModuleManager\ModuleManager->onLoadModules(Object(Laminas\ModuleManager\ModuleEvent)) #3 /vagrant__my_app/MyApp/vendor/laminas/laminas-eventmanager/src/EventManager.php(180): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\ModuleManager\ModuleEvent)) #4 /vagrant_ in /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php on line 210
When I remove the line from modules.config.php after this error message, another error is displayed:
Parse error: syntax error, unexpected ‘‘NewAPI’,’ (T_ENCAPSED_AND_WHITESPACE), expecting ‘)’ in /vagrant__my_app/MyApp/config/modules.config.php on line 45
In order to get back to the normal Admin Tools UI screen, I have to add the line in modules.config.php again, reload the browser (which gives me almost the same fatal error again, see below) and then remove the line again.
Fatal error: Uncaught Laminas\ModuleManager\Exception\RuntimeException: Module (NewAPI) could not be initialized. in /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php:210 Stack trace: #0 /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(182): Laminas\ModuleManager\ModuleManager->loadModuleByName(Object(Laminas\ModuleManager\ModuleEvent)) #1 /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php(104): Laminas\ModuleManager\ModuleManager->loadModule(‘NewAPI’) #2 /vagrant__my_app/MyApp/vendor/laminas/laminas-eventmanager/src/EventManager.php(331): Laminas\ModuleManager\ModuleManager->onLoadModules(Object(Laminas\ModuleManager\ModuleEvent)) #3 /vagrant__my_app/MyApp/vendor/laminas/laminas-eventmanager/src/EventManager.php(180): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\ModuleManager\ModuleEvent)) #4 /vagr in /vagrant__my_app/MyApp/vendor/laminas/laminas-modulemanager/src/ModuleManager.php on line 210
I’m not completely sure if this information is necessary or even useful for finding a solution, I just thought that this is some really weird behavior that the fatal error messages differ only this little bit directly after “#4 …” (“/vagrant_” vs “/vagr”).