Welcome Guest, Not a member yet? Register   Sign In
Custom controller - request object empty in constructor
#11

For some reason, the notification did not come from the forum.

Version 5 has been talked about for a long time, but there is not even a discussed development plan. The 4th version spent 4 years from development to the first release. If you look at Yii3, they still don't have a release even though it's been 3 years, but Yii has a much larger team.
Now I perceive version 5 as communism in the USSR. They promised 70 years, but communism did not come.

The use of PSR-7/15 should not, in fact, affect the services in any way. These are basically different things.

Removing Services::request() is the worst thing imaginable. I mean deleting access to an object. Look at this situation globally, not just within the controller.

In fact, neither a factory nor a service is needed for the Response class.
Reply
#12

(07-03-2022, 05:51 AM)iRedds Wrote: The use of PSR-7/15 should not, in fact, affect the services in any way. These are basically different things.

I think it is impossible.

If we will make it so, we need to change Request/Response to be mutable.
However, making them mutable is contrary to the PSR.
The significance of complying with the PSR will lost.

Therefore, I think that it is inevitable that some part will break.

(07-03-2022, 05:51 AM)iRedds Wrote: Removing Services::request() is the worst thing imaginable. I mean deleting access to an object. Look at this situation globally, not just within the controller.

Incoming Request object should be determined at the very early stage of the framework, and it should not be altered in the state,
It seems there is no problem that Services::request() returns the Request object.
Services::request() may be fine as it is now.
Changing the Request object state does not change the object returned by Service::request(), though.

But I don't know why you need it. Where do you use it?
In my opinion, the Request object is used only in Controllers or Controller Filters.

(07-03-2022, 05:51 AM)iRedds Wrote: In fact, neither a factory nor a service is needed for the Response class.

If we don't need service for Response class, it is a good news.
(I think we don't need it in App.)
The Response object is often changed in the state, so Services::response() seems to have more problems than Request.
Reply
#13

(07-03-2022, 04:47 PM)kenjis Wrote: I think it is impossible.

If we will make it so, we need to change Request/Response to be mutable.
However, making them mutable is contrary to the PSR.
The significance of complying with the PSR will lost.

Therefore, I think that it is inevitable that some part will break.

I meant that PSR-7/15 is about working with messages, and services are about providing access to global objects. That is, changing the behavior of HTTP classes will not affect the provision of access to objects of these classes through services.

(07-03-2022, 04:47 PM)kenjis Wrote: Incoming Request object should be determined at the very early stage of the framework, and it should not be altered in the state,
It seems there is no problem that Services::request() returns the Request object.
Services::request() may be fine as it is now.
Changing the Request object state does not change the object returned by Service::request(), though.

But I don't know why you need it. Where do you use it?
In my opinion, the Request object is used only in Controllers or Controller Filters.

Any service can be dependent on Services::request().
Or, for example, you can validate data not only in the controller.

Laravel, Symfony - provide access to Request via CI/DI.
Yii - provide access to the Request through the global object.
CakePHP, despite being accessed via a property in the controller ($this->request), can also inject a Request via container dependencies.

My point is that accessing the Request object from anywhere in the application, not just in the controller, is normal practice.

(07-03-2022, 04:47 PM)kenjis Wrote: If we don't need service for Response class, it is a good news.
(I think we don't need it in App.)
The Response object is often changed in the state, so Services::response() seems to have more problems than Request.

The fact that the Response object retains its state is contrary to PSR-7 =)
Can you give an example where saving the state of the Response is critical for the application to work?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB