CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.5 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.5
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
      • Exception
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

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.

Namespace: Cake\Console

Property 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.

  • 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.

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 $command): $this

Add a command to the collection

Parameters
string $name

The name of the command you want to map.

string|Cake\Console\Shell $command

The command to map.

Returns
$this

addMany() ¶ public

addMany(array $commands): $this

Add multiple commands at once.

Parameters
array $commands

A map of command names => command classes/instances.

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

autoDiscover() ¶ public

autoDiscover(): array

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
  • Plugin commands

Commands from plugins will be added based on the order plugins are loaded. Plugin shells will attempt to use a short name. If however, a plugin provides a shell that conflicts with CakePHP or the application shells, the full plugin_name.shell name will be used. Plugin shells are added in the order that plugins were loaded.

Returns
array

count() ¶ public

count(): int

Implementation of Countable.

Get the number of commands in the collection.

Returns
int

get() ¶ public

get(string $name): string|Cake\Console\Shell

Get the target for a command.

Parameters
string $name

The named shell.

Returns
string|Cake\Console\Shell
Throws
InvalidArgumentException
when unknown commands are fetched.

getIterator() ¶ public

getIterator(): ArrayIterator

Implementation of IteratorAggregate.

Returns
ArrayIterator

has() ¶ public

has(string $name): bool

Check whether the named shell exists in the collection.

Parameters
string $name

The named shell.

Returns
bool

remove() ¶ public

remove(string $name): $this

Remove a command from the collection if it exists.

Parameters
string $name

The named shell.

Returns
$this

Property Detail

$commands ¶ protected

Command list

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs