Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Kohana use before() and after()

Tags:

php

kohana

I've just started having a play with Kohana, coming from CodeIgniter and straight php. I was wondering why Kohana uses the before() and after() functions rather than normal constructors and destructors?

like image 615
Cubed Eye Avatar asked Feb 21 '23 23:02

Cubed Eye


1 Answers

There's a subtle difference between the 2:

The constructor and destructor are called when an instance is created and destroyed.

The before and after methods are called before and after an action of a controller is executed.

Besides that, you can't guarantee the constructor and destructor are called before and after the action is executed, but you can guarantee that for the before and after methods.

like image 164
SpadXIII Avatar answered Feb 24 '23 13:02

SpadXIII