Created
October 30, 2013 10:12
-
-
Save simkimsia/7230130 to your computer and use it in GitHub Desktop.
my bootstrap and core for production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This file is loaded automatically by the app/webroot/index.php file after core.php | |
| * | |
| * This file should load/create any application wide configuration settings, such as | |
| * Caching, Logging, loading additional configuration files. | |
| * | |
| * You should also use this file to include any files that provide global functions/constants | |
| * that your application uses. | |
| * | |
| * PHP 5 | |
| * | |
| * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | |
| * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
| * | |
| * Licensed under The MIT License | |
| * Redistributions of files must retain the above copyright notice. | |
| * | |
| * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
| * @link http://cakephp.org CakePHP(tm) Project | |
| * @package app.Config | |
| * @since CakePHP(tm) v 0.10.8.2117 | |
| * @license MIT License (http://www.opensource.org/licenses/mit-license.php) | |
| */ | |
| // Setup a 'default' cache configuration for use in the application. | |
| Cache::config('default', array('engine' => 'File')); | |
| /** | |
| * The settings below can be used to set additional paths to models, views and controllers. | |
| * | |
| * App::build(array( | |
| * 'Plugin' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'), | |
| * 'Model' => array('/full/path/to/models/', '/next/full/path/to/models/'), | |
| * 'View' => array('/full/path/to/views/', '/next/full/path/to/views/'), | |
| * 'Controller' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'), | |
| * 'Model/Datasource' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'), | |
| * 'Model/Behavior' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'), | |
| * 'Controller/Component' => array('/full/path/to/components/', '/next/full/path/to/components/'), | |
| * 'View/Helper' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'), | |
| * 'Vendor' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'), | |
| * 'Console/Command' => array('/full/path/to/shells/', '/next/full/path/to/shells/'), | |
| * 'Locale' => array('/full/path/to/locale/', '/next/full/path/to/locale/') | |
| * )); | |
| * | |
| */ | |
| /** | |
| * Custom Inflector rules, can be set to correctly pluralize or singularize table, model, controller names or whatever other | |
| * string is passed to the inflection functions | |
| * | |
| * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); | |
| * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array())); | |
| * | |
| */ | |
| /** | |
| * Plugins need to be loaded manually, you can either load them one by one or all of them in a single call | |
| * Uncomment one of the lines below, as you need. make sure you read the documentation on CakePlugin to use more | |
| * advanced ways of loading plugins | |
| * | |
| * CakePlugin::loadAll(); // Loads all plugins at once | |
| * CakePlugin::load('DebugKit'); //Loads a single plugin named DebugKit | |
| * | |
| */ | |
| /** | |
| * | |
| * plugin_configs.php file to define config settings for all the CakePlugins that remain same regardless of environments | |
| **/ | |
| $pluginConfigs = array(); | |
| if (file_exists(APP . DS . 'Config' . DS . 'plugin_configs.php')) { | |
| require_once (APP . DS . 'Config' . DS . 'plugin_configs.php'); | |
| } | |
| CakePlugin::loadAll($pluginConfigs); // Loads all plugins at once | |
| CakePlugin::unload('AssetCompress'); | |
| /** | |
| * You can attach event listeners to the request lifecyle as Dispatcher Filter . By Default CakePHP bundles two filters: | |
| * | |
| * - AssetDispatcher filter will serve your asset files (css, images, js, etc) from your themes and plugins | |
| * - CacheDispatcher filter will read the Cache.check configure variable and try to serve cached content generated from controllers | |
| * | |
| * Feel free to remove or add filters as you see fit for your application. A few examples: | |
| * | |
| * Configure::write('Dispatcher.filters', array( | |
| * 'MyCacheFilter', // will use MyCacheFilter class from the Routing/Filter package in your app. | |
| * 'MyPlugin.MyFilter', // will use MyFilter class from the Routing/Filter package in MyPlugin plugin. | |
| * array('callbale' => $aFunction, 'on' => 'before', 'priority' => 9), // A valid PHP callback type to be called on beforeDispatch | |
| * array('callbale' => $anotherMethod, 'on' => 'after'), // A valid PHP callback type to be called on afterDispatch | |
| * | |
| * )); | |
| */ | |
| Configure::write('Dispatcher.filters', array( | |
| 'AssetDispatcher','CacheDispatcher')); | |
| CakePlugin::load('AssetCompress', array('bootstrap' => true)); | |
| /** | |
| * Configures default file logging options | |
| */ | |
| App::uses('CakeLog', 'Log'); | |
| CakeLog::config('debug', array( | |
| 'engine' => 'FileLog', | |
| 'types' => array('notice', 'info', 'debug'), | |
| 'file' => 'debug', | |
| )); | |
| CakeLog::config('error', array( | |
| 'engine' => 'FileLog', | |
| 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), | |
| 'file' => 'error', | |
| )); | |
| /** | |
| * | |
| * Session settings | |
| */ | |
| Configure::write('Session', array( | |
| 'defaults' => 'php', | |
| 'cookie' => 'ABCD', | |
| 'timeout' => 60, //Session will timeout after 60 minutes of inactivity | |
| 'cookieTimeout' => 1440, //Session cookie will live for at most 24 hours, this does not effect session timeouts | |
| )); | |
| /** | |
| * | |
| * constants.php file to define constants that remain same regardless of environments | |
| **/ | |
| if (file_exists(APP . DS . 'Config' . DS . 'constants.php')) { | |
| require_once (APP . DS . 'Config' . DS . 'constants.php'); | |
| } | |
| /** | |
| * | |
| * whether we want to emulate the server delay we see in ajax upload etc | |
| **/ | |
| Configure::write('emulate_server_delay', false); // writing this here to override the one in constants.php | |
| /** | |
| * check for absolutely empty string | |
| * 0 as in zero will return false | |
| * | |
| **/ | |
| function is_blank($variable) { | |
| return (empty($variable) && !is_numeric($variable)); | |
| } | |
| /** | |
| * override the default exception renderer to display custom 404 page | |
| */ | |
| Configure::write('Exception', array( | |
| 'handler' => 'ErrorHandler::handleException', | |
| 'renderer' => 'AppExceptionRenderer', | |
| 'log' => true | |
| )); | |
| // taken from http://book.cakephp.org/2.0/en/installation/advanced-installation.html | |
| // Load composer autoload. | |
| require APP . '/Vendor/autoload.php'; | |
| // Remove and re-prepend CakePHP's autoloader as composer thinks it is the most important. | |
| // See https://github.com/composer/composer/commit/c80cb76b9b5082ecc3e5b53b1050f76bb27b127b | |
| spl_autoload_unregister(array('App', 'load')); | |
| spl_autoload_register(array('App', 'load'), true, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * This is core configuration file. | |
| * | |
| * Use it to configure core behavior of Cake. | |
| * | |
| * PHP 5 | |
| * | |
| * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | |
| * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
| * | |
| * Licensed under The MIT License | |
| * Redistributions of files must retain the above copyright notice. | |
| * | |
| * @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
| * @link http://cakephp.org CakePHP(tm) Project | |
| * @package app.Config | |
| * @since CakePHP(tm) v 0.2.9 | |
| * @license MIT License (http://www.opensource.org/licenses/mit-license.php) | |
| */ | |
| /** | |
| * CakePHP Debug Level: | |
| * | |
| * Production Mode: | |
| * 0: No error messages, errors, or warnings shown. Flash messages redirect. | |
| * | |
| * Development Mode: | |
| * 1: Errors and warnings shown, model caches refreshed, flash messages halted. | |
| * 2: As in 1, but also with full debug messages and SQL output. | |
| * | |
| * In production mode, flash messages redirect after a time interval. | |
| * In development mode, you need to click the flash message to continue. | |
| */ | |
| Configure::write('debug', 0); | |
| /** | |
| * Configure the Error handler used to handle errors for your application. By default | |
| * ErrorHandler::handleError() is used. It will display errors using Debugger, when debug > 0 | |
| * and log errors with CakeLog when debug = 0. | |
| * | |
| * Options: | |
| * | |
| * - `handler` - callback - The callback to handle errors. You can set this to any callback type, | |
| * including anonymous functions. | |
| * - `level` - int - The level of errors you are interested in capturing. | |
| * - `trace` - boolean - Include stack traces for errors in log files. | |
| * | |
| * @see ErrorHandler for more information on error handling and configuration. | |
| */ | |
| Configure::write('Error', array( | |
| 'handler' => 'ErrorHandler::handleError', | |
| 'level' => E_ALL & ~E_DEPRECATED, | |
| 'trace' => true | |
| )); | |
| /** | |
| * Configure the Exception handler used for uncaught exceptions. By default, | |
| * ErrorHandler::handleException() is used. It will display a HTML page for the exception, and | |
| * while debug > 0, framework errors like Missing Controller will be displayed. When debug = 0, | |
| * framework errors will be coerced into generic HTTP errors. | |
| * | |
| * Options: | |
| * | |
| * - `handler` - callback - The callback to handle exceptions. You can set this to any callback type, | |
| * including anonymous functions. | |
| * - `renderer` - string - The class responsible for rendering uncaught exceptions. If you choose a custom class you | |
| * should place the file for that class in app/Lib/Error. This class needs to implement a render method. | |
| * - `log` - boolean - Should Exceptions be logged? | |
| * | |
| * @see ErrorHandler for more information on exception handling and configuration. | |
| */ | |
| Configure::write('Exception', array( | |
| 'handler' => 'ErrorHandler::handleException', | |
| 'renderer' => 'ExceptionRenderer', | |
| 'log' => true | |
| )); | |
| /** | |
| * Application wide charset encoding | |
| */ | |
| Configure::write('App.encoding', 'UTF-8'); | |
| /** | |
| * To configure CakePHP *not* to use mod_rewrite and to | |
| * use CakePHP pretty URLs, remove these .htaccess | |
| * files: | |
| * | |
| * /.htaccess | |
| * /app/.htaccess | |
| * /app/webroot/.htaccess | |
| * | |
| * And uncomment the App.baseUrl below: | |
| */ | |
| //Configure::write('App.baseUrl', env('SCRIPT_NAME')); | |
| /** | |
| * Uncomment the define below to use CakePHP prefix routes. | |
| * | |
| * The value of the define determines the names of the routes | |
| * and their associated controller actions: | |
| * | |
| * Set to an array of prefixes you want to use in your application. Use for | |
| * admin or other prefixed routes. | |
| * | |
| * Routing.prefixes = array('admin', 'manager'); | |
| * | |
| * Enables: | |
| * `admin_index()` and `/admin/controller/index` | |
| * `manager_index()` and `/manager/controller/index` | |
| * | |
| */ | |
| Configure::write('Routing.prefixes', array('admin', 'su')); | |
| /** | |
| * Turn off all caching application-wide. | |
| * | |
| */ | |
| //Configure::write('Cache.disable', true); | |
| /** | |
| * Enable cache checking. | |
| * | |
| * If set to true, for view caching you must still use the controller | |
| * public $cacheAction inside your controllers to define caching settings. | |
| * You can either set it controller-wide by setting public $cacheAction = true, | |
| * or in each action using $this->cacheAction = true. | |
| * | |
| */ | |
| //Configure::write('Cache.check', true); | |
| /** | |
| * Defines the default error type when using the log() function. Used for | |
| * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG. | |
| */ | |
| define('LOG_ERROR', LOG_ERR); | |
| /** | |
| * Session configuration. | |
| * | |
| * Contains an array of settings to use for session configuration. The defaults key is | |
| * used to define a default preset to use for sessions, any settings declared here will override | |
| * the settings of the default config. | |
| * | |
| * ## Options | |
| * | |
| * - `Session.cookie` - The name of the cookie to use. Defaults to 'CAKEPHP' | |
| * - `Session.timeout` - The number of minutes you want sessions to live for. This timeout is handled by CakePHP | |
| * - `Session.cookieTimeout` - The number of minutes you want session cookies to live for. | |
| * - `Session.checkAgent` - Do you want the user agent to be checked when starting sessions? You might want to set the | |
| * value to false, when dealing with older versions of IE, Chrome Frame or certain web-browsing devices and AJAX | |
| * - `Session.defaults` - The default configuration set to use as a basis for your session. | |
| * There are four builtins: php, cake, cache, database. | |
| * - `Session.handler` - Can be used to enable a custom session handler. Expects an array of of callables, | |
| * that can be used with `session_save_handler`. Using this option will automatically add `session.save_handler` | |
| * to the ini array. | |
| * - `Session.autoRegenerate` - Enabling this setting, turns on automatic renewal of sessions, and | |
| * sessionids that change frequently. See CakeSession::$requestCountdown. | |
| * - `Session.ini` - An associative array of additional ini values to set. | |
| * | |
| * The built in defaults are: | |
| * | |
| * - 'php' - Uses settings defined in your php.ini. | |
| * - 'cake' - Saves session files in CakePHP's /tmp directory. | |
| * - 'database' - Uses CakePHP's database sessions. | |
| * - 'cache' - Use the Cache class to save sessions. | |
| * | |
| * To define a custom session handler, save it at /app/Model/Datasource/Session/<name>.php. | |
| * Make sure the class implements `CakeSessionHandlerInterface` and set Session.handler to <name> | |
| * | |
| * To use database sessions, run the app/Config/Schema/sessions.php schema using | |
| * the cake shell command: cake schema create Sessions | |
| * | |
| */ | |
| Configure::write('Session', array( | |
| 'defaults' => 'php', | |
| 'cookie' => 'ABCD', | |
| 'timeout' => 60, //Session will timeout after 60 minutes of inactivity | |
| 'cookieTimeout' => 1440, //Session cookie will live for at most 24 hours, this does not effect session timeouts | |
| )); | |
| /** | |
| * The level of CakePHP security. | |
| */ | |
| Configure::write('Security.level', 'low'); | |
| /** | |
| * A random string used in security hashing methods. | |
| */ | |
| Configure::write('Security.salt', '123'); | |
| /** | |
| * A random numeric string (digits only) used to encrypt/decrypt strings. | |
| */ | |
| Configure::write('Security.cipherSeed', 'fakseseed'); | |
| /** | |
| * Apply timestamps with the last modified time to static assets (js, css, images). | |
| * Will append a querystring parameter containing the time the file was modified. This is | |
| * useful for invalidating browser caches. | |
| * | |
| * Set to `true` to apply timestamps when debug > 0. Set to 'force' to always enable | |
| * timestamping regardless of debug value. | |
| */ | |
| //Configure::write('Asset.timestamp', true); | |
| /** | |
| * Compress CSS output by removing comments, whitespace, repeating tags, etc. | |
| * This requires a/var/cache directory to be writable by the web server for caching. | |
| * and /vendors/csspp/csspp.php | |
| * | |
| * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css(). | |
| */ | |
| //Configure::write('Asset.filter.css', 'css.php'); | |
| /** | |
| * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the | |
| * output, and setting the config below to the name of the script. | |
| * | |
| * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link(). | |
| */ | |
| //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php'); | |
| /** | |
| * The classname and database used in CakePHP's | |
| * access control lists. | |
| */ | |
| Configure::write('Acl.classname', 'DbAcl'); | |
| Configure::write('Acl.database', 'default'); | |
| /** | |
| * Uncomment this line and correct your server timezone to fix | |
| * any date & time related errors. | |
| */ | |
| date_default_timezone_set('UTC'); | |
| /** | |
| * Pick the caching engine to use. If APC is enabled use it. | |
| * If running via cli - apc is disabled by default. ensure it's available and enabled in this case | |
| * | |
| * Note: 'default' and other application caches should be configured in app/Config/bootstrap.php. | |
| * Please check the comments in boostrap.php for more info on the cache engines available | |
| * and their setttings. | |
| */ | |
| $engine = 'File'; | |
| if (extension_loaded('apc') && function_exists('apc_dec') && (php_sapi_name() !== 'cli' || ini_get('apc.enable_cli'))) { | |
| $engine = 'Apc'; | |
| } | |
| // In development mode, caches should expire quickly. | |
| $duration = '+999 days'; | |
| if (Configure::read('debug') >= 1) { | |
| $duration = '+10 seconds'; | |
| } | |
| // Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts. | |
| $prefix = 'myapp_'; | |
| /** | |
| * Configure the cache used for general framework caching. Path information, | |
| * object listings, and translation cache files are stored with this configuration. | |
| */ | |
| Cache::config('_cake_core_', array( | |
| 'engine' => $engine, | |
| 'prefix' => $prefix . 'cake_core_', | |
| 'path' => CACHE . 'persistent' . DS, | |
| 'serialize' => ($engine === 'File'), | |
| 'duration' => $duration | |
| )); | |
| /** | |
| * Configure the cache for model and datasource caches. This cache configuration | |
| * is used to store schema descriptions, and table listings in connections. | |
| */ | |
| Cache::config('_cake_model_', array( | |
| 'engine' => $engine, | |
| 'prefix' => $prefix . 'cake_model_', | |
| 'path' => CACHE . 'models' . DS, | |
| 'serialize' => ($engine === 'File'), | |
| 'duration' => $duration | |
| )); | |
| Configure::write('beta_testing', false); | |
| Configure::write('bypass_reset_token', true); | |
| Configure::write('BASE_URL', 'http://example.com'); | |
| Configure::write('ENVIRONMENT', 'production'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment