本文整理汇总了PHP中Kohana::expose方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::expose方法的具体用法?PHP Kohana::expose怎么用?PHP Kohana::expose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::expose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_expose
/**
* Ensures that Kohana::$expose adds the x-powered-by header and
* makes sure it's set to the correct Kohana Framework string
*
* @test
*/
public function test_expose()
{
Kohana::$expose = TRUE;
$response = new Response();
$headers = $response->send_headers()->headers();
$this->assertArrayHasKey('x-powered-by', (array) $headers);
if (isset($headers['x-powered-by'])) {
$this->assertSame($headers['x-powered-by']->value, 'Kohana Framework ' . Kohana::VERSION . ' (' . Kohana::CODENAME . ')');
}
Kohana::$expose = FALSE;
$response = new Response();
$headers = $response->send_headers()->headers();
$this->assertArrayNotHasKey('x-powered-by', (array) $headers);
}
示例2: test_expose
/**
* Ensures that Kohana::$expose adds the x-powered-by header and
* makes sure it's set to the correct Kohana Framework string
*
* @test
*/
public function test_expose()
{
$this->markTestSkipped('send_headers() can only be executed once, test will never pass in current API');
Kohana::$expose = TRUE;
$response = new Response();
$headers = $response->send_headers()->headers();
$this->assertArrayHasKey('x-powered-by', (array) $headers);
if (isset($headers['x-powered-by'])) {
$this->assertSame($headers['x-powered-by']->value, 'Kohana Framework ' . Kohana::VERSION . ' (' . Kohana::CODENAME . ')');
}
Kohana::$expose = FALSE;
$response = new Response();
$headers = $response->send_headers()->headers();
$this->assertArrayNotHasKey('x-powered-by', (array) $headers);
}
示例3: init
/**
* Initializes the environment:
*
* - Disables register_globals and magic_quotes_gpc
* - Determines the current environment
* - Set global settings
* - Sanitizes GET, POST, and COOKIE variables
* - Converts GET, POST, and COOKIE variables to the global character set
*
* The following settings can be set:
*
* Type | Setting | Description | Default Value
* ----------|------------|------------------------------------------------|---------------
* `string` | base_url | The base URL for your application. This should be the *relative* path from your DOCROOT to your `index.php` file, in other words, if Kohana is in a subfolder, set this to the subfolder name, otherwise leave it as the default. **The leading slash is required**, trailing slash is optional. | `"/"`
* `string` | index_file | The name of the [front controller](http://en.wikipedia.org/wiki/Front_Controller_pattern). This is used by Kohana to generate relative urls like [HTML::anchor()] and [URL::base()]. This is usually `index.php`. To [remove index.php from your urls](tutorials/clean-urls), set this to `FALSE`. | `"index.php"`
* `string` | charset | Character set used for all input and output | `"utf-8"`
* `string` | cache_dir | Kohana's cache directory. Used by [Kohana::cache] for simple internal caching, like [Fragments](kohana/fragments) and **\[caching database queries](this should link somewhere)**. This has nothing to do with the [Cache module](cache). | `APPPATH."cache"`
* `integer` | cache_life | Lifetime, in seconds, of items cached by [Kohana::cache] | `60`
* `boolean` | errors | Should Kohana catch PHP errors and uncaught Exceptions and show the `error_view`. See [Error Handling](kohana/errors) for more info. <br /> <br /> Recommended setting: `TRUE` while developing, `FALSE` on production servers. | `TRUE`
* `boolean` | profile | Whether to enable the [Profiler](kohana/profiling). <br /> <br />Recommended setting: `TRUE` while developing, `FALSE` on production servers. | `TRUE`
* `boolean` | caching | Cache file locations to speed up [Kohana::find_file]. This has nothing to do with [Kohana::cache], [Fragments](kohana/fragments) or the [Cache module](cache). <br /> <br /> Recommended setting: `FALSE` while developing, `TRUE` on production servers. | `FALSE`
* `boolean` | expose | Set the X-Powered-By header
*
* @throws Kohana_Exception
* @param array $settings Array of settings. See above.
* @return void
* @uses Kohana::globals
* @uses Kohana::sanitize
* @uses Kohana::cache
* @uses Profiler
*/
public static function init(array $settings = NULL)
{
if (Kohana::$_init) {
// Do not allow execution twice
return;
}
// Kohana is now initialized
Kohana::$_init = TRUE;
if (isset($settings['profile'])) {
// Enable profiling
Kohana::$profiling = (bool) $settings['profile'];
}
// Start an output buffer
ob_start();
if (isset($settings['errors'])) {
// Enable error handling
Kohana::$errors = (bool) $settings['errors'];
}
if (Kohana::$errors === TRUE) {
// Enable Kohana exception handling, adds stack traces and error source.
set_exception_handler(array('Kohana_Exception', 'handler'));
// Enable Kohana error handling, converts all PHP errors to exceptions.
set_error_handler(array('Kohana', 'error_handler'));
}
/**
* Enable xdebug parameter collection in development mode to improve fatal stack traces.
*/
if (Kohana::$environment == Kohana::DEVELOPMENT and extension_loaded('xdebug')) {
ini_set('xdebug.collect_params', 3);
}
// Enable the Kohana shutdown handler, which catches E_FATAL errors.
register_shutdown_function(array('Kohana', 'shutdown_handler'));
if (ini_get('register_globals')) {
// Reverse the effects of register_globals
Kohana::globals();
}
if (isset($settings['expose'])) {
Kohana::$expose = (bool) $settings['expose'];
}
// Determine if we are running in a Windows environment
Kohana::$is_windows = DIRECTORY_SEPARATOR === '\\';
// Determine if we are running in safe mode
Kohana::$safe_mode = (bool) ini_get('safe_mode');
if (isset($settings['cache_dir'])) {
if (!is_dir($settings['cache_dir'])) {
try {
// Create the cache directory
mkdir($settings['cache_dir'], 0755, TRUE);
// Set permissions (must be manually set to fix umask issues)
chmod($settings['cache_dir'], 0755);
} catch (Exception $e) {
throw new Kohana_Exception('Could not create cache directory :dir', array(':dir' => Debug::path($settings['cache_dir'])));
}
}
// Set the cache directory path
Kohana::$cache_dir = realpath($settings['cache_dir']);
} else {
// Use the default cache directory
Kohana::$cache_dir = APPPATH . 'cache';
}
if (!is_writable(Kohana::$cache_dir)) {
throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Debug::path(Kohana::$cache_dir)));
}
if (isset($settings['cache_life'])) {
// Set the default cache lifetime
Kohana::$cache_life = (int) $settings['cache_life'];
}
if (isset($settings['caching'])) {
// Enable or disable internal caching
//.........这里部分代码省略.........
示例4: test_send_headers
/**
* Tests that send headers processes the headers sent to PHP correctly
*
* @dataProvider provider_send_headers
*
* @param array state in
* @param array expected out
* @return void
*/
public function test_send_headers(array $state, array $expected, $expose)
{
Kohana::$expose = $expose;
$response = new Response();
$response->headers($state);
$this->assertSame($expected, $response->send_headers(FALSE, array($this, 'send_headers_handler')));
}
示例5:
/**
* Attach the file write to logging. Multiple writers are supported.
*/
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
/**
* Attach a file reader to config. Multiple readers are supported.
*/
Kohana::$config->attach(new Config_File());
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array('cache' => MODPATH . 'cache', 'kostache' => MODPATH . 'kostache'));
/*
* We want to show the world we're running on... Kohana of course!
*/
Kohana::$expose = TRUE;
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('error', 'error')->defaults(array('controller' => 'home', 'action' => 'error'));
Route::set('download', 'download')->defaults(array('controller' => 'download', 'action' => 'index'));
Route::set('documentation', 'documentation')->defaults(array('controller' => 'documentation', 'action' => 'index'));
Route::set('development', 'development')->defaults(array('controller' => 'development', 'action' => 'index'));
Route::set('team', 'team')->defaults(array('controller' => 'team', 'action' => 'index'));
Route::set('license', 'license')->defaults(array('controller' => 'license', 'action' => 'index'));
Route::set('donate', 'donate')->defaults(array('controller' => 'donate', 'action' => 'index'));
Route::set('home', '(index)')->defaults(array('controller' => 'home', 'action' => 'index'));
// // Handles: feed/$type.rss and feed/$type.atom
// Route::set('feed', 'feed/<name>', array('name' => '.+'))
// ->defaults(array(
示例6: ready
/**
* Runs the Gleez environment
*
* @uses Gleez::_set_cookie
* @uses Route::set
* @uses Route::defaults
* @uses Config::load
* @uses I18n::initialize
* @uses Module::load_modules
*/
public static function ready()
{
if (self::$_init) {
// Do not allow execution twice
return;
}
// Gleez is now initialized?
self::$_init = TRUE;
// Set default cookie salt and lifetime
self::_set_cookie();
// Check database config file exist or not
Gleez::$installed = file_exists(APPPATH . 'config/database.php');
if (Gleez::$installed) {
// Database config reader and writer
Kohana::$config->attach(new Config_Database());
}
if (Kohana::$environment !== Kohana::DEVELOPMENT) {
Gleez_Exception::$error_view = 'errors/stack';
}
// Turn off notices and strict errors in production
if (Kohana::$environment === Kohana::PRODUCTION) {
// Turn off notices and strict errors
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
}
// Initialize the locale from settings
I18n::initialize();
// Disable the kohana powered headers
// @todo Remove it, use Gleez::$expose
Kohana::$expose = FALSE;
/**
* If database.php doesn't exist, then we assume that the Gleez is not
* properly installed and send to the installer.
*/
if (!Gleez::$installed) {
Session::$default = 'cookie';
Gleez_Exception::$error_view = 'errors/error';
// Static file serving (CSS, JS, images)
Route::set('install/media', 'media(/<file>)', array('file' => '.+'))->defaults(array('controller' => 'install', 'action' => 'media', 'file' => NULL, 'directory' => 'install'));
Route::set('install', '(install(/<action>))', array('action' => 'index|systemcheck|database|install|finalize'))->defaults(array('controller' => 'install', 'directory' => 'install'));
return;
}
// Set the default session type
Session::$default = Config::get('site.session_type');
// Initialize Gleez modules
Module::load_modules(FALSE);
// Load the active theme(s)
Theme::load_themes();
}
示例7: init
/**
* Initializes the environment:
*
* - Disables register_globals and magic_quotes_gpc
* - Determines the current environment
* - Set global settings
* - Sanitizes GET, POST, and COOKIE variables
* - Converts GET, POST, and COOKIE variables to the global character set
*
* The following settings can be set:
*
* Type | Setting | Description | Default Value
* ----------|------------|------------------------------------------------|---------------
* `string` | base_url | The base URL for your application. This should be the *relative* path from your DOCROOT to your `index.php` file, in other words, if Kohana is in a subfolder, set this to the subfolder name, otherwise leave it as the default. **The leading slash is required**, trailing slash is optional. | `"/"`
* `string` | index_file | The name of the [front controller](http://en.wikipedia.org/wiki/Front_Controller_pattern). This is used by Kohana to generate relative urls like [HTML::anchor()] and [URL::base()]. This is usually `index.php`. To [remove index.php from your urls](tutorials/clean-urls), set this to `FALSE`. | `"index.php"`
* `string` | charset | Character set used for all input and output | `"utf-8"`
* `string` | cache_dir | Kohana's cache directory. Used by [Kohana::cache] for simple internal caching, like [Fragments](kohana/fragments) and **\[caching database queries](this should link somewhere)**. This has nothing to do with the [Cache module](cache). | `APPPATH."cache"`
* `integer` | cache_life | Lifetime, in seconds, of items cached by [Kohana::cache] | `60`
* `boolean` | errors | Should Kohana catch PHP errors and uncaught Exceptions and show the `error_view`. See [Error Handling](kohana/errors) for more info. <br /> <br /> Recommended setting: `TRUE` while developing, `FALSE` on production servers. | `TRUE`
* `boolean` | profile | Whether to enable the [Profiler](kohana/profiling). <br /> <br />Recommended setting: `TRUE` while developing, `FALSE` on production servers. | `TRUE`
* `boolean` | caching | Cache file locations to speed up [Kohana::find_file]. This has nothing to do with [Kohana::cache], [Fragments](kohana/fragments) or the [Cache module](cache). <br /> <br /> Recommended setting: `FALSE` while developing, `TRUE` on production servers. | `FALSE`
* `boolean` | expose | Set the X-Powered-By header
*
* @throws Gleez_Exception
* @param array $settings Array of settings. See above.
* @return void
*
* @uses Kohana::globals
* @uses Kohana::sanitize
* @uses Kohana::cache
* @uses Profiler
* @uses System::mkdir
*/
public static function init(array $settings = NULL)
{
if (Kohana::$_init) {
// Do not allow execution twice
return;
}
// Kohana is now initialized
Kohana::$_init = TRUE;
if (isset($settings['profile'])) {
// Enable profiling
Kohana::$profiling = (bool) $settings['profile'];
}
// Start an output buffer
ob_start();
if (isset($settings['errors'])) {
// Enable error handling
Kohana::$errors = (bool) $settings['errors'];
}
if (Kohana::$errors === TRUE) {
// Enable Gleez exception handling, adds stack traces and error source.
set_exception_handler(array('Gleez_Exception', 'handler'));
// Enable Kohana error handling, converts all PHP errors to exceptions.
set_error_handler(array('Kohana', 'error_handler'));
}
if (isset($settings['autolocale'])) {
// Manual enable Gleez_Locale
Kohana::$autolocale = (bool) $settings['autolocale'];
}
// Enable the Kohana shutdown handler, which catches E_FATAL errors.
register_shutdown_function(array('Kohana', 'shutdown_handler'));
if (ini_get('register_globals')) {
// Reverse the effects of register_globals
Kohana::globals();
}
if (isset($settings['expose'])) {
Kohana::$expose = (bool) $settings['expose'];
}
// Determine if we are running in a command line environment
Kohana::$is_cli = PHP_SAPI === 'cli';
// Determine if we are running in a Windows environment
Kohana::$is_windows = DS === '\\';
// Determine if we are running in safe mode
Kohana::$safe_mode = (bool) ini_get('safe_mode');
if (isset($settings['cache_dir'])) {
if (!is_dir($settings['cache_dir'])) {
try {
// Create the cache directory
System::mkdir($settings['cache_dir']);
} catch (Exception $e) {
throw new Gleez_Exception('Could not create cache directory :dir', array(':dir' => Debug::path($settings['cache_dir'])));
}
}
// Set the cache directory path
Kohana::$cache_dir = realpath($settings['cache_dir']);
} else {
// Use the default cache directory
Kohana::$cache_dir = APPPATH . 'cache';
}
if (!is_dir(Kohana::$cache_dir)) {
try {
System::mkdir(Kohana::$cache_dir);
} catch (Exception $e) {
throw new Gleez_Exception('Could not create cache directory :dir', array(':dir' => Debug::path(Kohana::$cache_dir)));
}
}
if (!is_writable(Kohana::$cache_dir)) {
throw new Gleez_Exception('Directory :dir must be writable', array(':dir' => Debug::path(Kohana::$cache_dir)));
//.........这里部分代码省略.........