Report this

What is the reason for this report?

I need to know where to put controller and model for creating Themes as plugins in cakephp 3

Posted on November 2, 2017

I am working on Cakephp 3. I am little bit confused. I have created theme as a plugin and i want to know whether to code it in theme folder or main project folder. I want to know the general rule how to work with theme when used as a plugin, its controllers and model will be in theme folder or i have to use main application controller folder.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Just a quick follow-up on this question in case anyone comes across this in the future.

You can put them in plugins/MyPlugin/src/ for example, and then to load the classes automatically, you can add the following to your composer.json file:

{
    **"autoload"**: {
        **"psr-4"**: {
            **"MyPlugin\\"**: "plugins/MyPlugin/src/"
        }
    },
    **"autoload-dev"**: {
        **"psr-4"**: {
            **"MyPlugin\\Test\\"**: "plugins/MyPlugin/tests/"
        }
    }
}

For more information here is a link to the official docs:

https://book.cakephp.org/3/en/plugins.html

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.