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.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 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:      * Contains tasks to load and instantiate
 34:      *
 35:      * @var array
 36:      */
 37:     public $tasks = ['Command'];
 38: 
 39:     /**
 40:      * Displays a header for the shell
 41:      *
 42:      * @return void
 43:      */
 44:     protected function _welcome()
 45:     {
 46:         $this->out();
 47:         $this->out(sprintf('<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
 48:         $this->hr();
 49:         $this->out(sprintf('App : %s', APP_DIR));
 50:         $this->out(sprintf('Path: %s', APP));
 51:         $this->out(sprintf('PHP : %s', PHP_VERSION));
 52:         $this->hr();
 53:     }
 54: 
 55:     /**
 56:      * startup
 57:      *
 58:      * @return void
 59:      */
 60:     public function startup()
 61:     {
 62:         if (!$this->param('xml') && !$this->param('version')) {
 63:             parent::startup();
 64:         }
 65:     }
 66: 
 67:     /**
 68:      * Main function Prints out the list of shells.
 69:      *
 70:      * @return void
 71:      */
 72:     public function main()
 73:     {
 74:         if (!$this->param('xml') && !$this->param('version')) {
 75:             $this->out('<info>Current Paths:</info>', 2);
 76:             $this->out('* app:  ' . APP_DIR . DIRECTORY_SEPARATOR);
 77:             $this->out('* root: ' . ROOT . DIRECTORY_SEPARATOR);
 78:             $this->out('* core: ' . CORE_PATH);
 79:             $this->out('');
 80: 
 81:             $this->out('<info>Available Shells:</info>', 2);
 82:         }
 83: 
 84:         if ($this->param('version')) {
 85:             $this->out(Configure::version());
 86: 
 87:             return;
 88:         }
 89: 
 90:         $shellList = $this->Command->getShellList();
 91:         if (!$shellList) {
 92:             return;
 93:         }
 94: 
 95:         if (!$this->param('xml')) {
 96:             $this->_asText($shellList);
 97:         } else {
 98:             $this->_asXml($shellList);
 99:         }
100:     }
101: 
102:     /**
103:      * Output text.
104:      *
105:      * @param array $shellList The shell list.
106:      * @return void
107:      */
108:     protected function _asText($shellList)
109:     {
110:         foreach ($shellList as $plugin => $commands) {
111:             sort($commands);
112:             $this->out(sprintf('[<info>%s</info>] %s', $plugin, implode(', ', $commands)));
113:             $this->out();
114:         }
115: 
116:         $this->out('To run an app or core command, type <info>`cake shell_name [args]`</info>');
117:         $this->out('To run a plugin command, type <info>`cake Plugin.shell_name [args]`</info>');
118:         $this->out('To get help on a specific command, type <info>`cake shell_name --help`</info>', 2);
119:     }
120: 
121:     /**
122:      * Output as XML
123:      *
124:      * @param array $shellList The shell list.
125:      * @return void
126:      */
127:     protected function _asXml($shellList)
128:     {
129:         $plugins = Plugin::loaded();
130:         $shells = new SimpleXMLElement('<shells></shells>');
131:         foreach ($shellList as $plugin => $commands) {
132:             foreach ($commands as $command) {
133:                 $callable = $command;
134:                 if (in_array($plugin, $plugins)) {
135:                     $callable = Inflector::camelize($plugin) . '.' . $command;
136:                 }
137: 
138:                 $shell = $shells->addChild('shell');
139:                 $shell->addAttribute('name', $command);
140:                 $shell->addAttribute('call_as', $callable);
141:                 $shell->addAttribute('provider', $plugin);
142:                 $shell->addAttribute('help', $callable . ' -h');
143:             }
144:         }
145:         $this->_io->setOutputAs(ConsoleOutput::RAW);
146:         $this->out($shells->saveXML());
147:     }
148: 
149:     /**
150:      * Gets the option parser instance and configures it.
151:      *
152:      * @return \Cake\Console\ConsoleOptionParser
153:      */
154:     public function getOptionParser()
155:     {
156:         $parser = parent::getOptionParser();
157: 
158:         $parser->setDescription(
159:             'Get the list of available shells for this CakePHP application.'
160:         )->addOption('xml', [
161:             'help' => 'Get the listing as XML.',
162:             'boolean' => true
163:         ])->addOption('version', [
164:             'help' => 'Prints the currently installed version of CakePHP. (deprecated - use `cake --version` instead)',
165:             'boolean' => true
166:         ]);
167: 
168:         return $parser;
169:     }
170: }
171: 
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