Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation? #90

Open
adriansuter opened this issue May 20, 2019 · 5 comments
Open

Documentation? #90

adriansuter opened this issue May 20, 2019 · 5 comments

Comments

@adriansuter
Copy link
Contributor

Unfortunately I have not found a documentation nor any best-practices on how to use this library with slim 4. The README explains the instantiation process only.

In a test installation I used it in the route callable (an invokable class) the following way - is that correct?

// .... strict types and namespace

use Slim\Http\Response;
use Slim\Http\ServerRequest;

class HomeController
{
    public function __invoke(ServerRequest $request, Response $response, array $args = []): Response
    {
        return $response->withJson(['foo' => 'bar']);
    }
}

Am I loosing anything by directly typehinting Slim\Http\ServerRequest and Slim\Http\Response for the first two params?

The documentarion should mention that after installation (which works out-of-the-box), the first two arguments of the route callables would be decorated. I assume the same holds for the middleware $request param and for $response in the middleware code $response = $handler->handle($request);.

@l0gicgate l0gicgate added this to the 0.8 milestone May 24, 2019
@l0gicgate
Copy link
Member

You are never losing anything. Your application is however dependent on those objects though. It's not that complicated to change later though if you wanted to get rid of it.

I'm not sure how to go about docs right now. Do we include it on the Slim-Website under the regular docs in its own section? or do we create an entire new website.. It is a package that can be used with other PSR-7 implementations so it can stand alone.

@adriansuter
Copy link
Contributor Author

I suggest to write a documentation of its own. Always under the assumption, that this package can be used with other PSR-7 implementations.

And in the Slim 4 docs, I would add a section that shows how to use this package explicitly together with Slim. I think that the decorator "Slim-Http" would be used by most people. So it could probably be a sub-section in the Concepts section? Maybe after PSR-7?

However, the section does not have to contain or describe all non PSR-7 methods. I would add a link to the Slim-Http docs though, where a complete reference of all extra methods can be found.

@adriansuter
Copy link
Contributor Author

How about using github pages and one of its predefined themes in order to create the docs? Maybe such that these pages would be accessible via http://http.slimframework.com? Or do you think that the docs for this "library" should be in the same look as the slim docs?

@bennnjamin
Copy link

I was trying to upgrade a Slim 3 application to Slim 4 which is strictly a JSON API and I had to find this issue to figure out that the HTTP decorators were not working for parsing the body and creating a JSON response because the Route Controller needed:

use Slim\Http\Response;
use Slim\Http\ServerRequest;

Part of the confusion was from following this https://github.com/slimphp/Slim#hello-world-using-appfactory-with-psr-7-auto-detection where I assumed all routes needed:

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

If had I done nothing it would have worked. Perhaps in the upgrade guide for v3 to v4 there should be a section on preserving Slim 3 behavior by installing this repo and a PSR-7 implementation. Or the documentation for using this repo with Slim 4 could be under the Cookbooks section of the current documentation site and standalone usage documentation should be in this repo.

@l0gicgate l0gicgate removed this from the 0.8 milestone Sep 10, 2019
@cskeeters
Copy link

For anyone else having problems getting Slim-Http working in Slim 4. Know that it will only work with semi recent versions of Slim-Http that composer won't install unless it detects simplexml and fileinfo PHP extensions.

https://discourse.slimframework.com/t/how-to-utilize-slim-http-decorators-in-slim-4/5511/3?u=chad.skeeters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants