Code generation with CakePHP

How to set up console to generate code with cakephp?

Cakephp is a powerfull php framework that can generate working codes for you within minutes. To generate code cakephp uses console. There are step by step tutorial about how to set up all.

Step:1- Open command prompt using (window+R) key
Sttep:2- Check if its working already, tpye (cake) in console window. If it shows something like

'cake' is not recognized as an internal or external command
then you have to set up path environment variable.

Step:3 - You need to supply php.exe path and console script path which resides in lib\cake\console
So right click on my computer->properties->advanced system settings->Environment Variables->System variables->path->edit. Then in variable value you will see several values separated with (;) sign, you have to put your path here.
Just make a ; in last if not already there and paste your path here

If your xampp or wamp is under d:\xampp then

D:\xampp\php;

and if your cakephp folder name is cake then

D:\xampp\htdocs\cake\lib\Cake\Console;

putting it all together looks like

D:\xampp\php;D:\xampp\htdocs\cake\lib\Cake\Console;

Now its all done.

Step 4:- check its working or not by typing previous command (cake)

now it should produce result like this

Welcome to CakePHP v2.5.4 Console

Now you can use cake to bake your code, model, view, controller or projects

For baking a project navigate to folder where you want to create project and type

cake bake project myapp

this will successfully create your skelton project.

No comments: