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 6.0 API

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

Namespace Core

Namespaces

  • Cake\Core\Attribute
  • Cake\Core\Configure
  • Cake\Core\Exception
  • Cake\Core\Retry
  • Cake\Core\TestSuite

Function Detail

deprecationWarning() ¶

deprecationWarning(string $version, string $message, int $stackFrame = 1): void

Helper method for outputting deprecation warnings

Parameters
string $version

The version that added this deprecation warning.

string $message

The message to output as a deprecation warning.

int $stackFrame optional

The stack frame to include in the error. Defaults to 1 as that should point to application/plugin code.

Returns
void

env() ¶

env(string $key, string|float|int|bool|null $default = null): string|float|int|bool|null

Gets an environment variable from available sources, and provides emulation for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom environment information.

Parameters
string $key

Environment variable name.

string|float|int|bool|null $default optional

Specify a default value in case the environment variable is not defined.

Returns
string|float|int|bool|null

Environment variable setting.

Links
https://book.cakephp.org/5/en/core-libraries/global-constants-and-functions.html#env

h() ¶

h(mixed $text, bool $double = true, string|null $charset = null): mixed

Convenience method for htmlspecialchars.

Parameters
mixed $text

Text to wrap through htmlspecialchars. Also works with arrays, and objects. Arrays will be mapped and have all their elements escaped. Objects will be string cast if they implement a __toString method. Otherwise, the class name will be used. Other scalar types will be returned unchanged.

bool $double optional

Encode existing html entities.

string|null $charset optional

Character set to use when escaping. Defaults to config value in mb_internal_encoding() or 'UTF-8'.

Returns
mixed

Wrapped text.

Links
https://book.cakephp.org/5/en/core-libraries/global-constants-and-functions.html#h

namespaceSplit() ¶

namespaceSplit(string $class): array{0: string, 1: string}

Split the namespace from the classname.

Commonly used like list($namespace, $className) = namespaceSplit($class);.

Parameters
string $class

The full class name, ie Cake\Core\App.

Returns
array{0: string, 1: string}

Array with 2 indexes. 0 => namespace, 1 => classname.

pathCombine() ¶

pathCombine(array<string> $parts, bool|null $trailing = null): string

Combines parts with a forward-slash /.

Skips adding a forward-slash if either / or \ already exists.

Parameters
array<string> $parts
bool|null $trailing optional

Determines how trailing slashes are handled

  • If true, ensures a trailing forward-slash is added if one doesn't exist
  • If false, ensures any trailing slash is removed
  • if null, ignores trailing slashes
Returns
string

pj() ¶

pj(mixed $var): mixed

JSON pretty print convenience function.

In terminals this will act similar to using json_encode() with JSON_PRETTY_PRINT directly, when not run on CLI will also wrap <pre> tags around the output of given variable. Similar to pr().

This function returns the same variable that was passed.

Parameters
mixed $var

Variable to print out.

Returns
mixed

the same $var that was passed to this function

See Also
pr()
Links
https://book.cakephp.org/5/en/core-libraries/global-constants-and-functions.html#pj

pluginSplit() ¶

