cakephp Error: Class WidgetShell could not be loaded - cakephp-2.0

I'm using CakePHP 2.0, and my command line cake settings as follows. Surprisingly the command works fine in windwos environment
App : app
Path : /var/www/qa/app/
Current Paths:
-app: app
-working: /var/www/qa/app
-root: /var/www/qa
-core: /var/www/qa/lib
Available Shells:
acl [CORE] i18n [CORE]
acl_extras [AclExtras] schema [CORE]
api [CORE] template [app]
bake [CORE] testsuite [CORE]
command_list [CORE] upgrade [CORE]
console [CORE] widget [app]
I can able to see the widget [app] shell command listed above
When I run the following command
webtools#local:/var/www/qa/app$ ./Console/cake widget
Error: Shell class WidgetShell could not be found.
#0 /var/www/qa/lib/Cake/Console/ShellDispatcher.php(167): ShellDispatcher >_getShell('widget')
#1 /var/www/qa/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch()
#2 /var/www/qa/app/Console/cake.php(41): ShellDispatcher::run(Array)
#3 {main}
#3 {main}
What could be the problem. I have gone through all the similar kind of issue in the forum!. I couldn't find the answer.
I really appreciate your help in this.

It's interesting. I had the named of the file as 'Widget.php'. it works fine in windows. But in Linux/Mac it didn't.
I changed the filename to 'WidgetShell.php' it started working. I should have noticed the issue little early, spent lot of hours ;)

Related

Cake\Routing\Router not found in shell after migration to cakephp-4

After updating my app from 3.9 to 4.1.4 shell scripts stopped working. Typing this bin/cake plugin assets symlink yields this error message:
PHP Fatal error: Uncaught Error: Class 'Cake\Routing\Router' not found in /var/www/releases/12/vendor/cakephp/cakephp/config/bootstrap.php:27
Stack trace:
#0 /var/www/releases/12/config/bootstrap.php(32): require()
#1 /var/www/releases/12/bin/cake.php(31): include('/var/www/...')
#2 {main}
thrown in /var/www/releases/12/vendor/cakephp/cakephp/config/bootstrap.php on line 27
I assume there is something wrong with autoloading, but I don`t know where to start with this.
It turns out I did not replace the contents of the bin folder. They have changed with the new major version of cakephp and must be replaced with the files from the app-skeleton: https://github.com/cakephp/app/tree/master/bin

How do you run a global plugin's shell in CakePHP 2?

I have a shell located in PluginName/Console/Command/FooShell.php in CakePHP 2.6.3.
I've loaded this plugin via CakePlugin::load('PluginName'); in my app's bootstrap.php.
When that plugin is in ROOT/app_name/Plugin, and I run PluginName.foo, the shell works.
When that plugin is in ROOT/plugins and I run the same command, I get an error:
The command:
C:\xampp\htdocs\site_name\app_name>php Console/cake.php -app app_name PluginName.foo
The error:
Warning Error: include(C:\xampp\htdocs\site_name\app_name\Plugin\PluginName\Console\Command\FooShell.php): failed to open stream: No such file or directory in [C:\xampp\htdocs\site_name\lib\Cake\Core\App.php, line 547]
Warning Error: include(): Failed opening 'C:\xampp\htdocs\site_name\app_name\Plugin\PluginName\Console\Command\FooShell.php' for inclusion (include_path='C:\xampp\htdocs\site_name\lib;.;C:\xampp\php\PEAR') in [C:\xampp\htdocs\site_name\lib\Cake\Core\App.php, line 547]
Error: Shell class FooShell could not be found.
#0 C:\xampp\htdocs\site_name\lib\Cake\Console\ShellDispatcher.php(200): ShellDispatcher->_getShell('PluginName.back...')
#1 C:\xampp\htdocs\site_name\lib\Cake\Console\ShellDispatcher.php(66): ShellDispatcher->dispatch()
#2 C:\xampp\htdocs\site_name\app_name\Console\cake.php(33): ShellDispatcher::run(Array)
#3 {main}
For some reason, CakePHP is fine with this plugin being in ROOT/plugins when it's serving actual webpages, but throws an error in the console.
Nothing in the shell docs or the plugin docs explicitly says that there's anything different about using plugins in ROOT/plugins, but discussion of how that directory is used is conspicuously absent from the plugin and folder structure docs. (I assume because it's implied you're supposed to implement plugins the same way, regardless of which directory they're in.)
Am I doing this wrong?
when it is in the ROOT/plugins directory you need to load it like this in ROOT/lib/Cake/bootstrap.php
App::build(array('Plugin' => array(CAKE . DS . 'plugins' . DS)));
CakePlugin::load('<plugin-name>');

CakePHP bake Error: Database connection "Mysql" is missing, or could not be created

I've already checked other questions and answers regarding my issue and nothing seems to help resolving it.
I'm using vagrant percise64 (ubuntu server 12.04) with lamp installed.
On my host (desktop) I have myfinalproject dir containing extracted cakePHP version 2.3.5.
I've set all that cakePHP required and on the generated page of cakePHP it says that "Cake is able to connect to the database."
When I try to bake a new Model/Controller or All I get the following error:
Welcome to CakePHP v2.3.5 Console
---------------------------------------------------------------
App : app
Path: /home/shahar/development/myfinalproject/app/
---------------------------------------------------------------
Interactive Bake Shell
---------------------------------------------------------------
[D]atabase Configuration
[M]odel
[V]iew
[C]ontroller
[P]roject
[F]ixture
[T]est case
[Q]uit
What would you like to Bake? (D/M/V/C/P/F/T/Q)
> m
---------------------------------------------------------------
Bake Model
Path: /home/shahar/development/myfinalproject/app/Model/
---------------------------------------------------------------
Use Database Config: (default/test)
[default] > default
Error: Database connection "Mysql" is missing, or could not be created.
#0 /home/shahar/development/myfinalproject/lib/Cake/Model/ConnectionManager.php(107): DboSource->__construct(Array)
#1 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(900): ConnectionManager::getDataSource('default')
#2 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(837): ModelTask->getAllTables(NULL)
#3 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(926): ModelTask->listAll(NULL)
#4 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(205): ModelTask->getName()
#5 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/Task/ModelTask.php(93): ModelTask->_interactive()
#6 /home/shahar/development/myfinalproject/lib/Cake/Console/Command/BakeShell.php(108): ModelTask->execute()
#7 /home/shahar/development/myfinalproject/lib/Cake/Console/Shell.php(392): BakeShell->main()
#8 /home/shahar/development/myfinalproject/lib/Cake/Console/ShellDispatcher.php(200): Shell->runCommand(NULL, Array)
#9 /home/shahar/development/myfinalproject/lib/Cake/Console/ShellDispatcher.php(68): ShellDispatcher->dispatch()
#10 /home/shahar/development/myfinalproject/app/Console/cake.php(37): ShellDispatcher::run(Array)
#11 {main}
I've tried to run the bake command from my app dir (though i see the path is ok) and I got the same error.
I've change in my database.php the localhost to 127.0.0.1 and still same error occurs.
What am I missing here?
Edit: Since people suggested i'll check PDO extension availability I did a tiny test.
I used:
vagrant#precise64:/etc/php5/cli$ php -i | grep -i pdo
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
PDO
PDO support => enabled
PDO drivers => mysql
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
Did you enabled pdo module for cli? I think that you can have different php.ini for cli / web (fpm).
Just to help Ubuntu users out:
I had the same error in my ubuntu 13.10 machine with the newest xampp downloaded directly from apachefriends.
Try this:
Find the socket that mysqld creates for programs to connect to:
user#host /opt$ find . -name mysql.sock
/opt/lampp/var/mysql/mysql.sock
add it to your cakePHP database configuration file (cakePHP)/app/Config/database.php
'unix_socket' => '/opt/lampp/var/mysql/mysql.sock'
To me, this finally resulted in my cake commands being able to be executed without the "Error: Database connection "Mysql" is missing, or could not be created.".
on apache start if you get a warning that says something along the lines of apache not resolving hostname, using 127.0.1.1.. this may cause problems later with cakephp.
solution: sudo nano /etc/apache2/apache2.config , add the line:
ServerName localhost
Try to (re)install PHP MySQL support
sudo apt-get install php5-mysql
For me it turned out to be that the server variable $_SERVER['HTTP_HOST'] was not available in the database.php config file so my specific config was not being set correctly when running in a Shell.
$_SERVER['HTTP_HOST'] is not available during Shell execution.

Google App Engine: Downloading Source: Could not find or load main class com.google.appengine.tools.admin.AppCfg

I'm an owner on a project and I would like to pull down the war on GAE. Through Cygwin, when I try to do this:
./appengine-java-sdk/bin/appcfg.sh download_app -A sampleapp -V
I get the following error:
Error: Could not find or load main class com.google.appengine.tools.admin.AppCfg
I suspect that this might be because I am behind a corporate firewall, but I have already configured my cygwin to reroute through a proxy.
Does anyone have other suggestions as to what might be the cause?
This worked out for me.
sh appcfg.sh vacuum_indexes /ProjectPath/war
I could see in lot of document that the appcfg.cmd should be used but that didn't work but the above one looked good.

Cakephp database migration error

I am using Ubuntu + cakephp 1.3. I am trying the database migration with the help of cakeDC migration plugin. I configured the plugin as per the instructions.
But when i goes to the terminal, goes to the path of the application application_path/app/ dir then fire a command 'cake migration help' it gives me following error,
Hello user,
Welcome to CakePHP v1.2 Console
Current Paths:
-working: /path/to/cake/
-root: /path/to/cake/
-app: /path/to/cake/app/
-core: /path/to/cake/
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
Available Shells:
app/vendors/shells/:
- none
vendors/shells/:
- none
cake/console/libs/:
acl
api
bake
console
extract
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
Then i followed the steps given in the :
http://book.cakephp.org/view/108/The-CakePHP-Console
$ cake -app /path/to/app
But i am not getting the success. Can anybody help me out from this issue...
Thanks in adavnce.
You're executing cake shell, which is somewhere in your $PATH (type which cake to see which one comes in $PATH first). To run cake shell belonging to your app (version 1.3), execute /path/to/your/application/cake/console/cake (if you're in your /app dir, simply execute ../cake/console/cake) with any options you may need (like -app).

Resources