ronaldosantana
ronaldosantana

Reputation: 5252

Loading lib from plugin - cakephp

I have a plugin and inside the plugin I have a Lib folder. Like this:

Lib/Billing/CMS/CMS.php

How can I use the CMS class inside CMS.php on my controller? Not my plugin controller, but a controller on my application.

EDIT: Cake version is 2.3

Upvotes: 1

Views: 2061

Answers (1)

mark
mark

Reputation: 21743

So, from your short information one can only guess... Your plugin is "Billing"?

Your files are

APP/Plugin/Billing/Lib/CMS/CMS.php (class CMS)
APP/Plugin/Billing/Lib/Billing.php (class Billing)

You include classes always the same, using App::uses(). Then its

App::uses('CMS', 'Billing.CMS'); // Filename, Plugin.Package

and

App::uses('Billing', 'Billing.Lib'); // Lib as package namespace here due to lack of a proper one

I do not have to point out, that you need to load your plugin first, right? Using CakePlugin::load()/loadAll()

Upvotes: 1

Related Questions