refactoring and adding more dependency injection through ioc container.

This commit is contained in:
Taylor Otwell
2011-08-24 22:51:32 -05:00
parent 99adf09ac7
commit 6a8aafc259
46 changed files with 1039 additions and 1276 deletions

View File

@@ -1,48 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| Here, you can specify any class aliases that you would like registered
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
| Aliases make it more convenient to use namespaced classes. Instead of
| referring to the class using its full namespace, you may simply use
| the alias defined here.
|
| We have already aliased common Laravel classes to make your life easier.
|
*/
'Asset' => 'Laravel\\Asset',
'Auth' => 'Laravel\\Auth',
'Benchmark' => 'Laravel\\Benchmark',
'Cache' => 'Laravel\\Cache',
'Config' => 'Laravel\\Config',
'Cookie' => 'Laravel\\Cookie',
'Crypter' => 'Laravel\\Crypter',
'DB' => 'Laravel\\DB',
'Eloquent' => 'Laravel\\DB\\Eloquent\\Model',
'File' => 'Laravel\\File',
'Form' => 'Laravel\\Form',
'Hasher' => 'Laravel\\Hasher',
'HTML' => 'Laravel\\HTML',
'Inflector' => 'Laravel\\Inflector',
'Input' => 'Laravel\\Input',
'Lang' => 'Laravel\\Lang',
'Loader' => 'Laravel\\Loader',
'Package' => 'Laravel\\Package',
'URL' => 'Laravel\\URL',
'Redirect' => 'Laravel\\Redirect',
'Request' => 'Laravel\\Request',
'Response' => 'Laravel\\Response',
'Session' => 'Laravel\\Session',
'Str' => 'Laravel\\Str',
'Validator' => 'Laravel\\Validator',
'View' => 'Laravel\\View',
);

View File

@@ -1,98 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| The URL used to access your application. No trailing slash.
|
*/
'url' => 'http://localhost',
/*
|--------------------------------------------------------------------------
| Application Index
|--------------------------------------------------------------------------
|
| If you are including the "index.php" in your URLs, you can ignore this.
|
| However, if you are using mod_rewrite or something similar to get
| cleaner URLs, set this option to an empty string.
|
*/
'index' => 'index.php',
/*
|--------------------------------------------------------------------------
| Application Language
|--------------------------------------------------------------------------
|
| The default language of your application. This language will be used by
| Lang library as the default language when doing string localization.
|
*/
'language' => 'en',
/*
|--------------------------------------------------------------------------
| Application Character Encoding
|--------------------------------------------------------------------------
|
| The default character encoding used by your application. This is the
| character encoding that will be used by the Str, Text, and Form classes.
|
*/
'encoding' => 'UTF-8',
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| The default timezone of your application. This timezone will be used when
| Laravel needs a date, such as when writing to a log file.
|
*/
'timezone' => 'UTC',
/*
|--------------------------------------------------------------------------
| Auto-Loaded Packages
|--------------------------------------------------------------------------
|
| The packages that should be auto-loaded each time Laravel handles
| a request. These should generally be packages that you use on almost
| every request to your application.
|
| Each package specified here will be bootstrapped and can be conveniently
| used by your application's routes, models, and libraries.
|
| Note: The package names in this array should correspond to a package
| directory in application/packages.
|
*/
'packages' => array(),
/*
|--------------------------------------------------------------------------
| Application Key
|--------------------------------------------------------------------------
|
| Your application key should be a 32 character string that is totally
| random and secret. This key is used by the encryption class to generate
| secure, encrypted strings.
|
*/
'key' => '',
);

View File

