Example
initialize() is introduced in CakePHP version > 3.0
As a code structure, it looks like same as beforeFilter() method. but there is many differences between beforeFilter() and initialize().
- initialize() is always called after constructor is called. but beforeFilter() is not calling in case of action method not found in particular controller.
- initialize() method is generally used for initialize something like add new components and helpers. but in beforeFilter() is generally used for execute some global logic part.