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

  • App
  • BasePlugin
  • ClassLoader
  • Configure
  • ObjectRegistry
  • Plugin
  • PluginCollection

Interfaces

  • ConsoleApplicationInterface
  • HttpApplicationInterface
  • PluginApplicationInterface
  • PluginInterface

Traits

  • ConventionsTrait
  • InstanceConfigTrait
  • StaticConfigTrait

Class Plugin

Plugin is used to load and locate plugins.

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

Namespace: Cake\Core
Link: https://book.cakephp.org/3.0/en/plugins.html
Location: Core/Plugin.php

Properties summary

  • $_loader protected static
    Cake\Core\ClassLoader
    Class loader instance
  • $plugins protected static
    Cake\Core\PluginCollection|null
    Holds a list of all loaded plugins and their configuration

Method Summary

  • _includeFile() protected static
    Include file, ignoring include error if needed if file is missing
  • bootstrap() public static deprecated
    Loads the bootstrapping files for a plugin, or calls the initialization setup in the configuration
  • classPath() public static
    Returns the filesystem path for plugin's folder containing class folders.
  • configPath() public static
    Returns the filesystem path for plugin's folder containing config files.
  • getCollection() public static
    Get the shared plugin collection.
  • isLoaded() public static
    Check whether or not a plugin is loaded.
  • load() public static deprecated

    Loads a plugin and optionally loads bootstrapping, routing files or runs an initialization function.

  • loadAll() public static deprecated
    Will load all the plugins located in the default plugin folder.
  • loaded() public static
    Return a list of loaded plugins.
  • path() public static
    Returns the filesystem path for a plugin
  • routes() public static deprecated
    Loads the routes file for a plugin, or all plugins configured to load their respective routes file.
  • unload() public static deprecated
    Forgets a loaded plugin or all of them if first parameter is null

Method Detail

_includeFile() protected static ¶

_includeFile( string $file , boolean $ignoreMissing = false )

Include file, ignoring include error if needed if file is missing

Parameters
string $file
File to include
boolean $ignoreMissing optional false
Whether to ignore include error for missing files
Returns
mixed

bootstrap() public static deprecated ¶

bootstrap( string $name )

Loads the bootstrapping files for a plugin, or calls the initialization setup in the configuration

Deprecated
3.7.0 This method will be removed in 4.0.0.
Parameters
string $name
name of the plugin
Returns
mixed
See
\Cake\Core\Plugin::load() for examples of bootstrap configuration

classPath() public static ¶

classPath( string $name )

Returns the filesystem path for plugin's folder containing class folders.

Parameters
string $name
name of the plugin in CamelCase format.
Returns
string
Path to the plugin folder container class folders.
Throws
Cake\Core\Exception\MissingPluginException
If plugin has not been loaded.

configPath() public static ¶

configPath( string $name )

Returns the filesystem path for plugin's folder containing config files.

Parameters
string $name
name of the plugin in CamelCase format.
Returns
string
Path to the plugin folder container config files.
Throws
Cake\Core\Exception\MissingPluginException
If plugin has not been loaded.

getCollection() public static ¶

getCollection( )

Get the shared plugin collection.

This method should generally not be used during application runtime as plugins should be set during Application startup.

Returns
Cake\Core\PluginCollection

isLoaded() public static ¶

isLoaded( string $plugin )

Check whether or not a plugin is loaded.

Parameters
string $plugin
The name of the plugin to check.
Returns
boolean
Since
3.7.0

load() public static deprecated ¶

load( string|array $plugin , array $config = [] )

Loads a plugin and optionally loads bootstrapping, routing files or runs an initialization function.

Plugins only need to be loaded if you want bootstrapping/routes/cli commands to be exposed. If your plugin does not expose any of these features you do not need to load them.

This method does not configure any autoloaders. That must be done separately either through composer, or your own code during config/bootstrap.php.

Examples:

Plugin::load('DebugKit')

Will load the DebugKit plugin and will not load any bootstrap nor route files. However, the plugin will be part of the framework default routes, and have its CLI tools (if any) available for use.

Plugin::load('DebugKit', ['bootstrap' => true, 'routes' => true])

Will load the bootstrap.php and routes.php files.

