PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 21, 2022

[FIXED] Where to put controllers of main application in cakephp when theme is used as plugin

 April 21, 2022     cakephp, cakephp-2.0, cakephp-2.3, cakephp-3.0     No comments   

Issue

I new to cakephp, i have created plugin of theme named Amuk

enter image description here

Now i want to do my application coding, i have doubt regarding where i have to put application controller, in the main src folder or in the /plugins/Amuk/src/Controller/. Second doubt is where i will put my view file. Here i have created default.ctp inside Layout folder, but where shouls i put my other views that are to be rendered inside this default view. Please help to clear my doubts or give up some usefull links to start with. I am using Latest Version of Cakephp.


Solution

The rules for naming files in a plugin is the same as for the main application. Your controllers go in the Controller folder, e.g. Controller/ThingsController.php. Your templates go in a folder under Templates, named the same as the controller, so Template/Things/index.ctp for example. See Conventions and Folder Structure in the manual for more complete details.

But the easiest thing to do might be to use the bake tool (e.g. bin/cake bake -p Amuk) to have it generate skeleton code for you. It will put all the files in the right places, correctly named, with correct namespaces, generate inputs in the edit page based on fields it finds in the database, lots of useful stuff. Anything it generates that you don't need, just delete. See Code Generation with Bake for more details on this.



Answered By - Greg Schmidt
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing