Console not finding Shells in CakePHP for windows - php

I'm having trouble getting the cake console on winows (XAMPP) to see the demo shell
C:\xampp\htdocs\twitter\app\vendors\shells>dir
2011/03/31 21:11 <DIR> .
2011/03/31 21:11 <DIR> ..
2011/03/31 21:16 761 demo.php
2011/03/31 21:01 <DIR> tasks
2011/03/31 21:01 <DIR> templates
I have the demo.php shell in the shell directory.
C:\xampp\htdocs\twitter\app\vendors\shells>cake demo
Error: Class DemoShell could not be loaded.
But the cake console couldn't find it.
C:\xampp\htdocs\twitter\app\vendors\shells>cake
Welcome to CakePHP v1.3.7 Console
---------------------------------------------------------------
Current Paths:
-app: shells
-working: C:\xampp\htdocs\twitter\app\vendors\shells
-root: C:\xampp\htdocs\twitter\app\vendors
-core: C:\xampp\htdocs\twitter
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:
acl [CORE] i18n [CORE]
api [CORE] schema [CORE]
bake [CORE] testsuite [CORE]
console [CORE]
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
C:\xampp\htdocs\twitter\app\vendors\shells>
And it isn't recognised by the console itself. (note the core is reading from the correct directory).
It's probably some silly oversight but any idea what I am doing wrong here?

You should call cake [shell name] from within the app folder: C:\xampp\htdocs\twitter\app\>cake demo.
Please let me know if it works.

Read the error, it does not say 'file not found' it says 'class not found' so it would seem you have named the class incorrectly inside your demo.php shell
Error: Class DemoShell could not be loaded. that is a hint as to what it should be

Related

CakePHP shell script won't run as cron job

I have written a shell script that works perfectly when I test it locally.
bin/cake myshell method
But when I assign it as a crob it's not working. Instead I see the default cake output:
Welcome to CakePHP v3.1.4 Console
---------------------------------------------------------------
App : src
Path: /home/fantastagram/public_html/src/
PHP : 5.6.16
---------------------------------------------------------------
Current Paths:
* app: src
* root: /home/fantastagram/public_html
* core: /home/fantastagram/public_html/vendor/cakephp/cakephp
Available Shells:
[Migrations] migrations
[CORE] i18n, orm_cache, plugin, routes, server
[app] console, instagram
To run an app or core command, type `cake shell_name [args]`
To run a plugin command, type `cake Plugin.shell_name [args]`
To get help on a specific command, type `cake shell_name --help`
Content-type: text/html; charset=UTF-8
It appears that the two arguments to the script are being ignored. I'm using the cron jobs tool in the cPanel...
What am I doing wrong?
I turned on debugging and found that the script was actually erroring out before it to my parameters. I googled the error and it turned out to be this: Cakephp 3 bin/cake bake - Undefined variable: argv
Tweaked the php.ini config and it worked perfectly.

PHPUnit cannot open file

I've started learning how to use PHPUnit. However, I'm facing a problem which I have no clue how to solve.
I have a folder called lessons and inside there is a composer.json which I installed PHPUnit with.
The output resulted in a folder called vendor and a sub-folder called bin which has the phpunit file in it.
In the cmd I typed: cd c:/xampp/htdocs/lessons/vendor/bin. Now the cmd folder sets to the same folder as phpunit. I've created a directory in lessons which I called tests (lessons/tests) which I store all of my tests in. I've created a file called PracticeTest.php with a very simple test script in it.
When I go back to the cmd and type phpunit tests I get cannot open file tests.php When I try to type phpunit PracticeTest I get cannot open file PracticeTest.php. When I try phpunit tests/PracticeTest (with .php or without) I get the same error that the file could not be opened.
My suspicious that it has something to do with that face that the cmd is pointing at the lessons/vendor/bin directory, but I'm not sure if it is really the problem or how to fix it.
just to arrange the paths:
lessons\vendor\bin\
lessons\tests\
lessons\tests\PracticeTest.php
Thanks in advance!
Go to path project:
D:\>cd www
D:\wwww>cd lessons
And execute:
D:\www\lessons>vendor\bin\phpunit tests
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
.....E.
Time: 1.34 seconds, Memory: 5.50MB
There was 1 error:
1) UserTest::it_should_be_able_to_construct
PHPUnit_Framework_Exception: Argument #1 (No Value) of PHPUnit_Framework_Assert
:assertInstanceOf() must be a class or interface name
D:\www\lessons\tests\UserTest.php:10
FAILURES!
Tests: 7, Assertions: 4, Errors: 1.
It Works!!!!
This is what worked for me.
vendor/bin/phpunit ./tests/PracticeTest
I was getting the same, but if you type phpunit then tab you will see what directory you are in and it should autosuggest. Then navigate to your test file.
I had include_path sections separated by comma. It has to be semicolon on Windows.
I have created a phpunit.bat in the root folder of my project containing
#ECHO OFF SET BIN_TARGET=%~dp0/vendor/phpunit/phpunit/phpunit php "%BIN_TARGET%" %*
Now it works.

How to change the Cake Console in Ubuntu?

I have downloaded Cake PHP v2.7.0. Now, I need to change the console path for baking. What command should I use to change the console from current v1.3.0 to v2.7.0. I tried with the following commands
app/Console/cake bake
/var/www/project_name/app/Console/cake.php bake
But, still I am not getting updated with the console. I am using ubuntu OS. What command should I try to change the cake console in my system? When I get into the Console folder and execute the command "cake", I get the following warning:
PHP Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
PHP Stack trace:
PHP 1. {main}() /usr/share/php/cake/console/cake.php:0
PHP 2. ShellDispatcher->ShellDispatcher() /usr/share/php/cake/console/cake.php:664
PHP 3. ShellDispatcher->_initEnvironment() /usr/share/php/cake/console/cake.php:136
PHP 4. ShellDispatcher->__bootstrap() /usr/share/php/cake/console/cake.php:176
PHP 5. include_once() /usr/share/php/cake/console/cake.php:272
PHP 6. Cache->config() /usr/share/php/cake/console/templates/skel/config/core.php:304
PHP 7. Cache->_buildEngine() /usr/share/php/cake/libs/cache.php:141
PHP 8. FileEngine->init() /usr/share/php/cake/libs/cache.php:166
PHP 9. FileEngine->__active() /usr/share/php/cake/libs/cache/file.php:94
PHP 10. trigger_error() /usr/share/php/cake/libs/cache/file.php:281
Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
Call Stack:
0.0016 380824 1. {main}() /usr/share/php/cake/console/cake.php:0
0.0174 381144 2. ShellDispatcher->ShellDispatcher() /usr/share/php/cake/console/cake.php:664
0.1012 535216 3. ShellDispatcher->_initEnvironment() /usr/share/php/cake/console/cake.php:136
0.1013 538040 4. ShellDispatcher->__bootstrap() /usr/share/php/cake/console/cake.php:176
0.2275 1716776 5. include_once('/usr/share/php/cake/console/templates/skel/config/core.php') /usr/share/php/cake/console/cake.php:272
0.2300 1898096 6. Cache->config() /usr/share/php/cake/console/templates/skel/config/core.php:304
0.2300 1899448 7. Cache->_buildEngine() /usr/share/php/cake/libs/cache.php:141
0.2340 1956656 8. FileEngine->init() /usr/share/php/cake/libs/cache.php:166
0.2347 1959744 9. FileEngine->__active() /usr/share/php/cake/libs/cache/file.php:94
0.2647 2568904 10. trigger_error() /usr/share/php/cake/libs/cache/file.php:281
Welcome to CakePHP v1.3.14 Console
---------------------------------------------------------------
Current Paths:
-app: Console
-working: /var/www/cakelatest/app/Console
-root: /var/www/cakelatest/app
-core: /usr/share/php
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:
acl [CORE] i18n [CORE]
api [CORE] schema [CORE]
bake [CORE] testsuite [CORE]
console [CORE]
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
what am I missing in here?
PHP Warning: /usr/share/php/cake/console/templates/skel/tmp/cache/ is not writable in /usr/share/php/cake/libs/cache/file.php on line 281
Sounds like a permission Problem to me.
can you print here the output of
ls -la /usr/share/php/cake/console/templates/skel/tmp/cache | grep -e " \.$"
When you open the app in the web, cakephp change the /APP/tmp/ folder, you need run the cake command with the www-data user, you can use this command:
sudo www-data php Console/cake.php bake

not able to create controller from console : cakephp : showing fatal error

I am trying to create a controller in cakephp(1.3) using console. I am using windows XP and XAMPP.
My current cake console settings below
C:\xampp\htdocs\cake\apressblog\cake\console>cake
♀ Welcome to CakePHP v1.3.4 Console
--------------------------------------------------------------- Current Paths: -app: console
-working: C:\xampp\htdocs\cake\apressblog\cake\console
-root: C:\xampp\htdocs\cake\apressblog\cake
-core: C:\xampp\htdocs\cake\apressblog
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: acl [CORE]
i18n [CORE]
api [CORE]
schema [CORE]
bake [CORE]
testsuite [CORE]
console [CORE]
To run a command, type 'cake
shell_name [args]' To get help on a
specific command, type 'cake
shell_name help'
C:\xampp\htdocs\cake\apressblog\cake\console>-app
c:\xampp '-app' is not recognized as
an internal or external command,
operable program or batch file.
C:\xampp\htdocs\cake\apressblog\cake\console>
what are the path settings I need to set for creating a controller from console ?
I tried to change the app path but, when I type command cake It goes app directory to console,
Could you please help me to solve this issue
when I try to create a controller I am getting the following error :
C:\xampp\htdocs\cake\apressblog\cake\console>cake bake controller news
♀
Welcome to CakePHP v1.3.4 Console
---------------------------------------------------------------
App : console
Path: C:\xampp\htdocs\cake\apressblog\cake\console
---------------------------------------------------------------
Creating file C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_cont
roller.php
Wrote `C:\xampp\htdocs\cake\apressblog\cake\console\controllers\news_controller.
php`
You can download SimpleTest from http://simpletest.org
Bake is detecting possible fixtures..
Warning: include_once(C:\xampp\htdocs\cake\apressblog\cake\console\config\databa
se.php): failed to open stream: No such file or directory in C:\xampp\htdocs\cak
e\apressblog\cake\libs\model\connection_manager.php on line 23
Warning: include_once(): Failed opening 'C:\xampp\htdocs\cake\apressblog\cake\co
nsole\config\database.php' for inclusion (include_path='.;\xampp\php\PEAR') in C
:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on line 23
Fatal error: ConnectionManager::getDataSource - Non-existent data source default
in C:\xampp\htdocs\cake\apressblog\cake\libs\model\connection_manager.php on li
ne 102
C:\xampp\htdocs\cake\apressblog\cake\console>
You need to create your database.php file in the config folder so that Cake knows what database to connect to for the models.
Once you have done this you need to create your database schema and then bake the model for it.
I'd been having the same problem and was googling when I stumbled upon this. I was getting the same 'Warning: include_once...' error as you did.
I figured out this was happening only when I ran the 'cake bake' command from the ..\cake\console\ folder like you did.
So here's what fixed this issue for me. I added path to the console folder to my environment variables. Now I could call the cake bake command from anywhere.
Then I changed directory to your app folder e.g. ...\htdocs\myCakeWebsite\app
Then run 'cake bake' command! It worked fine from then on.
sources: http://www.youtube.com/watch?v=xvJH0wTlRg

cakephp console issue : not able to set path

I am trying to create a controller in cakephp(1.3) using console. I am using windows XP and XAMPP.
My current cake console settings below
C:\xampp\htdocs\cake\apressblog\cake\console>cake
♀ Welcome to CakePHP v1.3.4 Console
--------------------------------------------------------------- Current Paths: -app: console
-working: C:\xampp\htdocs\cake\apressblog\cake\console
-root: C:\xampp\htdocs\cake\apressblog\cake
-core: C:\xampp\htdocs\cake\apressblog
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: acl [CORE]
i18n [CORE]
api [CORE]
schema [CORE]
bake [CORE]
testsuite [CORE]
console [CORE]
To run a command, type 'cake
shell_name [args]' To get help on a
specific command, type 'cake
shell_name help'
C:\xampp\htdocs\cake\apressblog\cake\console>-app
c:\xampp '-app' is not recognized as
an internal or external command,
operable program or batch file.
C:\xampp\htdocs\cake\apressblog\cake\console>
what are the path settings I need to set for creating a controller from console ?
I tried to change the app path but, when I type command cake It goes app directory to console,
-app is a parameter for the cake command:
C:\...\console>cake -app C:\xampp\htdocs\cake\apressblog\app
You can also run cake console without problems, provided you're at the correct path. Try the following:
C:\xampp\htdocs\cake\apressblog\>C:\xampp\htdocs\cake\apressblog\cake\console\cake
or, to save yourself the trouble, add C:\xampp\htdocs\cake\apressblog\cake\console to the %PATH% environmental variable.

Categories