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

  • Arguments
  • Command
  • CommandCollection
  • CommandFactory
  • CommandRunner
  • ConsoleErrorHandler
  • ConsoleInput
  • ConsoleInputArgument
  • ConsoleInputOption
  • ConsoleInputSubcommand
  • ConsoleIo
  • ConsoleOptionParser
  • ConsoleOutput
  • Helper
  • HelperRegistry
  • HelpFormatter
  • Shell
  • ShellDispatcher
  • TaskRegistry

Interfaces

  • CommandCollectionAwareInterface
  • CommandFactoryInterface

Class CommandCollection

Collection for Commands.

Used by Applications to whitelist their console commands. CakePHP will use the mapped commands to construct and dispatch shell commands.

Cake\Console\CommandCollection implements IteratorAggregate, Countable
Namespace: Cake\Console
Location: Console/CommandCollection.php

Properties summary

  • $commands protected
    array
    Command list

Method Summary

  • __construct() public
    Constructor
  • add() public
    Add a command to the collection
  • addMany() public
    Add multiple commands at once.
  • autoDiscover() public
    Automatically discover shell commands in CakePHP, the application and all plugins.
  • count() public
    Implementation of Countable.
  • discoverPlugin() public
    Auto-discover shell & commands from the named plugin.
  • get() public
    Get the target for a command.
  • getIterator() public
    Implementation of IteratorAggregate.
  • has() public
    Check whether the named shell exists in the collection.
  • remove() public
    Remove a command from the collection if it exists.
  • resolveNames() protected
    Resolve names based on existing commands

Method Detail

__construct() public ¶

__construct( array $commands = [] )

Constructor

Parameters
array $commands optional []
The map of commands to add to the collection.

add() public ¶

add( string $name , string|Cake\Console\Shell|Cake\Console\Command $command )

Add a command to the collection

Parameters
string $name
The name of the command you want to map.
string|Cake\Console\Shell|Cake\Console\Command $command
The command to map.
Returns

$this
Throws
InvalidArgumentException

addMany() public ¶

addMany( array $commands )

Add multiple commands at once.

Parameters
array $commands
A map of command names => command classes/instances.
Returns

$this
See
\Cake\Console\CommandCollection::add()

autoDiscover() public ¶

autoDiscover( )

Automatically discover shell commands in CakePHP, the application and all plugins.

Commands will be located using filesystem conventions. Commands are discovered in the following order:

  • CakePHP provided commands
  • Application commands

Commands defined in the application will ovewrite commands with the same name provided by CakePHP.

Returns
string[]
An array of command names and their classes.

count() public ¶

count( )

Implementation of Countable.

Get the number of commands in the collection.

Returns
integer
Implementation of
Countable::count()

discoverPlugin() public ¶

discoverPlugin( string $plugin )

Auto-discover shell & commands from the named plugin.

Discovered commands will have their names de-duplicated with existing commands in the collection. If a command is already defined in the collection and discovered in a plugin, only the long name (plugin.command) will be returned.

Parameters
string $plugin
The plugin to scan.
Returns
string[]
Discovered plugin commands.

get() public ¶

get( string $name )

Get the target for a command.

Parameters
string $name
The named shell.
Returns
string|Cake\Console\Shell
Either the shell class or an instance.
Throws
InvalidArgumentException
when unknown commands are fetched.

getIterator() public ¶

getIterator( )

Implementation of IteratorAggregate.

Returns
ArrayIterator
Implementation of
IteratorAggregate::getIterator()

has() public ¶

has( string $name )

Check whether the named shell exists in the collection.

Parameters
string $name
The named shell.
Returns
boolean

remove() public ¶

remove( string $name )

Remove a command from the collection if it exists.

Parameters
string $name
The named shell.
Returns

$this

resolveNames() protected ¶

resolveNames( array $input )

Resolve names based on existing commands

Parameters
array $input
The results of a CommandScanner operation.
Returns
string[]
A flat map of command names => class names.

Properties detail

$commands ¶

protected array

Command list

[]
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