本文整理汇总了PHP中Kohana::environment方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::environment方法的具体用法?PHP Kohana::environment怎么用?PHP Kohana::environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana
的用法示例。
在下文中一共展示了Kohana::environment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
*
* @see http://kohanaframework.org/guide/using.configuration
* @see http://php.net/setlocale
*/
setlocale(LC_ALL, 'en_US.utf-8');
/**
* Enable the Kohana auto-loader.
*
* @see http://kohanaframework.org/guide/using.autoloading
* @see http://php.net/spl_autoload_register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Set the production status by the domain.
*/
Kohana::$environment = ($_SERVER['HTTP_HOST'] !== 'dev.2do.me.uk' and $_SERVER['HTTP_HOST'] !== 'm.dev.2do.me.uk') ? Kohana::PRODUCTION : Kohana::DEVELOPMENT;
//Kohana::$environment = Kohana::PRODUCTION;
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
示例2: getenv
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*/
if (getenv('KOHANA_ENV') !== FALSE)
{
Kohana::$environment = getenv('KOHANA_ENV');
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
示例3:
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set Kohana::$environment if $_ENV['KOHANA_ENV'] has been supplied.
*
*/
if (isset($_ENV['KOHANA_ENV'])) {
Kohana::$environment = $_ENV['KOHANA_ENV'];
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array('base_url' => '/', 'index_file' => FALSE, 'errors' => FALSE));
示例4: constant
* Set the default language
*/
I18n::lang('ru');
if (isset($_SERVER['SERVER_PROTOCOL'])) {
// Replace the default protocol.
HTTP::$protocol = $_SERVER['SERVER_PROTOCOL'];
}
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
Kohana::$environment = Kohana::DEVELOPMENT;
if (isset($_SERVER['KOHANA_ENV'])) {
Kohana::$environment = constant('Kohana::' . strtoupper($_SERVER['KOHANA_ENV']));
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
示例5: array
* Set the default locale.
*/
setlocale(LC_TIME, 'de_DE.utf-8', 'de_DE@euro', 'de_DE', 'de', 'ge', 'German', 'german', 'Germany', 'germany', 'deutsch', 'Deutsch', 'deu', 'deu_deu', '276', 'CTRY_GERMANY');
/**
* Enable the Kohana auto-loader.
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Enable the Kohana auto-loader for unserialization.
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
// DEFAULT LANGUAGE
I18n::lang('de-DE');
// ENVIRONMENT
Kohana::$environment = $_SERVER['SERVER_NAME'] !== 'mtbo' ? Kohana::PRODUCTION : Kohana::DEVELOPMENT;
// INIT
Kohana::init(array('base_url' => '/', 'caching' => Kohana::$environment === Kohana::PRODUCTION, 'profile' => Kohana::$environment !== Kohana::PRODUCTION, 'index_file' => FALSE));
// LOGS
Kohana::$log->attach(new Log_File(APPPATH . 'logs'));
// CONFIGS
Kohana::$config->attach(new Config_File());
// MODULES
Kohana::modules(array('userguide' => MODPATH . 'userguide', 'helper' => MODPATH . 'helper', 'yubico' => MODPATH . 'yubico', 'recaptcha' => MODPATH . 'recaptcha', 'swiftmailer' => MODPATH . 'swiftmailer', 'auth' => MODPATH . 'auth', 'database' => MODPATH . 'database', 'image' => MODPATH . 'image', 'orm' => MODPATH . 'orm'));
Cookie::$salt = ')$Vpx,cwou34hvmp9(/KH§vmpöUZP§)zöä9=H//§%';
// ROUTES
Route::set('mediaresizer', 'media_resize/<path>.<extension>/<dimensions>', array('path' => '[A-Za-z0-9\\/]+', 'dimensions' => '[\\d]+x[\\d]+'))->defaults(array('controller' => 'Media', 'action' => 'resize'));
Route::set('places_today', 'places/neues')->defaults(array('controller' => 'Places', 'action' => 'neues'));
Route::set('places_read', 'places/<user>/<entry>/<seo>', array('entry' => '[\\d]+'))->defaults(array('controller' => 'Places', 'action' => 'show'));
Route::set('places_diary', 'places/diary/<user>/<diary_id>/<seo>(/<page>)', array('diary_id' => '[\\d]+', 'page' => '[\\d]+'))->defaults(array('controller' => 'Places', 'action' => 'index'));
Route::set('places', 'places/<user>(/<page>)', array('page' => '[\\d]+'))->defaults(array('controller' => 'Places', 'action' => 'index'));
示例6: array
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
*/
if (in_array(@$_SERVER['SERVER_NAME'], array('127.0.0.1', 'fe80::1', '::1', 'localhost', '192.168.2.164', '192.168.0.123'))) {
$init = array('base_url' => "/tizzy", 'index_file' => "index.php", 'errors' => TRUE, 'profile' => Kohana::$environment === Kohana::DEVELOPMENT);
Kohana::$environment = Kohana::DEVELOPMENT;
} else {
$init = array('base_url' => "/", 'index_file' => FALSE, 'errors' => TRUE, 'profile' => Kohana::$environment === Kohana::PRODUCTION);
Kohana::$environment = Kohana::PRODUCTION;
}
Kohana::init($init);
/**
* Setting Cookie::$salt
*/
Cookie::$salt = '29961408e9a1bbbf0456dd913a12d31fffa587cc';
/**
* 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());
/**
示例7: constant
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set the default language
*/
I18n::lang('en-us');
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*/
if (getenv('KOHANA_ENV') !== false) {
Kohana::$environment = constant('Kohana::' . strtoupper(getenv('KOHANA_ENV')));
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array('base_url' => '/', 'index_file' => false, 'caching' => !in_array(Kohana::$environment, array(Kohana::DEVELOPMENT, Kohana::TESTING))));
示例8: constant
*/
I18n::lang('ru');
if (isset($_SERVER['SERVER_PROTOCOL'])) {
// Replace the default protocol.
HTTP::$protocol = $_SERVER['SERVER_PROTOCOL'];
}
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
if (isset($_SERVER['KOHANA_ENV'])) {
Kohana::$environment = constant('Kohana::' . strtoupper($_SERVER['KOHANA_ENV']));
} else {
Kohana::$environment = constant('Kohana::' . strtoupper(substr(strtolower($_SERVER['HTTP_HOST']), -4) == '.dev' ? 'DEVELOPMENT' : 'PRODUCTION'));
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
示例9: constant
* @see http://php.net/spl_autoload_register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set if the application is in development (FALSE)
* or if the application is in production (TRUE).
*/
Kohana::$environment = constant('Kohana::' . strtoupper(Arr::get($_SERVER, 'KOHANA_ENV', 'PRODUCTION')));
/**
* Display errors only when in development.
*/
ini_set('display_errors', Kohana::$environment != Kohana::PRODUCTION);
if (Kohana::$environment == Kohana::PRODUCTION) {
error_reporting(E_ALL ^ E_NOTICE);
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
示例10: define
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
/**
* Set the default language
*/
I18n::lang('en-us');
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
if (isset($_SERVER['KOHANA_ENV'])) {
define('ENVIRONMENT', Kohana::$environment = constant('Kohana::' . strtoupper($_SERVER['KOHANA_ENV'])));
}
/**
* configure environment constants
*/
require_once 'configuration/configure.php';
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
示例11: strtoupper
* @see http://kohanaframework.org/guide/using.autoloading
* @see http://php.net/spl_autoload_register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
if (isset($_SERVER['KOHANA_ENV'])) {
$env = 'Kohana::' . strtoupper($_SERVER['KOHANA_ENV']);
Kohana::$environment = constant($env);
} elseif (defined('KOHANA_ENV')) {
$env = 'Kohana::' . strtoupper(KOHANA_ENV);
Kohana::$environment = constant($env);
}
if (Kohana::$environment === Kohana::DEVELOPMENT) {
$config = array('timezone' => 'Europe/Kiev', 'locale' => 'ru_RU.utf-8', 'language' => 'ru', 'caching' => FALSE, 'profile' => TRUE, 'errors' => TRUE, 'charset' => 'utf-8', 'modules' => 'apis/twitter, asset, auth, cache, beanstalk, database, demo, event, image, mailer, oauth, orm, orm-mptt, pagination, plater, resizer, unittest, sso, libs, jelly, jelly-auth', 'cache_dir' => APPPATH . 'cache', 'logdir' => APPPATH . '../etc/logs/application', 'salt' => 'nd79Y!cPDG!SuWV$rWT8uHdJk%*T2ve84%#&9GCwN6c^5Hbj54^P$Ckx!8RH');
if (PHP_SAPI != 'cli') {
$config['modules'] .= ', devbar';
}
} elseif (Kohana::$environment === Kohana::TESTING) {
$config = array('timezone' => 'Europe/Kiev', 'locale' => 'en_US', 'language' => 'en-us', 'caching' => TRUE, 'profile' => FALSE, 'errors' => FALSE, 'charset' => 'utf-8', 'modules' => 'apis/twitter, asset, auth, cache, beanstalk, database, demo, event, image, mailer, oauth, orm, orm-mptt, pagination, plater, resizer, sso, libs, jelly, jelly-auth', 'cache_dir' => APPPATH . 'cache', 'logdir' => FALSE, 'salt' => '22sjmFA%$3uUb3d7AKG82A^unxGkdvMR9!5*47czjRWFFDBz!Bb@Q7Epf5^b');
} else {
$config = array('timezone' => 'Europe/Kiev', 'locale' => 'ru_RU.utf-8', 'language' => 'ru', 'caching' => TRUE, 'profile' => FALSE, 'errors' => FALSE, 'charset' => 'utf-8', 'modules' => 'apis/twitter, asset, auth, cache, beanstalk, database, event, image, mailer, oauth, orm, orm-mptt, pagination, plater, resizer, sso, libs', 'cache_dir' => APPPATH . 'cache', 'logdir' => APPPATH . '../etc/logs/application', 'salt' => '6wGwxJmevA$r92e5ZNmCK#C4UeET#$J2x%tA4E&R2HV8R5pvv^BtA@sjdT3f');
}
/**
* Set the default time zone.
*
* @see http://kohanaframework.org/guide/using.configuration
示例12:
* @see http://php.net/timezones
*/
date_default_timezone_set('America/Chicago');
/**
* Enable the Kohana auto-loader.
*
* @see http://docs.kohanaphp.com/features/autoloading
* @see http://php.net/spl_autoload_register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Set the environment status by the domain.
*/
if (strpos($_SERVER['HTTP_HOST'], 'kohanaphp.com') !== FALSE) {
// We are live!
Kohana::$environment = 'live';
// Turn off notices and strict errors
error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT);
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
示例13: getenv
/**
* Enable the Kohana auto-loader for unserialization.
*
* @see http://php.net/spl_autoload_call
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
//-- Configuration and initialization -----------------------------------------
/**
* Set Kohana::$environment if $_ENV['KOHANA_ENV'] has been supplied.
*
*/
if (getenv('SOURCEMAP_ENV')) {
Kohana::$environment = getenv('SOURCEMAP_ENV');
} else {
Kohana::$environment = Sourcemap::PRODUCTION;
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
*/
Kohana::init(array('cache_dir' => CACHEPATH, 'index_file' => ''));
示例14: define
/*
* Load and configure Kohana Core
*/
if (!defined('KOHANA_START_TIME')) {
define('KOHANA_START_TIME', microtime(TRUE));
}
if (!defined('KOHANA_START_MEMORY')) {
define('KOHANA_START_MEMORY', memory_get_usage());
}
require SYSPATH . 'classes/Kohana/Core' . EXT;
require SYSPATH . 'classes/Kohana' . EXT;
require DOCROOT . 'vendor/autoload.php';
spl_autoload_register(array('Kohana', 'auto_load'));
ini_set('unserialize_callback_func', 'spl_autoload_call');
I18n::lang(KOHANA_LANG);
Kohana::$environment = constant('Kohana::' . strtoupper(KOHANA_ENVIRONMENT));
/*
* Try to create log directory.
*/
$cache_dir = APPPATH . 'cache';
if (!file_exists($cache_dir)) {
// Create directory, after the precedent of Kohana_Core::init();
mkdir($cache_dir, 0755, TRUE) or die('Unable to make directory ' . $cache_dir);
chmod($cache_dir, 0755);
}
/**
* Shutdown for CLI, can be removed when http://dev.kohanaframework.org/issues/4537 is resolved.
*/
if (PHP_SAPI == 'cli') {
register_shutdown_function(function () {
if (Kohana::$errors and $error = error_get_last() and in_array($error['type'], Kohana::$shutdown_errors)) {
示例15: action_update
/**
* Update selected database
*
* @throws Exception On unknown database configuration
*/
public function action_update()
{
$this->db_name = $this->request->param('database', NULL);
if (!$this->db_name) {
self::display('Please select the database to perform update on dbupdate/update/[testing|default].', 'red');
return;
}
switch ($this->db_name) {
case 'dev':
Kohana::$environment = Kohana::DEVELOPMENT;
break;
case 'test':
Kohana::$environment = Kohana::TESTING;
break;
case 'prod':
Kohana::$environment = Kohana::PRODUCTION;
break;
default:
throw new Exception('Unknown database.');
}
while (TRUE) {
$this->setup();
self::display();
self::display('Current DB version is ' . ($this->current_version ?: 'NULL') . '. Latest version is ' . $this->latest_version . ".\n");
self::display('z) Update to latest version considering applied versions.
c) See description of new versions.
m) Mark as applied
r) Run specific migration (advanced)
d) Create skeleton version file.
x) Exit
Choose option ==> ', FALSE);
$input = trim(fgets(STDIN));
switch ($input) {
case 'x':
return;
break;
case 'z':
// Update to a version considering applied migrations
$this->apply_migrations();
return;
break;
case 'c':
self::display();
$not_applied = $this->get_not_applied_versions();
foreach ($not_applied as $version => $file) {
require_once $file;
$class = 'C' . $version;
$c = new $class();
self::display('Version ' . $version . ': ' . $c->desc . "\n");
foreach ($c->sqls as $sql) {
self::display(trim($sql));
}
self::display();
self::display('-------------------------------------------------');
}
break;
// Create skeleton file for next version
// Create skeleton file for next version
case 'd':
$resp = Request::factory('/dbupdate/skel')->execute();
self::display($resp . '');
break;
case 'm':
$this->mark_applied();
break;
case 'r':
self::display("\nApply migration (ENTER to exit) ==> ", FALSE);
$input = trim(fgets(STDIN));
if ($input !== '') {
$versions = $this->get_versions();
if (array_key_exists($input, $versions)) {
$this->apply_migrations(array($input => $versions[$input]));
} else {
self::display("\nMigration: " . $input . ' does not exist!', 'red');
}
}
break;
}
}
}