What is the CakePHP request life cycle?

Spoiler: I would like to better understand the request life cycle in CakePHP application.

Background: I'm on CakePHP v2.3. I am debugging a problem that leads to unwanted redirects that I cannot find. I am trying to fulfill my request life cycle by adding incrementally die()to try to determine where the redirect occurs.

I am at a dead end because I can kill the execution from inside the beforeFilter () controller, but the redirection happens if I move die()to the actual action.

So my specific question is: what happens after beforeFilter, but before the action? I know beforeRender (), which had no effect when I posted die()there.

My more general / better question is: is there any documentation for the full CakePHP request life cycle?

The answer to any of them would be wonderful.

Update

Thanks to Matthew F.’s helpful suggestions, I am focusing on the Auth component because it’s almost the only candidate and the redirect I am debugging looks like handiwork (the user comes to the authRedirect location). However, when I finish die()at the top of the AppController isAuthorized(), nothing happens. And my controller does not have isAuthorized(). So that again puzzled me a little.

+4
source share
2 answers

, beforeFilter(), , die() .

, .

beforeFilter() , - . . . , (.. AuthComponent ).

, : beforeFilter, ? beforeRender(), , die() .

. . . initialize(). beforeFilter(). startup(). .

http://book.cakephp.org/2.0/en/controllers/components.html#component-api

, , . - echo "hello" index.php -. header can not be modified , .

+8

! :

Typical request

  • , http://www.example.com/cakes/buy, -.
  • URL-, : , , - .
  • , URL- ( ). buy() CakesController. callers beforeFilter() .
  • . Ricardos . , . , CakePHP .
  • , , . .
  • (, , ).
  • , , set() . . , / . .
  • (, AfterFilter). , Ricardos.
+7

All Articles