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

Functions

  • __
  • __d
  • __dn
  • __dx
  • __dxn
  • __n
  • __x
  • __xn
  • breakpoint
  • collection
  • dd
  • debug
  • deprecationWarning
  • env
  • getTypeName
  • h
  • loadPHPUnitAliases
  • namespaceSplit
  • pj
  • pluginSplit
  • pr
  • stackTrace
  • triggerWarning
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         0.2.9
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: use Cake\Core\Configure;
 16: use Cake\Error\Debugger;
 17: 
 18:     /**
 19:      * Basic defines for timing functions.
 20:      */
 21:     define('SECOND', 1);
 22:     define('MINUTE', 60);
 23:     define('HOUR', 3600);
 24:     define('DAY', 86400);
 25:     define('WEEK', 604800);
 26:     define('MONTH', 2592000);
 27:     define('YEAR', 31536000);
 28: 
 29: if (!function_exists('debug')) {
 30:     /**
 31:      * Prints out debug information about given variable and returns the
 32:      * variable that was passed.
 33:      *
 34:      * Only runs if debug mode is enabled.
 35:      *
 36:      * @param mixed $var Variable to show debug information for.
 37:      * @param bool|null $showHtml If set to true, the method prints the debug data in a browser-friendly way.
 38:      * @param bool $showFrom If set to true, the method prints from where the function was called.
 39:      * @return mixed The same $var that was passed
 40:      * @link https://book.cakephp.org/3.0/en/development/debugging.html#basic-debugging
 41:      * @link https://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#debug
 42:      */
 43:     function debug($var, $showHtml = null, $showFrom = true)
 44:     {
 45:         if (!Configure::read('debug')) {
 46:             return $var;
 47:         }
 48: 
 49:         $location = [];
 50:         if ($showFrom) {
 51:             $trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
 52:             $location = [
 53:                 'line' => $trace[0]['line'],
 54:                 'file' => $trace[0]['file']
 55:             ];
 56:         }
 57: 
 58:         Debugger::printVar($var, $location, $showHtml);
 59: 
 60:         return $var;
 61:     }
 62: 
 63: }
 64: 
 65: if (!function_exists('stackTrace')) {
 66:     /**
 67:      * Outputs a stack trace based on the supplied options.
 68:      *
 69:      * ### Options
 70:      *
 71:      * - `depth` - The number of stack frames to return. Defaults to 999
 72:      * - `args` - Should arguments for functions be shown? If true, the arguments for each method call
 73:      *   will be displayed.
 74:      * - `start` - The stack frame to start generating a trace from. Defaults to 1
 75:      *
 76:      * @param array $options Format for outputting stack trace
 77:      * @return void
 78:      */
 79:     function stackTrace(array $options = [])
 80:     {
 81:         if (!Configure::read('debug')) {
 82:             return;
 83:         }
 84: 
 85:         $options += ['start' => 0];
 86:         $options['start']++;
 87: 
 88:         /** @var string $trace */
 89:         $trace = Debugger::trace($options);
 90:         echo $trace;
 91:     }
 92: 
 93: }
 94: 
 95: if (!function_exists('breakpoint')) {
 96:     /**
 97:      * Command to return the eval-able code to startup PsySH in interactive debugger
 98:      * Works the same way as eval(\Psy\sh());
 99:      * psy/psysh must be loaded in your project
100:      * @link http://psysh.org/
101:      * ```
102:      * eval(breakpoint());
103:      * ```
104:      * @return string
105:      */
106:     function breakpoint()
107:     {
108:         if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && class_exists('\Psy\Shell')) {
109:             return 'extract(\Psy\Shell::debug(get_defined_vars(), isset($this) ? $this : null));';
110:         }
111:         trigger_error(
112:             'psy/psysh must be installed and you must be in a CLI environment to use the breakpoint function',
113:             E_USER_WARNING
114:         );
115:     }
116: }
117: 
118: if (!function_exists('dd')) {
119:     /**
120:      * Prints out debug information about given variable and dies.
121:      *
122:      * Only runs if debug mode is enabled.
123:      * It will otherwise just continue code execution and ignore this function.
124:      *
125:      * @param mixed $var Variable to show debug information for.
126:      * @param bool|null $showHtml If set to true, the method prints the debug data in a browser-friendly way.
127:      * @return void
128:      * @link https://book.cakephp.org/3.0/en/development/debugging.html#basic-debugging
129:      */
130:     function dd($var, $showHtml = null)
131:     {
132:         if (!Configure::read('debug')) {
133:             return;
134:         }
135: 
136:         $trace = Debugger::trace(['start' => 1, 'depth' => 2, 'format' => 'array']);
137:         $location = [
138:             'line' => $trace[0]['line'],
139:             'file' => $trace[0]['file']
140:         ];
141: 
142:         Debugger::printVar($var, $location, $showHtml);
143:         die(1);
144:     }
145: }
146: 
147: if (!function_exists('loadPHPUnitAliases')) {
148:     /**
149:      * Loads PHPUnit aliases
150:      *
151:      * This is an internal function used for backwards compatibility during
152:      * fixture related tests.
153:      *
154:      * @return void
155:      */
156:     function loadPHPUnitAliases()
157:     {
158:         require_once dirname(__DIR__) . DS . 'tests' . DS . 'phpunit_aliases.php';
159:     }
160: }
161: 
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