Question

I'm new to Shell using CakePHP and I couldn't notice how there are 2 cake console application: one at app/Console/cake and other in lib/Console/cake being the second one the one in CakePHP's core.

So far, I have used lib/Console/cake bake -app /path/to/app to bake some MVC classes, but I have never used app/Console/cake before. Also lib/Console/cake is configured in my environment variables.

I want to know the difference of these 2, when to use one or another and why.

Note: I moved my core folder to a different directory, so naturally, app/Console/cake wont find ShellDispatcher, which line should I modify to set the new path to core library?

Was it helpful?

Solution

Are identical, but you should use the one inside app folder:

cd app/
./Console/cake bake

To change the default folder structure and config you must edit these files:

/app/webroot/index.php
/app/webroot/test.php

and un-Comment this line putting your core folder location:

// /usr/lib/mylocation    
define('CAKE_CORE_INCLUDE_PATH', DS . 'usr' . DS . 'lib' . DS . 'mylocation');

Take a look at the manual here: http://book.cakephp.org/2.0/en/installation/advanced-installation.html#sharing-cakephp-libraries-with-multiple-applications

OTHER TIPS

The difference

The difference between the two executables is that one derives the app location from the current working directory, and the other is application specific. This can be highlighted like so:

Normal usage:

www-data @ dev [ /tmp/cakephp ] (master=)
-> app/Console/cake 

Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------

Reference app executable from different path:

-> cd anywhere
-> /tmp/cakephp/app/Console/cake 

Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------

Note the app and path did not change.

cake in path

If /tmp/cakephp/lib/Cake/Console/ is in the path:

-> cd anywhere
-> cake 

Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : xxx
Path: **anywhere**
---------------------------------------------------------------

Note the app and path vary depending on where you are when executing the command.

If you always specify the -app flag, they will function the same, but you'll find it is problematic to use cake in your path if for example you have multiple applications on the same host using different versions of CakePHP.

Fixing paths

If you moved the cake folder, the files you need to edit are:

  • app/Console/cake.php ($root variable/include_path)
  • app/webroot/index.php (ROOT constant)
  • app/webroot/test.php (ROOT constant)

Only the first will affect cli usage.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top