1

Background: Basically, my application has a plugin which has a Shell within it. This Shell is located in the plugin's Console > Command folder. Functions from this shell are intended to be ran from the command line.

My database configuration file (database.php) is located in the application's root Config folder. I access the database in several other instances so I know there's nothing wrong with the database configuration.

When I try to use any Model data retrieval methods (such as find(...)), I get the error:

The datasource configuration "default" was not found in database.php

This is occurring because it's looking for the database.php file inside the Plugin's Config folder, rather than the root Config folder. This only occurs when using a Shell, rather than in a Controller.

My Question: How can I tell my Plugin to use the root's database.php file instead of trying to find it in it's own Config folder, when using a Shell?

To reiterate: The Plugin uses the root Config/database.php file when retrieving data from a model in a Controller, but tries to use its own Config/database.php file when retrieving data from a model in a Shell.

Two things that I've tried that will work: 1) Moving database.php into the Plugin's Config folder and 2) Creating a symbolic link.

Both solutions seem unacceptable as I don't want to have two copies of my database.php file around, and creating a symbolic link isn't a great solution since this application will likely have to be distributing among different systems.

Thanks. I should mention that this is Cakephp 2.3.6

Answer (thanks user221931): Your working path needs to be the application path, not the plugin path. You can run the plugin shell using the plugin dot notation. Like this:

cake -app /path/to/app Plugin.shellName shellFunction

as opposed to how I was incorrectly doing it before:

cake -app /path/to/app/Plugin/pluginName shellName shellFunction

1 Answer 1

1

How about running the plugin shell using -app?

Changing Paths: Your working path should be the same as your application path. To change your path use the '-app' param. Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp

Sign up to request clarification or add additional context in comments.

3 Comments

I already am... I have no problems running the plugin shell itself using "cake -app /path/to/plugin shellName shellFunction". Or do I need to run it something like "cake -app /path/to/app plugin.shellName shellFunction"? Is that possible?
Apparently you can, I'll update my question to better explain how the answer helped me. Thanks!
I am running cake shell command from my app root path with the way suggested as Plugin.shell but i dont get any output on console? from app root path 'cake PluginName.Hello hey_their' and i have also tried 'cake -app /var/www/app PluginName.Hello hey_their'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.