@@ -1,44 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Retrieve Users By ID
|--------------------------------------------------------------------------
|
| This method is called by the Auth::user() method when attempting to
| retrieve a user by their user ID, such as when retrieving a user by the
| user ID stored in the session.
|
| You are free to change this method for your application however you wish.
|
*/
'by_id' => function($id)
{
return User::find($id);
},
/*
|--------------------------------------------------------------------------
| Retrieve Users By Username
|--------------------------------------------------------------------------
|
| This method is called by the Auth::check() method when attempting to
| retrieve a user by their username, such as when checking credentials
| received from a login form.
|
| You are free to change this method for your application however you wish.
|
| Note: This method must return an object that has "id" and "password"
| properties. The type of object returned does not matter.
|
*/
'by_username' => function($username)
{
return User::where_email($username)->first();
},
);

View File

@@ -1,52 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Cache Driver
|--------------------------------------------------------------------------
|
| The name of the default cache driver for your application.
|
| Caching can be used to increase the performance of your application
| by storing commonly accessed data in memory or in a file.
|
| Supported Drivers: 'file', 'memcached', 'apc'.
|
*/
'driver' => 'file',
/*
|--------------------------------------------------------------------------
| Cache Key
|--------------------------------------------------------------------------
|
| This key will be prepended to item keys stored using Memcached and APC to
| prevent collisions with other applications on the server.
|
*/
'key' => 'laravel',
/*
|--------------------------------------------------------------------------
| Memcached Servers
|--------------------------------------------------------------------------
|
| The Memcached servers used by your application.
|
| Memcached is a free and open source, high-performance, distributed memory
| object caching system, generic in nature, but intended for use in speeding
| up dynamic web applications by alleviating database load.
|
| For more information about Memcached, check out: http://memcached.org
|
*/
'servers' => array(
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
),
);

View File

@@ -1,73 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Default Database Connection
|--------------------------------------------------------------------------
|
| The name of your default database connection.
|
| This connection will be the default for all database operations unless a
| different connection is specified when performing the operation.
|
*/
'default' => 'sqlite',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| All of the database connections used by your application.
|
| Supported Drivers: 'mysql', 'pgsql', 'sqlite'.
|
| Note: When using the SQLite driver, the path and "sqlite" extention will
| be added automatically. You only need to specify the database name.
|
| Using a driver that isn't supported? You can still establish a PDO
| connection. Simply specify a driver and DSN option:
|
| 'odbc' => array(
| 'driver' => 'odbc',
| 'dsn' => 'your-dsn',
| 'username' => 'username',
| 'password' => 'password',
| )
|
| Note: When using an unsupported driver, Eloquent and the fluent query
| builder may not work as expected.
|
*/
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => 'application',
),
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => 'password',
'charset' => 'utf8',
),
),
);

View File

@@ -0,0 +1,88 @@
<?php namespace Laravel;
return array(
/*
|--------------------------------------------------------------------------
| Laravel File Cache Driver
|--------------------------------------------------------------------------
*/
'laravel.cache.file' => array('resolver' => function($container)
{
return new Cache\File($container->resolve('laravel.cache.file_engine'));
}),
/*
|--------------------------------------------------------------------------
| Laravel File Cache Driver Engine
|--------------------------------------------------------------------------
*/
'laravel.cache.file_engine' => array('resolver' => function($container)
{
return new Cache\File_Engine;
}),
/*
|--------------------------------------------------------------------------
| Laravel APC Cache Driver
|--------------------------------------------------------------------------
*/
'laravel.cache.apc' => array('resolver' => function($container)
{
return new Cache\APC($container->resolve('laravel.cache.apc_engine'));
}),
/*
|--------------------------------------------------------------------------
| Laravel APC Cache Driver Engine
|--------------------------------------------------------------------------
*/
'laravel.cache.apc_engine' => array('resolver' => function($container)
{
return new Cache\APC_Engine;
}),
/*
|--------------------------------------------------------------------------
| Laravel Memcached Cache Driver
|--------------------------------------------------------------------------
*/
'laravel.cache.memcached' => array('resolver' => function($container)
{
return new Cache\Memcached($container->resolve('laravel.memcache'));
}),
/*
|--------------------------------------------------------------------------
| Memcache Connection
|--------------------------------------------------------------------------
*/
'laravel.memcache' => array('singleton' => true, 'resolver' => function($container)
{
if ( ! class_exists('Memcache'))
{
throw new \Exception('Attempting to use Memcached, but the Memcache PHP extension is not installed on this server.');
}
$memcache = new \Memcache;
foreach (Config::get('cache.servers') as $server)
{
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
}
if ($memcache->getVersion() === false)
{
throw new \Exception('Memcached is configured. However, no connections could be made. Please verify your memcached configuration.');
}
return $memcache;
}),
);

View File

@@ -1,58 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Error Detail
|--------------------------------------------------------------------------
|
| Detailed error messages contain information about the file in which
| an error occurs, a stack trace, and a snapshot of the source code
| in which the error occured.
|
| If your application is in production, consider turning off error details
| for enhanced security and user experience.
|
*/
'detail' => true,
/*
|--------------------------------------------------------------------------
| Error Logging
|--------------------------------------------------------------------------
|
| Error Logging will use the "logger" function defined below to log error
| messages, which gives you complete freedom to determine how error
| messages are logged. Enjoy the flexibility.
|
*/
'log' => false,
/*
|--------------------------------------------------------------------------
| Error Logger
|--------------------------------------------------------------------------
|
| Because of the various ways of managing error logging, you get complete
| flexibility to manage error logging as you see fit.
|
| This function will be called when an error occurs in your application.
| You can log the error however you like.
|
| The error "severity" passed to the method is a human-readable severity
| level such as "Parsing Error" or "Fatal Error".
|
| A simple logging system has been setup for you. By default, all errors
| will be logged to the storage/log.txt file.
|
*/
'logger' => function($severity, $message, $trace)
{
File::append(STORAGE_PATH.'log.txt', date('Y-m-d H:i:s').' '.$severity.' - '.$message.PHP_EOL);
},
);

View File

@@ -1,104 +0,0 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Session Driver
|--------------------------------------------------------------------------
|
| The name of the session driver for your application.
|
| Since HTTP is stateless, sessions are used to maintain "state" across
| multiple requests from the same user of your application.
|
| Supported Drivers: 'cookie', 'file', 'db', 'memcached', 'apc'.
|
*/
'driver' => '',
/*
|--------------------------------------------------------------------------
| Session Database
|--------------------------------------------------------------------------
|
| The database table on which the session should be stored.
|
| This option is only relevant when using the "db" session driver.
|
*/
'table' => 'sessions',
/*
|--------------------------------------------------------------------------
| Session Lifetime
|--------------------------------------------------------------------------
|
| The number of minutes a session can be idle before expiring.
|
*/
'lifetime' => 60,
/*
|--------------------------------------------------------------------------
| Session Expiration On Close
|--------------------------------------------------------------------------
|
| Determines if the session should expire when the user's web browser closes.
|
*/
'expire_on_close' => false,
/*
|--------------------------------------------------------------------------
| Session Cookie Path
|--------------------------------------------------------------------------
|
| The path for which the session cookie is available.
|
*/
'path' => '/',
/*
|--------------------------------------------------------------------------
| Session Cookie Domain
|--------------------------------------------------------------------------
|
| The domain for which the session cookie is available.
|
*/
'domain' => null,
/*
|--------------------------------------------------------------------------
| Session Cookie HTTPS
|--------------------------------------------------------------------------
|
| Determines if the session cookie should only be transported over HTTPS.
|
*/
'https' => false,
/*
|--------------------------------------------------------------------------
| HTTP Only Session Cookie
|--------------------------------------------------------------------------
|
| Determines if the session cookie should only be accessible over HTTP.
|
| Note: The intention of the "HTTP Only" option is to keep cookies from
| being accessed by client-side scripting languages. However, this
| setting should not be viewed as providing total XSS protection.
|
*/
'http_only' => false,
);