John Davidson

cakephp - Cake PHP 2 turn off default console output from shell commands

0 comments
Message:


I've written a custom shell in Cake PHP 2 under the Console/cake my_shell command, and have added my own $this->out() messages in places. Each time I run my shell, I get the default cake output first such as the path, and a welcome message. I'd like to disable these specifically for my shell but can't seem to find a setting to do so.


Welcome to CakePHP v2.10.18 Console
---------------------------------------------------------------
App : app
Path: /Users/user/Sites/project/app/
---------------------------------------------------------------


My Answer:
out() calls to display output. However, Cake PHP also outputs some default information such as the CakePHP version and the command being executed. Is there a way to turn off this default output so that only my custom output is displayed?

Yes, you can turn off the default console output from shell commands in Cake PHP 2 by setting the 'quiet' option to true in your shell's $options property. Here's an example of how you can do this:

php
class MyShell extends AppShell {
public $options = array(
'quiet' => true
);

public function main() {
$this->out('Custom output');
}
}


By setting 'quiet' to true in the $options property of your shell, Cake PHP will not output the default information when the shell command is executed. Only your custom output will be displayed.

Rate this post

3 of 5 based on 6077 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us