Slim icon indicating copy to clipboard operation
Slim copied to clipboard

Slim 4 Alpha Release Feedback

Open l0gicgate opened this issue 7 years ago • 50 comments

Slim 4 Alpha Release See the full release notes

Before doing anything read the docs I just finished the first draft of the docs for Slim 4 which are available here. I need feedback please: http://dev.slimframework.com/docs/v4

Download an test the 4.0.0-alpha release You may also play around with the 4.x branch and create a simple app with it to test things out. composer require slim/slim:4.0.0-alpha

Install a PSR-7 Implementation You will also need to install a PSR-7 implementation and ServerRequestCreator combo. You can use Slim's PSR-7 Implementation or choose one of the ones described on the 4.x branch README: https://github.com/slimphp/Slim/blob/4.x/README.md composer require slim/psr7:dev-master

Slim 4 DDD API Skeleton Prototype I also just created a Slim4 Skeleton with a DDD style directory structure with example files and test coverage for everything. I'm not sure if it's the right fit yet as it may be a bit too opinionated but I'd love some feedback:

git clone https://github.com/l0gicgate/Slim-Skeleton
git checkout 4.x

If you have any questions don't hesitate to ping me on Slack or ask questions in this thread directly, I'm available to help!

l0gicgate avatar Apr 23 '19 21:04 l0gicgate

@l0gicgate Just a little nitpik: The link to "contributing: Branching Strategy" on this page: http://slim-website.lgse.com/docs/v4/cookbook/uploading-files.html -- Links to version 3 (http://slim-website.lgse.com/docs/v3/contributors/strategy.html)

RyanNerd avatar Apr 25 '19 18:04 RyanNerd

Good catch @RyanNerd! Fixed

l0gicgate avatar Apr 25 '19 18:04 l0gicgate

@l0gicgate Version 3 has a Tutorial link with a guide to creating a "first application". Slim 4 with all the decoupling and plug-in choices (PSR-7, Containers, Route & ErrorHandling as middleware, etc.) is much more complex than Slim 3. This can be overwhelming to someone new to Slim (and even those like myself that are familiar with version 3). Perhaps the docs could include a Tutorial for v4 showing how to create a "first application" using bare bones concepts and the plug-in defaults.

RyanNerd avatar Apr 25 '19 18:04 RyanNerd

@RyanNerd I removed the tutorial from the v4 docs for now. It does need to be written and will be added to the docs later. In the mean time someone can look at the skeleton repository to see how things are implemented in a "real life" scenario.

I also think that a video tutorial would be much better. I just need time to get it done.

l0gicgate avatar Apr 25 '19 18:04 l0gicgate

Install a PSR-7 Implementation You will also need to install a PSR-7 implementation and ServerRequestCreator combo. You can use Slim's PSR-7 Implementation or choose one of the ones described on the 4.x branch README: https://github.com/slimphp/Slim/blob/4.x/README.md composer slim/psr-7:dev-master

composer require slim/psr-7:dev-master 😉

Antnee avatar Apr 25 '19 22:04 Antnee

Install a PSR-7 Implementation You will also need to install a PSR-7 implementation and ServerRequestCreator combo. You can use Slim's PSR-7 Implementation or choose one of the ones described on the 4.x branch README: https://github.com/slimphp/Slim/blob/4.x/README.md composer slim/psr-7:dev-master

composer require slim/psr-7:dev-master 😉

composer require slim/psr7:dev-master it's not "psr-7"

bednic avatar Apr 26 '19 15:04 bednic

See if you can tell who didn't run it but commented anyway... 😆

Antnee avatar Apr 26 '19 15:04 Antnee

@RyanNerd simply return a response object without calling $handler->handle($request)

l0gicgate avatar Apr 26 '19 15:04 l0gicgate

It looks like ErrorHandler will only catch exceptions thrown from further down the middleware stack. What about exceptions/errors thrown before then, eg a misconfiguration throwing an exception when initializing everything? Would you just register methods within ErrorHandler to the PHP exception and error handlers via set_error_handler() and set_exception_handler() to handle those?

davidbyoung avatar Apr 26 '19 18:04 davidbyoung

@davidbyoung I documented on how to handle all errors in the docs under Notices & Warnings handling. This shows a more advanced way of handling all errors. See http://dev.slimframework.com/docs/v4/objects/application.html#notices-and-warnings-handling

l0gicgate avatar Apr 26 '19 19:04 l0gicgate

Note the "Edit this page" links in the documentation refer to something like:

https://github.com/slimphp/Slim-Website/tree/gh-pages/docs/v4/objects/routing.md

which does not exist, while

https://github.com/slimphp/Slim-Website/tree/gh-pages-4.x/docs/v4/objects/routing.md

Should I create an issue for this? Or is it expected "for now"... 😄

holtkamp avatar Apr 26 '19 21:04 holtkamp

@holtkamp thanks for reporting this. It has to stay the same until I merge the gh-pages-4.x branch into gh-pages which won't be until Slim 4 is released. It'll have to stay broken for a bit 😂

l0gicgate avatar Apr 26 '19 21:04 l0gicgate

In the documentation and the readme file, index.php refers to '/vendor/autoload.php'. This seems to suggest that the vendor directory should be placed within the public directory, where index.php lives. That seems pretty dangerous. Would it make sense to change to this to refer to __DIR__ . '/../vendor/autoload.php' instead?

sander-bol avatar Apr 28 '19 11:04 sander-bol

How about adding suggestions for the PSR-7 implementations mentioned in the README.md to composer.json?

{
    "suggest": {
        "slim/psr7": "This is the Slim Framework projects PSR-7 implementation.",
        ...
    }
}

See: https://getcomposer.org/doc/04-schema.md#suggest

michaelbiberich avatar Apr 28 '19 13:04 michaelbiberich

Hi, I have a question about default middleware implementation. But first I need to clear my understanding the idea abou using this framework. When I look at your setup of App, it seems like whole idea is setup app via DI, cause the factories etc., is that right? Second is about middleware, I get idea, like all is middleware so everything is implemented same way. But It seems like I need to setup everyting by myself, is it right conclusion? And at the end, wouldn't be better if basic middlewares, like RouteMiddleware and ErrorMiddleware has been setup automaticly?

bednic avatar Apr 28 '19 14:04 bednic

@bednic the App can run without a container. It sure makes one’s life a lot easier to provide one though.

RoutingMiddleware is added by default if the user does not add it to the middleware queue. It will run last however, which means that the routing data won’t be available through the middleware stack if you have other middleware that depends on it.

As for ErrorMiddleware you need to place it at the outer most edge of your application (add it last, right before run, so it runs first) and we can’t automatically add it based on assumptions otherwise it wouldn’t behave correctly.

l0gicgate avatar Apr 28 '19 15:04 l0gicgate

Hello.

Missing an example of using sessions with cookies

danielspk avatar May 02 '19 23:05 danielspk

@danielspk I'm not sure exactly how to show an example of that since Slim doesn't handle sessions. That's typically something you'd implement via middleware or if you want sessions turned on at all times just use session_start() after the require __DIR__ . '/../vendor/autoload.php';

l0gicgate avatar May 03 '19 01:05 l0gicgate

I can't get the middleware examples to work. e.g.: http://dev.slimframework.com/docs/v4/concepts/middleware.html#application-middleware From what I can tell, the 'BEFORE' middleware prevents the route from being called.. somehow.

EDIT: I've figured out how it works, but the example remains incredibly confusing. As far as I can tell there's no way to write to the body in middleware before the route does its thing.

Serdan avatar May 03 '19 07:05 Serdan

Hi, I made a simple repository that uses travis-ci to automatically test the slim4 framework against multiple PSR-7 implementations. See https://github.com/adriansuter/Slim4-CI

Currently, all are working fine!

adriansuter avatar May 05 '19 20:05 adriansuter