Chapter 16. Controllers

 

This chapter covers:

I’ve never flown a fighter aircraft, and I don’t believe I want to try it. (Nor do I think they would let me. Those planes are expensive.) I know only what I’ve seen in documentaries: you make too sharp a turn, the G force rises steeply to 7, 8, or 9 or thereabouts, and whoops...you’re out.

You come out of the turn; eventually you regain consciousness. But...you don’t remember what happened. You start to ask questions. Who am I? Where am I? Ahhh...now I remember. I’m in a cockpit! What’s that ahead? A mountain? The ground?

PHP does this. It forgets. When PHP runs as mod_php in an Apache process (the most common scenario), all the data gets dumped on each new HTTP request.

You can use session variables to create continuity. But even if you reconstitute your objects from session storage, message-passing between objects is interrupted. Communication is temporarily impaired, since all you have is the HTTP request. This is the background for the discussions in the previous chapter.

16.1. Controllers and request objects

16.2. Using Page Controllers

16.3. Building a Front Controller

16.4. Summary