Answer the question
In order to leave comments, you need to log in
Why do you need psr-7?
Please do not beat me with sticks for this question, I really cannot understand what its essence is, and I will be glad to clarify it with specific examples. I quote what confuses me on the example of Slim 2 and Slim 3.
For example, here:
Why is it proposed to receive data from a get and a post in this way and not through the usual $_GET or $_POST?
Or here is an example of using the Twig template engine in Slim 2:
and in Slim 3:
The same bullshit with a redirect:$app->render('test.html');
$this->view->render($response,'test.html');
//Slim 2
$app->redirect('/test');
//Slim 3
return $response->withRedirect('/test');
Answer the question
In order to leave comments, you need to log in
An exhaustive video on PSR-7 (the first of the entire cycle)
https://www.youtube.com/watch?v=w4iqxN0nfTs&list=P...
The video will answer - why do you need to wrap global variables in objects ?
To your code could be passed to other tools that also work with Request / Response objects ... moreover, other parts of the framework / other frameworks work with these objects - they modify, enrich, etc. ... For example, intermediaries, routers, controllers, etc. .d... And the standard itself is needed so that the creators of libraries / adapters / frameworks do everything through a single interface, which helps to exchange solutions or do it for several platforms at once
Well, then work with him, there is no torture in our time (for such work with globals)
a wrapper over $_GET/$_POST is needed to make it convenient to write tests on your controllers later. Slim can be used both for small projects (where tests are almost never written), and for microservices, where it will be hard without tests.
secondly, you are immediately accustomed to good things by switching to another framework - you will already know how request / response works. In theory, it is easier to migrate to another framework both in code and in terms of learning.
If you have studied PSR7 once, then it is automatically easier for you to use all the libraries that use it, for example, Guzzle, PHPReact, etc.
Why is it proposed to receive data from get and post in this way and not through the usual $_GET or $_POST?Because global variables are evil.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question