Read the CakePHP docs on Components:

What is a Component?

Components are packages of logic that are shared between controllers. If you find yourself wanting to copy and paste things between controllers, you might consider wrapping some functionality in a component.


Assuming you want to create an Example component, it would be found at /app/Controller/Component/ExampleComponent.php:

class ExampleComponent extends Component {

    public function myMethod() {
        // your code here


Plugin components

If it Example plugin’s component, it would be found at /app/Plugin/Example/Controller/Component/ExampleComponent.php.

Using Components in Controllers

class RecipesController extends AppController {

    public $components = array(
        'Example', // 'Example.Example' if it is from Example plugin

    public function view($id)     {
        // call component method