diff --git a/laravel/arr.php b/laravel/arr.php
index 35c7afc0..ca88753c 100644
--- a/laravel/arr.php
+++ b/laravel/arr.php
@@ -1,15 +1,21 @@
+ * // Get the value of $array['user']['name']
+ * $value = Arr::get($array, 'user.name');
+ *
+ * // Get a value from the array, but return a default if it doesn't exist
+ * $value = Arr::get($array, 'user.name', 'Taylor');
+ *
*
* @param array $array
* @param string $key
@@ -24,7 +30,7 @@ public static function get($array, $key, $default = null)
{
if ( ! is_array($array) or ! array_key_exists($segment, $array))
{
- return ($default instanceof Closure) ? call_user_func($default) : $default;
+ return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
$array = $array[$segment];
@@ -36,9 +42,16 @@ public static function get($array, $key, $default = null)
/**
* Set an array item to a given value.
*
- * This method is primarly helpful for setting the value in an array with
- * a variable depth, such as configuration arrays. Like the Arr::get
- * method, JavaScript "dot" syntax is supported.
+ * This method supports accessing arrays through JavaScript "dot" style syntax
+ * for conveniently digging deep into nested arrays.
+ *
+ *
+ * // Set the $array['user']['name'] value in the array
+ * Arr::set($array, 'user.name', 'Taylor');
+ *
+ * // Set the $array['db']['driver']['name'] value in the array
+ * Arr::set($array, 'db.driver.name', 'SQLite');
+ *
*
* @param array $array
* @param string $key
@@ -69,6 +82,20 @@ public static function set(&$array, $key, $value)
/**
* Return the first element in an array which passes a given truth test.
*
+ * The truth test is passed as a closure, and simply returns true or false.
+ * The array key and value will be passed to the closure on each iteration.
+ *
+ * Like the "get" method, a default value may be specified, and will be
+ * returned if no matching array elements are found by the method.
+ *
+ *
+ * // Get the first string from an array with a length of 3
+ * $value = Arr::first($array, function($k, $v) {return strlen($v) == 3;});
+ *
+ * // Return a default value if no matching array elements are found
+ * $value = Arr::first($array, function($k, $v) {return;}, 'Default');
+ *
+ *
* @param array $array
* @param Closure $callback
* @return mixed
@@ -80,7 +107,7 @@ public static function first($array, $callback, $default = null)
if (call_user_func($callback, $key, $value)) return $value;
}
- return ($default instanceof Closure) ? call_user_func($default) : $default;
+ return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
}
\ No newline at end of file
diff --git a/laravel/asset.php b/laravel/asset.php
index 0a4ee68e..1bb2cc98 100644
--- a/laravel/asset.php
+++ b/laravel/asset.php
@@ -35,10 +35,10 @@ public function __construct(HTML $html)
* expressive code and a clean API.
*
*
- * // Get the default asset container
+ * // Get an instance of the default asset container
* $container = Asset::container();
*
- * // Get the "footer" asset container
+ * // Get an instance of the "footer" container
* $container = Asset::container('footer');
*
*
@@ -58,12 +58,9 @@ public function container($container = 'default')
/**
* Magic Method for calling methods on the default Asset container.
*
- * This provides a convenient API, allowing the developer to skip the
- * "container" method when using the default container.
- *
*
- * // Add a JavaScript file to the default container
- * Asset::script('jquery', 'js/jquery.js');
+ * // Call the "add" method on the default asset container
+ * Asset::add('jquery', 'js/jquery.js');
*
* // Get all of the styles from the default container
* echo Asset::styles();
@@ -125,10 +122,13 @@ public function __construct($name, HTML $html)
*
*
* // Add an asset to the container
- * Asset::add('jquery', 'js/jquery.js');
+ * Asset::container()->add('style', 'style.css');
*
- * // Add an asset that has dependencies
- * Asset::add('jquery', 'js/jquery.js', array('jquery-ui'));
+ * // Add an asset to the container with attributes
+ * Asset::container()->add('style', 'style.css', array(), array('media' => 'print'));
+ *
+ * // Add an asset to the container with dependencies
+ * Asset::container()->add('jquery', 'jquery.js', array('jquery-ui'));
*
*
* @param string $name
@@ -147,6 +147,17 @@ public function add($name, $source, $dependencies = array(), $attributes = array
/**
* Add a CSS file to the registered assets.
*
+ *
+ * // Add a CSS file to the registered assets
+ * Asset::container()->style('common', 'common.css');
+ *
+ * // Add a CSS file with dependencies to the registered assets
+ * Asset::container()->style('common', 'common.css', array('reset'));
+ *
+ * // Add a CSS file with attributes to the registered assets
+ * Asset::container()->style('common', 'common.css', array(), array('media' => 'print'));
+ *
+ *
* @param string $name
* @param string $source
* @param array $dependencies
@@ -168,6 +179,17 @@ public function style($name, $source, $dependencies = array(), $attributes = arr
/**
* Add a JavaScript file to the registered assets.
*
+ *
+ * // Add a CSS file to the registered assets
+ * Asset::container()->script('jquery', 'jquery.js');
+ *
+ * // Add a CSS file with dependencies to the registered assets
+ * Asset::container()->script('jquery', 'jquery.js', array('jquery-ui'));
+ *
+ * // Add a CSS file with attributes to the registered assets
+ * Asset::container()->script('loader', 'loader.js', array(), array('defer'));
+ *
+ *
* @param string $name
* @param string $source
* @param array $dependencies
diff --git a/laravel/bootstrap.php b/laravel/bootstrap.php
index 5ad080f8..cb7df0d7 100644
--- a/laravel/bootstrap.php
+++ b/laravel/bootstrap.php
@@ -49,7 +49,9 @@
$dependencies = array_merge($dependencies, require $path);
}
-if (isset($_SERVER['LARAVEL_ENV']) and file_exists($path = CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/container'.EXT))
+$env = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'] : null;
+
+if ( ! is_null($env) and file_exists($path = CONFIG_PATH.$env.'/container'.EXT))
{
$dependencies = array_merge($dependencies, require $path);
}
@@ -61,4 +63,9 @@
// --------------------------------------------------------------
// Register the auto-loader on the auto-loader stack.
// --------------------------------------------------------------
-spl_autoload_register(array($container->resolve('laravel.loader'), 'load'));
\ No newline at end of file
+spl_autoload_register(array($container->resolve('laravel.loader'), 'load'));
+
+// --------------------------------------------------------------
+// Set the application environment configuration option.
+// --------------------------------------------------------------
+$container->resolve('laravel.config')->set('application.env', $env);
\ No newline at end of file
diff --git a/laravel/config.php b/laravel/config.php
index 2cd2a4b6..00ce2873 100644
--- a/laravel/config.php
+++ b/laravel/config.php
@@ -5,33 +5,32 @@ class Config {
/**
* All of the loaded configuration items.
*
- * The configuration arrays are keyed by their owning file name.
- *
* @var array
*/
- protected $items = array();
-
- /**
- * The paths to the configuration files.
- *
- * @var array
- */
- protected $paths = array();
+ protected $config = array();
/**
* Create a new configuration manager instance.
*
- * @param array $paths
+ * @param array $config
* @return void
*/
- public function __construct($paths)
+ public function __construct($config)
{
- $this->paths = $paths;
+ $this->config = $config;
}
/**
* Determine if a configuration item or file exists.
*
+ *
+ * // Determine if the "options" configuration file exists
+ * $options = Config::has('options');
+ *
+ * // Determine if a specific configuration item exists
+ * $timezone = Config::has('application.timezone');
+ *
+ *
* @param string $key
* @return bool
*/
@@ -43,18 +42,23 @@ public function has($key)
/**
* Get a configuration item.
*
- * If the name of a configuration file is passed without specifying an item, the
- * entire configuration array will be returned.
+ * Configuration items are stored in the application/config directory, and provide
+ * general configuration options for a wide range of Laravel facilities.
+ *
+ * The arrays may be accessed using JavaScript style "dot" notation to drill deep
+ * intot he configuration files. For example, asking for "database.connectors.sqlite"
+ * would return the connector closure for SQLite stored in the database configuration
+ * file. If no specific item is specfied, the entire configuration array is returned.
+ *
+ * Like most Laravel "get" functions, a default value may be provided, and it will
+ * be returned if the requested file or item doesn't exist.
*
*
- * // Get the "timezone" option from the "application" file
+ * // Get the "timezone" option from the application config file
* $timezone = Config::get('application.timezone');
*
- * // Get the SQLite connection configuration from the "database" file
- * $sqlite = Config::get('database.connections.sqlite');
- *
- * // Get a configuration option and return "Fred" if it doesn't exist
- * $option = Config::get('config.option', 'Fred');
+ * // Get an option, but return a default value if it doesn't exist
+ * $value = Config::get('some.option', 'Default');
*
*
* @param string $key
@@ -63,30 +67,25 @@ public function has($key)
*/
public function get($key, $default = null)
{
- list($file, $key) = $this->parse($key);
-
- if ( ! $this->load($file))
- {
- return ($default instanceof \Closure) ? call_user_func($default) : $default;
- }
-
- if (is_null($key)) return $this->items[$file];
-
- return Arr::get($this->items[$file], $key, $default);
+ return Arr::get($this->items, $key, $default);
}
/**
* Set a configuration item.
*
- * If a specific configuration item is not specified, the entire configuration
- * array will be replaced with the given value.
+ * Configuration items are stored in the application/config directory, and provide
+ * general configuration options for a wide range of Laravel facilities.
+ *
+ * Like the "get" method, this method uses JavaScript style "dot" notation to access
+ * and manipulate the arrays in the configuration files. Also, like the "get" method,
+ * if no specific item is specified, the entire configuration array will be set.
*
*
- * // Set the "timezone" option in the "application" file
+ * // Set the "timezone" option in the "application" array
* Config::set('application.timezone', 'America/Chicago');
*
- * // Set the entire "session" array to an empty array
- * Config::set('session', array());
+ * // Set the entire "session" configuration array
+ * Config::set('session', $array);
*
*
* @param string $key
@@ -95,52 +94,7 @@ public function get($key, $default = null)
*/
public function set($key, $value)
{
- list($file, $key) = $this->parse($key);
-
- $this->load($file);
-
- (is_null($key)) ? Arr::set($this->items, $file, $value) : Arr::set($this->items[$file], $key, $value);
- }
-
- /**
- * Parse a configuration key and return its file and key segments.
- *
- * Configuration keys follow a {file}.{key} convention.
- *
- * @param string $key
- * @return array
- */
- protected function parse($key)
- {
- $segments = explode('.', $key);
-
- $key = (count($segments) > 1) ? implode('.', array_slice($segments, 1)) : null;
-
- return array($segments[0], $key);
- }
-
- /**
- * Load all of the configuration items from a module configuration file.
- *
- * If the configuration file has already been loaded, it will not be loaded again.
- *
- * @param string $file
- * @return bool
- */
- protected function load($file)
- {
- if (isset($this->items[$file])) return true;
-
- $config = array();
-
- foreach ($this->paths as $directory)
- {
- $config = (file_exists($path = $directory.$file.EXT)) ? array_merge($config, require $path) : $config;
- }
-
- if (count($config) > 0) $this->items[$file] = $config;
-
- return isset($this->items[$file]);
+ Arr::set($this->items, $key, $value);
}
}
\ No newline at end of file
diff --git a/laravel/config/container.php b/laravel/config/container.php
index ef347996..b38024f9 100644
--- a/laravel/config/container.php
+++ b/laravel/config/container.php
@@ -108,6 +108,8 @@
($request->spoofed()) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input);
}
+ unset($input['_REQUEST_METHOD_']);
+
return new Input($container->resolve('laravel.file'), $container->resolve('laravel.cookie'), $input, $_FILES);
}),
diff --git a/laravel/database/manager.php b/laravel/database/manager.php
index 33d0022c..0c29e294 100644
--- a/laravel/database/manager.php
+++ b/laravel/database/manager.php
@@ -21,10 +21,9 @@ public function __construct($config)
}
/**
- * Get a database connection.
+ * Get a database connection.
*
- * If no database name is specified, the default connection will be returned as
- * defined in the database configuration file.
+ * If no database name is specified, the default connection will be returned.
*
* Note: Database connections are managed as singletons.
*
@@ -46,7 +45,9 @@ public function connection($connection = null)
// This provides the developer the maximum amount of freedom in establishing their
// database connections, and allows the framework to remain agonstic to ugly database
// specific PDO connection details. Less code. Less bugs.
- $this->connections[$connection] = new Connection(call_user_func($this->config['connectors'][$connection], $this->config));
+ $pdo = call_user_func($this->config['connectors'][$connection]);
+
+ $this->connections[$connection] = new Connection($pdo, $this->config));
}
return $this->connections[$connection];
diff --git a/laravel/form.php b/laravel/form.php
index 73d607b7..1082b7f5 100644
--- a/laravel/form.php
+++ b/laravel/form.php
@@ -81,7 +81,7 @@ public function open($action = null, $method = 'POST', $attributes = array(), $h
$attributes['accept-charset'] = $this->html->encoding;
}
- $append = ($method == 'PUT' or $method == 'DELETE') ? $this->hidden('REQUEST_METHOD', $method) : '';
+ $append = ($method == 'PUT' or $method == 'DELETE') ? $this->hidden('_REQUEST_METHOD', $method) : '';
return '