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 5.1 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.1
      • 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
    • Cache
    • Collection
    • Command
    • Console
      • Command
      • Exception
      • TestSuite
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class HelpFormatter

HelpFormatter formats help for console shells. Can format to either text or XML formats. Uses ConsoleOptionParser methods to generate help.

Generally not directly used. Using $parser->help($command, 'xml'); is usually how you would access help. Or via the --help=xml option on the command line.

Xml output is useful for integration with other tools like IDE's or other build tools.

Namespace: Cake\Console

Property Summary

  • $_alias protected
    string

    Alias to display in the output.

  • $_maxArgs protected
    int

    The maximum number of arguments shown when generating usage.

  • $_maxOptions protected
    int

    The maximum number of options shown when generating usage.

  • $_parser protected
    Cake\Console\ConsoleOptionParser

    Option parser.

Method Summary

  • __construct() public

    Build the help formatter for an OptionParser

  • _generateUsage() protected

    Generate the usage for a shell based on its arguments and options. Usage strings favor short options over the long ones. and optional args will be indicated with []

  • _getMaxLength() protected

    Iterate over a collection and find the longest named thing.

  • setAlias() public

    Set the alias

  • text() public

    Get the help as formatted text suitable for output on the command line.

  • xml() public

    Get the help as an XML string.

Method Detail

__construct() ¶ public

__construct(Cake\Console\ConsoleOptionParser $parser)

Build the help formatter for an OptionParser

Parameters
Cake\Console\ConsoleOptionParser $parser

The option parser help is being generated for.

_generateUsage() ¶ protected

_generateUsage(): string

Generate the usage for a shell based on its arguments and options. Usage strings favor short options over the long ones. and optional args will be indicated with []

Returns
string

_getMaxLength() ¶ protected

_getMaxLength(array<Cake\Console\ConsoleInputOption|Cake\Console\ConsoleInputArgument> $collection): int

Iterate over a collection and find the longest named thing.

Parameters
array<Cake\Console\ConsoleInputOption|Cake\Console\ConsoleInputArgument> $collection

The collection to find a max length of.

Returns
int

setAlias() ¶ public

setAlias(string $alias): void

Set the alias

Parameters
string $alias

The alias

Returns
void

text() ¶ public

text(int $width = 72): string

Get the help as formatted text suitable for output on the command line.

Parameters
int $width optional

The width of the help output.

Returns
string

xml() ¶ public

xml(bool $string = true): SimpleXMLElement|string

Get the help as an XML string.

Parameters
bool $string optional

Return the SimpleXml object or a string. Defaults to true.

Returns
SimpleXMLElement|string

Property Detail

$_alias ¶ protected

Alias to display in the output.

Type
string

$_maxArgs ¶ protected

The maximum number of arguments shown when generating usage.

Type
int

$_maxOptions ¶ protected

The maximum number of options shown when generating usage.

Type
int

$_parser ¶ protected

Option parser.

Type
Cake\Console\ConsoleOptionParser
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