PHP Object Lifetime - How Many Controller Instances?

1

I have a controller that runs the index method for the main page. A button in profile information is called by a route that falls into the cadastre method. Is the instance that was run when the index was still running when I am running another call via get? Or does she go to each new request?

    
asked by anonymous 27.07.2016 / 23:46

2 answers

1

It all depends on how you are programming, because nothing prevents you from being in one controller and sending a message to another, even though this is not a good practice.

Framewoks that work with MVC typically have the following lifecycle:

That is, by default the controller does not store its state from one request to another.

    
28.07.2016 / 03:14
0

HTTP is a stateless protocol .
Briefly means that each request is an independent transaction.

The entire process in PHP is compiled at runtime and "dies" when the build is complete.

On a second request, a new process starts completely independent of processes executed on previous or subsequent requests.

However, there are several techniques for keeping a "live" instance on separate requests.

Obviously this is not only in PHP. It is the nature of the HTTP protocol.

    
28.07.2016 / 05:22