php Laravel-Config类(方法)实例源码

下面列出了php Laravel-Config 类(方法)源码代码实例,从而了解它的用法。

作者:victoroliveira160    项目:Laravel-Bootstra   
/**
  * Create a new language line instance.
  *
  * <code>
  *		// Create a new language line instance for a given line
  *		$line = Lang::line('validation.required');
  *
  *		// Create a new language line for a line belonging to a bundle
  *		$line = Lang::line('admin::messages.welcome');
  *
  *		// Specify some replacements for the language line
  *		$line = Lang::line('validation.required', array('attribute' => 'email'));
  * </code>
  *
  * @param  string  $key
  * @param  array   $replacements
  * @param  string  $language
  * @return Lang
  */
 public static function line($key, $replacements = array(), $language = null)
 {
     if (is_null($language)) {
         $language = Config::get('application.language');
     }
     return new static($key, $replacements, $language);
 }

作者:SerdarSanr    项目:laravel-wee   
/**
  * Render the view.
  *
  * @return string
  * @throws \Exception
  */
 public function render()
 {
     // Events
     Event::fire("laravel.composing: {$this->view}", array($this));
     // Buffer the output
     ob_start();
     try {
         // array of paths where to find the views
         $paths = Config::get('weed::weed.paths');
         // build the Twig object
         $loader = new Twig\Weed\Loader\Filesystem($paths);
         // define the Twig environment
         $config = array('cache' => Config::get('weed::weed.cache'), 'debug' => Config::get('weed::weed.debug'), 'auto_reload' => Config::get('weed::weed.auto_reload'));
         $twig = new \Twig_Environment($loader, $config);
         // register the desired extensions
         foreach (Config::get('weed::weed.extensions') as $extension) {
             $twig->addExtension(new $extension());
         }
         // output the rendered template :-)
         echo $twig->render($this->template, $this->data());
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ob_get_clean();
 }

作者:gigikir    项目:masjid-l   
/**
  * Create a new cache driver instance.
  *
  * @param  string  $driver
  * @return Cache\Drivers\Driver
  */
 protected static function factory($driver)
 {
     if (isset(static::$registrar[$driver])) {
         $resolver = static::$registrar[$driver];
         return $resolver();
     }
     switch ($driver) {
         case 'apc':
             return new Cache\Drivers\APC(Config::get('cache.key'));
         case 'file':
             return new Cache\Drivers\File(path('storage') . 'cache' . DS);
         case 'memcached':
             return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key'));
         case 'memory':
             return new Cache\Drivers\Memory();
         case 'redis':
             return new Cache\Drivers\Redis(Redis::db());
         case 'database':
             return new Cache\Drivers\Database(Config::get('cache.key'));
         case 'wincache':
             return new Cache\Drivers\WinCache(Config::get('cache.key'));
         default:
             throw new \Exception("Cache driver {$driver} is not supported.");
     }
 }

作者:cloudmani    项目:php-warches   
public static function sessioninit()
 {
     // See if we have passed in a access_token and an account id.
     if (Input::get('access_token') && Input::get('account_id')) {
         $access_token = Input::get('access_token');
         $account_id = Input::get('account_id');
     } else {
         // See if we have a session. If Not do something about it.
         if (!Session::get('AccountId') || !Session::get('AccessToken')) {
             die(header('location: ' . Config::get('site.login_url')));
         }
         $access_token = Session::get('AccessToken');
         $account_id = Session::get('AccountId');
     }
     // Is this a multi tenant setup? If so set the account.
     if (Config::get('cloudmanic.account')) {
         if (!(self::$account = \Accounts::get_by_id($account_id))) {
             $data = array('status' => 0, 'errors' => array());
             $data['errors'][] = 'Account not found.';
             return \Laravel\Response::json($data);
         }
     }
     // Validate the access_token
     if (!($user = Users::get_by_access_token($access_token))) {
         $data = array('status' => 0, 'errors' => array());
         $data['errors'][] = 'Access token not valid.';
         return \Laravel\Response::json($data);
     } else {
         self::_do_user($user);
     }
 }

作者:ashicu    项目:apocalyps   
public static function getFields($model)
 {
     $excluded = Config::get('Adminify::settings.fields');
     if (!isset($excluded[$model])) {
         return $excluded['all'];
     }
     return array_merge($excluded['all'], $excluded[$model]);
 }

作者:reith200    项目:component   
/**
  * Get a module renderer driver instance.
  *
  * @param  string  $driver
  * 
  * @return Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('admin::renderer.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }

作者:acmad    项目:language-builde   
/**
  * Get files for comparision editing
  *
  * @param string $name
  * @param string $location
  * @param string $translation
  * @return array
  */
 public static function get_files($name, $location, $translation)
 {
     $path = \Laravel\Bundle::path($location);
     if (!is_file($path . 'language/' . $translation . '/' . $name . '.php')) {
         return null;
     }
     $language['from'] = (require $path . 'language/' . \Laravel\Config::get('language-builder::builder.base_lang') . '/' . $name . '.php');
     $language['to'] = (require $path . 'language/' . $translation . '/' . $name . '.php');
     return $language;
 }

作者:reith200    项目:component   
public function __construct($name)
 {
     parent::__construct($name);
     $this->config = Config::get('thirdparty_assetcompressor::assetcompressor');
     $this->config['cache_dir'] = $this->config['cache_dir'] . '/';
     $this->config['cache_dir_path'] = path('public') . $this->config['cache_dir'];
     if (!is_dir($this->config['cache_dir_path'])) {
         mkdir($this->config['cache_dir_path']);
     }
 }

作者:reith200    项目:component   
/**
  * Get a API driver instance.
  *
  * If no driver name is specified, the default will be returned.
  *
  * <code>
  *		// Get the default API driver instance
  *		$driver = API::driver();
  *
  *		// Get a specific API driver instance by name
  *		$driver = API::driver('mysql');
  * </code>
  *
  * @param  string        $driver
  * @return API\Drivers\Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('layla.' . static::$component . '.api.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }

作者:reith200    项目:component   
/**
  * Get a DBManager driver instance.
  *
  * If no driver name is specified, the default will be returned.
  *
  * <code>
  *		// Get the default DBManager driver instance
  *		$driver = DBManager::driver();
  *
  *		// Get a specific DBManager driver instance by name
  *		$driver = DBManager::driver('mysql');
  * </code>
  *
  * @param  string        $driver
  * @return DBManager\Drivers\Driver
  */
 public static function driver($driver = null)
 {
     if (is_null($driver)) {
         $driver = Config::get('database.connections.' . Config::get('database.default') . '.driver');
     }
     if (!isset(static::$drivers[$driver])) {
         static::$drivers[$driver] = static::factory($driver);
     }
     return static::$drivers[$driver];
 }

作者:laravelboo    项目:framework   
public static function db($name = 'default')
 {
     if (!isset(static::$databases[$name])) {
         if (is_null($config = Config::get("database.redis.{$name}"))) {
             throw new \Exception("Redis database [{$name}] is not defined.");
         }
         extract($config);
         static::$databases[$name] = new static($host, $port, $database);
     }
     return static::$databases[$name];
 }

作者:cloudmani    项目:php-warches   
/**
  * Get the user from the database table.
  *
  * @param  array  $arguments
  * @return mixed
  */
 protected function get_user($arguments)
 {
     $table = Config::get('auth.table');
     return DB::table($table)->where(function ($query) use($arguments) {
         $username = Config::get('auth.username');
         $query->where($username, '=', $arguments['username']);
         foreach (array_except($arguments, array('username', 'password', 'remember')) as $column => $val) {
             $query->where($column, '=', $val);
         }
     })->first();
 }

作者:SerdarSanr    项目:laravel-wee   
/**
  * Get a language specific line
  *
  * @param string $key   The Key to search
  * @param array  $subst array The values to substitute
  * @param string $lang  string The language
  *
  * @return string
  */
 public function t($key, $subst = null, $lang = null)
 {
     if (is_null($lang)) {
         $lang = Config::get('application.language', 'en_US');
     }
     if (is_null($subst)) {
         return Lang::line($key, array())->get($lang);
     } else {
         parse_str($subst, $repl);
         return Lang::line($key, $repl)->get($lang);
     }
 }

作者:farhan4648gu    项目:developer-sid   
public static function listData()
 {
     $allGroup = Group::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('group_name' => Str::upper(Lang::line('admin.datagroup')->get())));
     $datagrid->setAction(Lang::line('global.manage')->get(), 'datacontent', false);
     $datagrid->setAction(Lang::line('global.edit')->get(), 'editGroup', true, array('dmid'));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteGroup', true, array('dmid', 'group_name'));
     $datagrid->setTable('dataGroup', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allGroup, 'dmid');
     return $datagrid->render();
 }

作者:perryha    项目:Laravel-   
/**
  * Sweep the expired sessions from storage.
  *
  * @param  array  $arguments
  * @return void
  */
 public function sweep($arguments = array())
 {
     $driver = Session::factory(Config::get('session.driver'));
     // If the driver implements the "Sweeper" interface, we know that it
     // can sweep expired sessions from storage. Not all drivers need be
     // sweepers since they do their own.
     if ($driver instanceof Sweeper) {
         $lifetime = Config::get('session.lifetime');
         $driver->sweep(time() - $lifetime * 60);
     }
     echo "The session table has been swept!";
 }

作者:farhan4648gu    项目:developer-sid   
public static function listRole()
 {
     $rolelist = Role::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('role' => Str::upper(Lang::line('admin.rolename')->get()), 'roledesc' => Str::upper(Lang::line('admin.roledesc')->get())));
     $datagrid->setAction(Lang::line('global.edit')->get(), 'editRoleModal', true, array('roleid'));
     //false,array('id'=>'roleid','data-toggle'=>'modal'));
     $datagrid->setAction(Lang::line('global.delete')->get(), 'deleteRole', true, array('roleid'));
     $datagrid->setContainer('list01', 'span12');
     $datagrid->setTable('users', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($rolelist, 'roleid');
     return $datagrid->render();
 }

作者:SerdarSanr    项目:Mai   
public function __construct()
 {
     $this->server = Config::get('mail::smtp.server');
     $this->port = Config::get('mail::smtp.port');
     $this->encryption = Config::get('mail::smtp.encryption');
     $this->username = Config::get('mail::smtp.username');
     $this->password = Config::get('mail::smtp.password');
     $this->realname = Config::get('mail::smtp.realname');
     $this->transport = Swift_SmtpTransport::newInstance($this->server, $this->port, $this->encryption)->setUsername($this->username)->setPassword($this->password);
     $this->mailer = Swift_Mailer::newInstance($this->transport);
     $this->message = Swift_Message::newInstance();
     // Set default sender.
     $this->message->setFrom(array($this->username => $this->realname));
 }

作者:bampe    项目:laravel.co   
/**
  * Get a database connection.
  *
  * If no database name is specified, the default connection will be returned.
  *
  * <code>
  *		// Get the default database connection for the application
  *		$connection = DB::connection();
  *
  *		// Get a specific connection by passing the connection name
  *		$connection = DB::connection('mysql');
  * </code>
  *
  * @param  string      $connection
  * @return Database\Connection
  */
 public static function connection($connection = null)
 {
     if (is_null($connection)) {
         $connection = Config::get('database.default');
     }
     if (!isset(static::$connections[$connection])) {
         $config = Config::get("database.connections.{$connection}");
         if (is_null($config)) {
             throw new \Exception("Database connection is not defined for [{$connection}].");
         }
         static::$connections[$connection] = new Connection(static::connect($config), $config);
     }
     return static::$connections[$connection];
 }

作者:nshont    项目:laravel-blo   
/**
  * Open a HTML form.
  *
  * If PUT or DELETE is specified as the form method, a hidden input field will be generated
  * containing the request method. PUT and DELETE are not supported by HTML forms, so the
  * hidden field will allow us to "spoof" PUT and DELETE requests.
  *
  * Unless specified, the "accept-charset" attribute will be set to the application encoding.
  *
  * <code>
  *		// Open a "POST" form to the current request URI
  *		echo Form::open();
  *
  *		// Open a "POST" form to a given URI
  *		echo Form::open('user/profile');
  *
  *		// Open a "PUT" form to a given URI
  *		echo Form::open('user/profile', 'put');
  *
  *		// Open a form that has HTML attributes
  *		echo Form::open('user/profile', 'post', array('class' => 'profile'));
  * </code>
  *
  * @param  string   $action
  * @param  string   $method
  * @param  array    $attributes
  * @param  bool     $https
  * @return string
  */
 public static function open($action = null, $method = 'POST', $attributes = array(), $https = false)
 {
     $method = strtoupper($method);
     $attributes['method'] = static::method($method);
     $attributes['action'] = static::action($action, $https);
     if (!array_key_exists('accept-charset', $attributes)) {
         $attributes['accept-charset'] = Config::get('application.encoding');
     }
     $append = '';
     if ($method == 'PUT' or $method == 'DELETE') {
         $append = static::hidden(Request::spoofer, $method);
     }
     return '<form' . HTML::attributes($attributes) . '>' . $append . PHP_EOL;
 }

作者:farhan4648gu    项目:developer-sid   
public static function listFlow()
 {
     $allFlow = Flow::paginate(Config::get('system.pagination'));
     $datagrid = new Datagrid();
     $datagrid->setFields(array('flowname' => 'Flow'));
     $datagrid->setFields(array('created_at' => 'Created'));
     $datagrid->setFields(array('updated_at' => 'Updated'));
     $datagrid->setAction('edit', 'editFlowModal', true, array('flowid'));
     // $datagrid->setAction('delete','deleteRole',true,array('userid'));
     $datagrid->setAction('step', 'step');
     $datagrid->setTable('flows', 'table table-bordered table-hover table-striped table-condensed');
     $datagrid->build($allFlow, 'flowid');
     return $datagrid->render();
 }


问题


面经


文章

微信
公众号

扫码关注公众号