tags:

views:

369

answers:

3

Hello,

I am just getting started with Cakephp shell and running into issues. My cake core library is under path d:/libs/cake My app is setup under d:/servers/htdocs/myapp

I wrote a test shell under d:/servers/htdocs/myapp/vendor/shells


class ReportShell extends Shell {
 var $uses = array('Appt');
 function main() {
  echo $this->Appt->find('first');


 }
}

When I try to run this code from d:/servers/htdocs/myapp , It gives me an error


Warning: include_once(d:/servers/htdocs/myapp/config/database.php): failed to open stream: No such file or directory in d:/libs/cake\libs\mode l\connection_manager.php on line 23

Warning: include_once(): Failed opening 'd:/servers/htdocs/myapp/config/database.php' for inclusion (include_path='.;D:\work\xampp\php\PEAR') in d:/libs/cake\libs\model\connection_manager.php on line 23

Fatal error: ConnectionManager::getDataSource - Non-existent data source default in d:/libs/cake\libs\model\connection_manager.php on line 102


Reason is that it is trying to find database.php under 'd:/servers/htdocs/myapp/config/' and the correct path is 'd:/servers/htdocs/myapp/app/config/database.php'

What am I doing wrong here?

thanks

A: 

Try to run it from within the /app directory or with the -app parameter specified:

cake -app d:/servers/htdocs/myapp/app report
deceze
I did but get this error:Error: Class ReportShell could not be loaded
aboxy
A: 

My app is setup under d:/servers/htdocs/myapp

No, the application directory (holding the config folder) is D:\servers\htdocs\myapp\app\.

Reason is that it is trying to find database.php under 'd:/servers/htdocs/myapp/config/' and the correct path is 'd:/servers/htdocs/myapp/app/config/database.php'

You are in the wrong directory, therefore it can't find your database config.

I wrote a test shell under d:/servers/htdocs/myapp/vendor/shells

Move your shell out of the global vendors folder at D:\servers\htdocs\myapp\vendors\shells to the application's vendors folder at D:\servers\htdocs\myapp\app\vendors\shells instead and try again.

(Note: I'm not actually sure where the global vendors folder should be when you have a setup where the cake and application directories are split from each other, but you definitely have to be in your application directory when running commands and not the myapp directory you're using.)


If you add D:\libs\cake\console\ to your PATH environment variable (remembering to close all cmd.exe processes afterwards) then you will simply be able to execute the following:

D:\servers\htdocs\myapp\app> cake report (from within the application directory)

Otherwise you will need to type the full relative or absolute path to the cake console executable and/or provide CakePHP with the absolute path to the application directory (if you are not in it):

D:\servers\htdocs\myapp\app> ..\..\..\..\libs\cake\console\cake report

D:\servers\htdocs\myapp\app> \libs\cake\console\cake report

D:\libs\cake\console> cake -app D:\servers\htdocs\myapp\app report

D:\> libs\cake\console\cake -app D:\servers\htdocs\myapp\app report

etc...

Hopefully you can see why just adding the correct folder to your PATH makes things a lot easier. :)

deizel
Thanks. Here was the issueMy shell script was under /myapp/vendor/shells which was wrong. It should have been under /myapp/app/vendor/shells. After I moved the file, it worked. Thank you.
aboxy
A: 

Thanks. Here was the issue My shell script was under /myapp/vendor/shells which was wrong. It should have been under /myapp/app/vendor/shells. After I moved the file, it worked. Thank you

aboxy