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 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::path('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::path('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.

Namespace: Cake\Core
Link: https://book.cakephp.org/3.0/en/core-libraries/app.html
Location: Core/App.php

Method Summary

  • _classExistsInBase() protected static
    _classExistsInBase
  • className() public static

    Return the class name namespaced. This method checks if the class is defined on the application/plugin, otherwise try to load from the CakePHP core

  • core() public static
    Returns the full path to a package inside the CakePHP core
  • path() public static
    Used to read information stored path
  • shortName() public static
    Returns the plugin split name of a class

Method Detail

_classExistsInBase() protected static ¶

_classExistsInBase( string $name , string $namespace )

_classExistsInBase

Test isolation wrapper

Parameters
string $name
Class name.
string $namespace
Namespace.
Returns
boolean

className() public static ¶

className( string $class , string $type = '' , string $suffix = '' )

Return the class name namespaced. This method checks if the class is defined on the application/plugin, otherwise try to load from the CakePHP core

Parameters
string $class
Class name
string $type optional ''
Type of class
string $suffix optional ''
Class name suffix
Returns
string|false
False if the class is not found or namespaced class name

core() public static ¶

core( string $type )

Returns the full path to a package inside the CakePHP core

Usage:

App::core('Cache/Engine');

Will return the full path to the cache engines package.

Parameters
string $type
Package type.
Returns
array
Full path to package

path() public static ¶

path( string $type , string|null $plugin = null )

Used to read information stored path

Usage:

App::path('Plugin');

Will return the configured paths for plugins. This is a simpler way to access the App.paths.plugins configure variable.

App::path('Model/Datasource', 'MyPlugin');

Will return the path for datasources under the 'MyPlugin' plugin.

Parameters
string $type
type of path
string|null $plugin optional null
name of plugin
Returns
array
Link
https://book.cakephp.org/3.0/en/core-libraries/app.html#finding-paths-to-namespaces

shortName() public static ¶

shortName( string $class , string $type , string $suffix = '' )

Returns the plugin split name of a class

Examples:

App::shortName(
    'SomeVendor\SomePlugin\Controller\Component\TestComponent',
    'Controller/Component',
    'Component'
)

Returns: SomeVendor/SomePlugin.Test

App::shortName(
    'SomeVendor\SomePlugin\Controller\Component\Subfolder\TestComponent',
    'Controller/Component',
    'Component'
)

Returns: SomeVendor/SomePlugin.Subfolder/Test

App::shortName(
    'Cake\Controller\Component\AuthComponent',
    'Controller/Component',
    'Component'
)

Returns: Auth

Parameters
string $class
Class name
string $type
Type of class
string $suffix optional ''
Class name suffix
Returns
string
Plugin split name of class
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