Closed JYDARTHA closed 4 years ago
Before I attempt to reproduce, can you answer a few questions for me, please?
composer require laminas-api-tools/statuslib-example
have write permissions to config/modules.config.php
?StatusLib
manually to your config/modules.config.php
or config/application.config.php
file, per the instructions?Another thing you can do for me: start over, and when you get to the composer require laminas-api-tools/statuslib-example
command, add the flag -vvv
when invoking it: composer require -vvv laminas-apitools/statuslib-example
, and then provide the output in a comment.
Thanks!
I've gone through the getting started and REST tutorials at this time. There are some JavaScript errors in the UI that require refreshing after each save, but I was able to complete the steps up to the "Defining the resource" section.
I then did the work in that section, and started testing the API.
And had no issues.
Now, regarding the StatusLib\Mapper
class referenced in the factory, this is what we've called in the past a "virtual service" - the class does not exist, but there is a mapping for the service StatusLib\Mapper
in the container, and, if you follow the directions, it works, resolving to the ArrayMapper
implementation in this case.
My guess is:
composer show
, you will NOT see laminas-api-tools/statuslib-example in the list, and/orconfig/modules.config.php
file.The first would mean there is no autoloader present for classes under the StatusLib
namespace, and the second would mean that the application is not aware of the module, so it is not loading any service configuration for it. All of this stems from the failure when installing via Composer, and the fact that you kept going when that occurred.
I suggest re-trying the install of the laminas-api-tools/statuslib-example package. If you run into errors, run composer self-update
to ensure you have the latest Composer version before trying again.
Hi. Thanks for your support. Here's my responses
When I launched, a second time, the composer require command, there wasn't the error message.
My composer version seems to be the latest one: composer --version Composer version 1.10.7 2020-06-03 10:03:56
Then, I cleaned my entire project and started it, a fourth time, from scratch :-) Here is the output in verbose mode of the composer require laminas-api-tools/statuslib-example command.
There is an exception.
I ran the composer show command and the laminas-api-tools/statuslib-example seems to be present.
But that's right, I don't have any StatusLib entry in my config/modules.config.php file.
Finally, I launched the composer self-update command: composer self-update You are already using composer version 1.10.7 (stable channel).
Should I re-install composer ?
Thanks
I found this PHP bug report: Bug #78883 | fgets(STDIN) fails on Windows [https://bugs.php.net/bug.php?id=78883] Do you think it is related ?
Hi. Finally I upgraded my PHP from 7.4.0 to 7.4.7 and it solved my problem. It works fine now. Thank for your support.
Glad you were able to get it sorted!
Bug Report
LAB API-REST doen't work, due to installation problems.
Summary
Version api : 1.5.2p1 While starting the Lab "Creating a REST Service", we need to install laminas-api-tools/status-lib-example. Composer failed : Here's the command and standard output:
composer require laminas-api-tools/statuslib-example Using version ^1.2 for laminas-api-tools/statuslib-example ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 2 installs, 0 updates, 0 removals
Installing laminas-api-tools/statuslib-example (1.2.0): Loading from cache
Please select which config file you wish to inject 'StatusLib' into: [0] Do not inject [1] config/modules.config.php [2] config/development.config.php.dist Make your selection (default is 1): Installation failed, reverting ./composer.json to its original content.
[Symfony\Component\Console\Exception\RuntimeException] Aborted
require [--dev] [--prefer-source] [--prefer-dist] [--fixed] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...
Current behavior
So, The package is still installed when I check in the vendor directory and the composer.json. Well, let's goes on!
On the chapter "Defining The Resource", when editing the module/Status/src/V1/Rest/Status/StatusResourceFactory.php file, there is a warning on "return new StatusResource($services->get(Mapper::class));" . The message is: Type 'Mapper' not found
Just after, at the chapter "Testing it out", the server response to the GET /status HTTP/1.1 Accept: application/json is 500 Internal Server Error
Here is the CUrl Command : curl -X GET -i http://syrius-api:8081/status --data 'HTTP/1.1 Accept: application/json'
I tried the LAB, 3 times. I have already the same problem. It looks like something wrong on the StatusResourceFactory.php with the Mapper::class?
How to reproduce
Expected behavior
I would like to install correctly my first REST-api with Laminas.
Thanks