CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.7 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • CacheShell
  • CommandListShell
  • CompletionShell
  • I18nShell
  • OrmCacheShell
  • PluginShell
  • RoutesShell
  • SchemaCacheShell
  • ServerShell
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  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.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP Project
 12:  * @since         2.0.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Shell;
 16: 
 17: use Cake\Console\ConsoleOutput;
 18: use Cake\Console\Shell;
 19: use Cake\Core\Configure;
 20: use Cake\Core\Plugin;
 21: use Cake\Utility\Inflector;
 22: use SimpleXMLElement;
 23: 
 24: /**
 25:  * Shows a list of commands available from the console.
 26:  *
 27:  * @property \Cake\Shell\Task\CommandTask $Command
 28:  * @deprecated 3.5.0 Replaced by Cake\Shell\HelpShell
 29:  */
 30: class CommandListShell extends Shell
 31: {
 32: 
 33:     /**
 34:      * Contains tasks to load and instantiate
 35:      *
 36:      * @var array
 37:      */
 38:     public $tasks = ['Command'];
 39: 
 40:     /**
 41:      * Displays a header for the shell
 42:      *
 43:      * @return void
 44:      */
 45:     protected function _welcome()
 46:     {
 47:         $this->out();
 48:         $this->out(sprintf('<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
 49:         $this->hr();
 50:         $this->out(sprintf('App : %s', APP_DIR));
 51:         $this->out(sprintf('Path: %s', APP));
 52:         $this->out(sprintf('PHP : %s', PHP_VERSION));
 53:         $this->hr();
 54:     }
 55: 
 56:     /**
 57:      * startup
 58:      *
 59:      * @return void
 60:      */
 61:     public function startup()
 62:     {
 63:         if (!$this->param('xml') && !$this->param('version')) {
 64:             parent::startup();
 65:         }
 66:     }
 67: 
 68:     /**
 69:      * Main function Prints out the list of shells.
 70:      *
 71:      * @return void
 72:      */
 73:     public function main()
 74:     {
 75:         if (!$this->param('xml') && !$this->param('version')) {
 76:             $this->out('<info>Current Paths:</info>', 2);
 77:             $this->out('* app:  ' . APP_DIR . DIRECTORY_SEPARATOR);
 78:             $this->out('* root: ' . ROOT . DIRECTORY_SEPARATOR);
 79:             $this->out('* core: ' . CORE_PATH);
 80:             $this->out('');
 81: 
 82:             $this->out('<info>Available Shells:</info>', 2);
 83:         }
 84: 
 85:         if ($this->param('version')) {
 86:             $this->out(Configure::version());
 87: 
 88:             return;
 89:         }
 90: 
 91:         $shellList = $this->Command->getShellList();
 92:         if (!$shellList) {
 93:             return;
 94:         }
 95: 
 96:         if (!$this->param('xml')) {
 97:             $this->_asText($shellList);
 98:         } else {
 99:             $this->_asXml($shellList);
100:         }
101:     }
102: 
103:     /**
104:      * Output text.
105:      *
106:      * @param array $shellList The shell list.
107:      * @return void
108:      */
109:     protected function _asText($shellList)
110:     {
111:         foreach ($shellList as $plugin => $commands) {
112:             sort($commands);
113:             $this->out(sprintf('[<info>%s</info>] %s', $plugin, implode(', ', $commands)));
114:             $this->out();
115:         }
116: 
117:         $this->out('To run an app or core command, type <info>`cake shell_name [args]`</info>');
118:         $this->out('To run a plugin command, type <info>`cake Plugin.shell_name [args]`</info>');
119:         $this->out('To get help on a specific command, type <info>`cake shell_name --help`</info>', 2);
120:     }
121: 
122:     /**
123:      * Output as XML
124:      *
125:      * @param array $shellList The shell list.
126:      * @return void
127:      */
128:     protected function _asXml($shellList)
129:     {
130:         $plugins = Plugin::loaded();
131:         $shells = new SimpleXMLElement('<shells></shells>');
132:         foreach ($shellList as $plugin => $commands) {
133:             foreach ($commands as $command) {
134:                 $callable = $command;
135:                 if (in_array($plugin, $plugins)) {
136:                     $callable = Inflector::camelize($plugin) . '.' . $command;
137:                 }
138: 
139:                 $shell = $shells->addChild('shell');
140:                 $shell->addAttribute('name', $command);
141:                 $shell->addAttribute('call_as', $callable);
142:                 $shell->addAttribute('provider', $plugin);
143:                 $shell->addAttribute('help', $callable . ' -h');
144:             }
145:         }
146:         $this->_io->setOutputAs(ConsoleOutput::RAW);
147:         $this->out($shells->saveXML());
148:     }
149: 
150:     /**
151:      * Gets the option parser instance and configures it.
152:      *
153:      * @return \Cake\Console\ConsoleOptionParser
154:      */
155:     public function getOptionParser()
156:     {
157:         $parser = parent::getOptionParser();
158: 
159:         $parser->setDescription(
160:             'Get the list of available shells for this CakePHP application.'
161:         )->addOption('xml', [
162:             'help' => 'Get the listing as XML.',
163:             'boolean' => true
164:         ])->addOption('version', [
165:             'help' => 'Prints the currently installed version of CakePHP. (deprecated - use `cake --version` instead)',
166:             'boolean' => true
167:         ]);
168: 
169:         return $parser;
170:     }
171: }
172: 
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs