本文整理汇总了PHP中Laravel\Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::set方法的具体用法?PHP Config::set怎么用?PHP Config::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laravel\Config
的用法示例。
在下文中一共展示了Config::set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: retrieve
/**
* Get the current user of the application.
*
* If the user is a guest, null should be returned.
*
* @param int $id
* @return mixed|null
*/
public function retrieve($id)
{
if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
// We want to return the object as an array.
$current = Config::get('database.fetch');
Config::set('database.fetch', \PDO::FETCH_ASSOC);
// Grab user and return fetch to what it was before the query.
$user = DB::table(Config::get('auth.table'))->where('UsersId', '=', $id)->first();
Config::set('database.fetch', $current);
return $user;
}
}
示例2: inline
/**
* Create a response that will force a image to be displayed inline.
*
* @param string $path Path to the image
* @param string $name Filename
* @param int $lifetime Lifetime in browsers cache
* @return Response
*/
public static function inline($path, $name = null, $lifetime = 0)
{
if (is_null($name)) {
$name = basename($path);
}
$filetime = filemtime($path);
$etag = md5($filetime . $path);
$time = gmdate('r', $filetime);
$expires = gmdate('r', $filetime + $lifetime);
$length = filesize($path);
$headers = array('Content-Disposition' => 'inline; filename="' . $name . '"', 'Last-Modified' => $time, 'Cache-Control' => 'must-revalidate', 'Expires' => $expires, 'Pragma' => 'public', 'Etag' => $etag);
// If enabled, we need to disable the profiler
LaravelConfig::set('application.profiler', false);
// Check the Browsers cache
$headerTest1 = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $time;
$headerTest2 = isset($_SERVER['HTTP_IF_NONE_MATCH']) && str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag;
if ($headerTest1 || $headerTest2) {
//image is cached by the browser, we dont need to send it again
return static::make('', 304, $headers);
}
$fileinfos = Imwg::imageInfo($path);
$headers = array_merge($headers, array('Content-Type' => $fileinfos['mime'], 'Content-Length' => $length));
return static::make(File::get($path), 200, $headers);
}
示例3: path
use Laravel\Bundle;
use Laravel\Config;
use Laravel\Request;
/**
* Fire up the default bundle. This will ensure any dependencies that
* need to be registered in the IoC container are registered and that
* the auto-loader mappings are registered.
*/
Bundle::start(DEFAULT_BUNDLE);
/**
* The default database connection may be set by specifying a value
* for the "database" CLI option. This allows migrations to be run
* conveniently for a test or staging database.
*/
if (!is_null($database = get_cli_option('db'))) {
Config::set('database.default', $database);
}
/**
* We will register all of the Laravel provided tasks inside the IoC
* container so they can be resolved by the task class. This allows
* us to seamlessly add tasks to the CLI so that the Task class
* doesn't have to worry about how to resolve core tasks.
*/
require path('sys') . 'cli/dependencies' . EXT;
/**
* We will wrap the command execution in a try / catch block and
* simply write out any exception messages we receive to the CLI
* for the developer. Note that this only writes out messages
* for the CLI exceptions. All others will be not be caught
* and will be totally dumped out to the CLI.
*/
示例4: __construct
/**
* Create a new Eloquent model instance.
*
* @param array $attributes
* @return void
*/
public function __construct($attributes = array())
{
$params = Bootstrap::$bag['config']->getDatabase();
Config::set('database.default', 'mysql');
Config::set('database.connections', array('mysql' => array('driver' => 'mysql', 'host' => $params->getHost(), 'database' => $params->getDbname(), 'username' => $params->getUsername(), 'password' => $params->getPassword(), 'charset' => 'utf8')));
$this->fill($attributes);
}
示例5: uninstall
public static function uninstall($module_slug)
{
if (empty($module_slug)) {
static::$errors->add('installer', 'Failed to uninstall module [' . $module_slug . ']');
return false;
}
$module = Model\Module::where('slug', '=', $module_slug)->first();
if (isset($module)) {
if (static::schema('uninstall', $module->slug)) {
//clean any message from schema
ob_get_clean();
if (static::migrate($module->slug, 'rollback')) {
//clean any message from migration
ob_get_clean();
// Remove the module from the config array
// updates information if we are in the same
// request eg: (ajax)
$installed_modules = Config::get('installed_modules');
unset($installed_modules[$module_slug]);
Config::set('installed_modules', $installed_modules);
// Remove from DB
$module->delete();
return true;
} else {
static::$errors->add('installer', 'Failed to rollback migrations for module ' . $module_slug . '.');
return false;
}
} else {
static::$errors->add('installer', 'Failed to uninstall data schema for module ' . $module_slug . '.');
return false;
}
} else {
static::$errors->add('installer', 'Module ' . $module_slug . ' was not found.');
return false;
}
}
示例6: function
error_reporting(-1);
Bundle::start(DEFAULT_BUNDLE);
foreach (Bundle::$bundles as $bundle => $config) {
if ($config['auto']) {
Bundle::start($bundle);
}
}
Router::register('*', '(:all)', function () {
return Event::first('404');
});
$uri = URI::current();
$languages = Config::get('application.languages', array());
$languages[] = Config::get('application.language');
foreach ($languages as $language) {
if (preg_match("#^{$language}(?:\$|/)#i", $uri)) {
Config::set('application.language', $language);
$uri = trim(substr($uri, strlen($language)), '/');
break;
}
}
if ($uri == '') {
$uri = '/';
}
URI::$uri = $uri;
Request::$route = Router::route(Request::method(), $uri);
$response = Request::$route->call();
$response->render();
if (Config::get('session.driver') !== '') {
Session::save();
}
$response->send();
示例7: path
defined('DS') or die('No direct script access.');
use Laravel\Bundle;
use Laravel\Config;
/**
* Fire up the default bundle. This will ensure any dependencies that
* need to be registered in the IoC container are registered and that
* the auto-loader mappings are registered.
*/
Bundle::start(DEFAULT_BUNDLE);
/**
* The default database connection may be set by specifying a value
* for the "database" CLI option. This allows migrations to be run
* conveniently for a test or staging database.
*/
if (isset($_SERVER['CLI']['DB'])) {
Config::set('database.default', $_SERVER['CLI']['DB']);
}
/**
* We will register all of the Laravel provided tasks inside the IoC
* container so they can be resolved by the task class. This allows
* us to seamlessly add tasks to the CLI so that the Task class
* doesn't have to worry about how to resolve core tasks.
*/
require path('sys') . 'cli/dependencies' . EXT;
/**
* We will wrap the command execution in a try / catch block and
* simply write out any exception messages we receive to the CLI
* for the developer. Note that this only writes out messages
* for the CLI exceptions. All others will be not be caught
* and will be totally dumped out to the CLI.
*/