3 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
6 * Licensed under The MIT License
7 * For full copyright and license information, please see the LICENSE.txt
8 * Redistributions of files must retain the above copyright notice.
10 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11 * @link http://cakephp.org CakePHP(tm) Project
13 * @license http://www.opensource.org/licenses/mit-license.php MIT License
17 use Cake\Console\ConsoleOptionParser;
18 use Cake\Console\Shell;
20 use Psy\Shell as PsyShell;
23 * Simple console wrapper around Psy\Shell.
25 class ConsoleShell extends Shell
29 * Start the shell and interactive console.
33 public function main()
35 if (!class_exists('Psy\Shell')) {
36 $this->err('<error>Unable to load Psy\Shell.</error>');
38 $this->err('Make sure you have installed psysh as a dependency,');
39 $this->err('and that Psy\Shell is registered in your autoloader.');
41 $this->err('If you are using composer run');
43 $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
46 return self::CODE_ERROR;
49 $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
54 $this->_io->setLoggers(false);
55 restore_error_handler();
56 restore_exception_handler();
58 $psy = new PsyShell();
63 * Display help for this console.
65 * @return \Cake\Console\ConsoleOptionParser
67 public function getOptionParser()
69 $parser = new ConsoleOptionParser('console');
70 $parser->setDescription(
71 'This shell provides a REPL that you can use to interact ' .
72 'with your application in an interactive fashion. You can use ' .
73 'it to run adhoc queries with your models, or experiment ' .
74 'and explore the features of CakePHP and your application.' .
76 'You will need to have psysh installed for this Shell to work.'