To reduce your consuming time in writing code, CakePHP provides its in-built PHP-CLI named as bin/cake . You need to just install this through composer and setting it’s PATH depending on your system. Then you can enjoy the magic of it.
Before using this make sure you have a working connection with DB.
To check if it has been properly installed try the following command from your application’s root directory using Terminal or Command Prompt:
This will show you the list of all available features. I am going with CakePHP 3.* version.
To generate controller files use the following command:This will generate UsersController file in /your_web_root/src/controller/UsersController.php . The above command will also generate Test Controller. If you don’t want to generate Controllers for use --no-test as :PHP1bin/cake bake controller UsersShell1bin/cake bake controller Users --no-test
To create your own plugin with CakePHP useAnd generating Controllers for your CakePHP Plugin use :Shell1bin/cake plugin PluginNameShell1bin/cake bake controller --plugin PluginName --no-test --force Users
If you want to generate basic CURD oepertaion views for your predefined Database tables / model in CakePHP use following command :For generating view/ templates for perticular Model use:Shell1bin/cake bake template allHere <modelName> is your model and action is name of your method. It may be having values like : create, update, listAll etc.Shell1bin/cake bake template <modelName> <action>
I am also exploring the rest of the commands as I am new to CakePHP, and will add here in future. Please suggest if you have more. Stay Tuned!