Slim 4 Alpha Release Feedback
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 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)
Good catch @RyanNerd! Fixed
@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 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.
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 😉
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"
See if you can tell who didn't run it but commented anyway... 😆
@RyanNerd simply return a response object without calling $handler->handle($request)
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 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
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 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 😂
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?
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
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 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.
Hello.
Missing an example of using sessions with cookies
@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';
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.
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!