pluginSplit(string $name, bool $dotAppend = false, string|null $plugin = null): array{0: (string|null, 1: string}

Splits a dot syntax plugin name into its plugin and class name. If $name does not have a dot, then index 0 will be null.

Commonly used like

list($plugin, $name) = pluginSplit($name);
Parameters
string $name

The name you want to plugin split.

bool $dotAppend optional

Set to true if you want the plugin to have a '.' appended to it.

string|null $plugin optional

Optional default plugin to use if no plugin is found. Defaults to null.

Returns
array{0: (string|null, 1: string}

Array with 2 indexes. 0 => plugin name, 1 => class name.

Links
https://book.cakephp.org/5/en/core-libraries/global-constants-and-functions.html#pluginsplit

pr() ¶

pr(mixed $var): mixed

print_r() convenience function.

In terminals this will act similar to using print_r() directly, when not run on CLI print_r() will also wrap <pre> tags around the output of given variable. Similar to debug().

This function returns the same variable that was passed.

Parameters
mixed $var

Variable to print out.

Returns
mixed

the same $var that was passed to this function

See Also
debug()
Links
https://book.cakephp.org/5/en/core-libraries/global-constants-and-functions.html#pr

toBool() ¶

toBool(mixed $value): bool|null

Converts a value to boolean.

1 | '1' | 1.0 | true - values returns as true 0 | '0' | 0.0 | false - values returns as false Other values returns as null.

Parameters
mixed $value

The value to convert to boolean.

Returns
bool|null

Returns true if the value is truthy, false if it's falsy, or NULL otherwise.

toFloat() ¶

toFloat(mixed $value): float|null

Converts a value to a float.

This method attempts to convert the given value to a float. If the conversion is successful, it returns the value as an float. If the conversion fails, it returns NULL.

String values are trimmed using trim().

Parameters
mixed $value

The value to be converted to a float.

Returns
float|null

Returns the converted float value or null if the conversion fails.

toInt() ¶

toInt(mixed $value): int|null

Converts a value to an integer.

This method attempts to convert the given value to an integer. If the conversion is successful, it returns the value as an integer. If the conversion fails, it returns NULL.

String values are trimmed using trim().

Parameters
mixed $value

The value to be converted to an integer.

Returns
int|null

Returns the converted integer value or null if the conversion fails.

toString() ¶

toString(mixed $value): ?string

Converts the given value to a string.

This method attempts to convert the given value to a string. If the value is already a string, it returns the value as it is. null is returned if the conversion is not possible.

Parameters
mixed $value

The value to be converted.

Returns
?string

Returns the string representation of the value, or null if the value is not a string.

triggerWarning() ¶

triggerWarning(string $message, int $level = E_USER_WARNING): void

Triggers a user-level PHP error/warning/notice.

Parameters
string $message

The warning message.

int $level optional

The error level to trigger. Defaults to E_USER_WARNING.

Returns
void

Interfaces

  • ConsoleApplicationInterface

    An interface defining the methods that the console runner depend on.

  • ConsoleHelpHeaderProviderInterface

    Provides a custom header line for console help output.

  • ContainerApplicationInterface

    Interface for applications that configure and use a dependency injection container.

  • EventAwareApplicationInterface
  • HttpApplicationInterface

    An interface defining the methods that the http server depend on.

  • PluginApplicationInterface

    Interface for Applications that leverage plugins & events.

    Events can be bound to the application event manager during the application's bootstrap and plugin bootstrap.

  • PluginInterface

    Plugin Interface

Classes

  • App

    App is responsible for resource location, and path management.

    Adding paths

    Additional paths for Templates and Plugins are configured with Configure now. See config/app.php for an example. The App.paths.plugins and App.paths.templates variables are used to configure paths for plugins and templates respectively. All class based resources should be mapped using your application's autoloader.

    Inspecting loaded paths

    You can inspect the currently loaded paths using App::classPath('Controller') for example to see loaded controller paths.

    It is also possible to inspect paths for plugin classes, for instance, to get the path to a plugin's helpers you would call App::classPath('View/Helper', 'MyPlugin')

    Locating plugins

    Plugins can be located with App as well. Using Plugin::path('DebugKit') for example, will give you the full path to the DebugKit plugin.

  • BasePlugin

    Base Plugin Class

    Every plugin should extend from this class or implement the interfaces and include a plugin class in its src root folder.

  • Configure

    Configuration class. Used for managing runtime configuration information.

    Provides features for reading and writing to the runtime configuration, as well as methods for loading additional configuration files or storing runtime configuration for future use.

  • ContainerFactory

    Factory for creating the application's dependency injection container.

    By default, a plain Cake\Container\Container is created. Applications that need a custom container implementation (for example, one with extra bootstrapping or a different underlying implementation) can set Configure::write('App.container', MyContainer::class) to a class name implementing Cake\Container\ContainerInterface.

  • ObjectRegistry

    Acts as a registry/factory for objects.

    Provides registry & factory functionality for object types. Used as a super class for various composition based re-use features in CakePHP.

    Each subclass needs to implement the various abstract methods to complete the template method load().

    The ObjectRegistry is EventManager aware, but each extending class will need to use \Cake\Event\EventDispatcherTrait to attach and detach on set and bind

  • Plugin

    Plugin is used to load and locate plugins.

    It also can retrieve plugin paths and load their bootstrap and routes files.

  • PluginCollection

    Plugin Collection

    Holds onto plugin objects loaded into an application, and provides methods for iterating, and finding plugins based on criteria.

    This class implements the Iterator interface to allow plugins to be iterated, handling the situation where a plugin's hook method (usually bootstrap) loads another plugin during iteration.

    While its implementation supported nested iteration it does not support using continue or break inside loops.

  • PluginConfig

    PluginConfig contains all available plugins and their config if/how they should be loaded

  • ServiceConfig

    Read-only wrapper for configuration data

    Intended for use with {@link \Cake\Container\Container} as a typehintable way for services to have application configuration injected as arrays cannot be typehinted.

Traits

  • ConventionsTrait

    Provides methods that allow other classes access to conventions based inflections.

  • InstanceConfigTrait

    A trait for reading and writing instance config

    Implementing objects are expected to declare a $defaultConfig property.

  • StaticConfigTrait

    A trait that provides a set of static methods to manage configuration for classes that provide an adapter facade or need to have sets of configuration data registered and manipulated.

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