Plugin::load('DebugKit', ['bootstrap' => false, 'routes' => true])

Will load routes.php file but not bootstrap.php

Plugin::load('FOC/Authenticate')

Will load plugin from plugins/FOC/Authenticate.

It is also possible to load multiple plugins at once. Examples:

Plugin::load(['DebugKit', 'ApiGenerator'])

Will load the DebugKit and ApiGenerator plugins.

Plugin::load(['DebugKit', 'ApiGenerator'], ['bootstrap' => true])

Will load bootstrap file for both plugins

Plugin::load([
    'DebugKit' => ['routes' => true],
    'ApiGenerator'
    ],
    ['bootstrap' => true])

Will only load the bootstrap for ApiGenerator and only the routes for DebugKit

Configuration options

  • bootstrap - array - Whether or not you want the $plugin/config/bootstrap.php file loaded.
  • routes - boolean - Whether or not you want to load the $plugin/config/routes.php file.
  • ignoreMissing - boolean - Set to true to ignore missing bootstrap/routes files.
  • path - string - The path the plugin can be found on. If empty the default plugin path (App.pluginPaths) will be used.
  • classBase - The path relative to path which contains the folders with class files. Defaults to "src".
  • autoload - boolean - Whether or not you want an autoloader registered. This defaults to false. The framework assumes you have configured autoloaders using composer. However, if your application source tree is made up of plugins, this can be a useful option.
Deprecated
3.7.0 This method will be removed in 4.0.0. Use Application::addPlugin() instead.
Parameters
string|array $plugin
name of the plugin to be loaded in CamelCase format or array or plugins to load
array $config optional []
configuration options for the plugin
Throws
Cake\Core\Exception\MissingPluginException
if the folder for the plugin to be loaded is not found

loadAll() public static deprecated ¶

loadAll( array $options = [] )

Will load all the plugins located in the default plugin folder.

If passed an options array, it will be used as a common default for all plugins to be loaded It is possible to set specific defaults for each plugins in the options array. Examples:

Plugin::loadAll([
     ['bootstrap' => true],
     'DebugKit' => ['routes' => true],
 ]);

The above example will load the bootstrap file for all plugins, but for DebugKit it will only load the routes file and will not look for any bootstrap script.

If a plugin has been loaded already, it will not be reloaded by loadAll().

Deprecated
3.7.0 This method will be removed in 4.0.0.
Parameters
array $options optional []
Options.
Throws
Cake\Core\Exception\MissingPluginException

loaded() public static ¶

loaded( string|null $plugin = null )

Return a list of loaded plugins.

If a plugin name is provided, the return value will be a bool indicating whether or not the named plugin is loaded. This usage is deprecated. Instead you should use Plugin::isLoaded($name)

Parameters
string|null $plugin optional null
Plugin name.
Returns
boolean|array

Boolean true if $plugin is already loaded. If $plugin is null, returns a list of plugins that have been loaded


path() public static ¶

path( string $name )

Returns the filesystem path for a plugin

Parameters
string $name
name of the plugin in CamelCase format
Returns
string
path to the plugin folder
Throws
Cake\Core\Exception\MissingPluginException
if the folder for plugin was not found or plugin has not been loaded

routes() public static deprecated ¶

routes( string|null $name = null )

Loads the routes file for a plugin, or all plugins configured to load their respective routes file.

If you need fine grained control over how routes are loaded for plugins, you can use Cake\Routing\RouteBuilder::loadPlugin()

Deprecated

3.6.5 This method is no longer needed when using HttpApplicationInterface based applications. This method will be removed in 4.0.0


Parameters
string|null $name optional null

name of the plugin, if null will operate on all plugins having enabled the loading of routes files.

Returns
boolean

unload() public static deprecated ¶

unload( string|null $plugin = null )

Forgets a loaded plugin or all of them if first parameter is null

Deprecated
3.7.0 This method will be removed in 4.0.0. Use PluginCollection::remove() or clear() instead.
Parameters
string|null $plugin optional null
name of the plugin to forget

Properties detail

$_loader ¶

protected static Cake\Core\ClassLoader

Class loader instance

$plugins ¶

protected static Cake\Core\PluginCollection|null

Holds a list of all loaded plugins and their configuration

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