|
@@ -108,93 +108,122 @@ Autoloader::namespaces(array(
|
|
|
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
-| Set The CLI Options Array
|
|
|
+| Magic Quotes Strip Slashes
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
-| If the current request is from the Artisan command-line interface, we
|
|
|
-| will parse the command line arguments and options and set them the
|
|
|
-| array of options in the $_SERVER global array for convenience.
|
|
|
+| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still
|
|
|
+| be enabled on the server. To account for this, we will strip slashes
|
|
|
+| on all input arrays if magic quotes are enabled for the server.
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
-if (defined('STDIN'))
|
|
|
+if (magic_quotes())
|
|
|
{
|
|
|
- $console = CLI\Command::options($_SERVER['argv']);
|
|
|
+ $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
|
|
|
|
|
|
- list($arguments, $options) = $console;
|
|
|
+ foreach ($magics as &$magic)
|
|
|
+ {
|
|
|
+ $magic = array_strip_slashes($magic);
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
- $options = array_change_key_case($options, CASE_UPPER);
|
|
|
+/*
|
|
|
+|--------------------------------------------------------------------------
|
|
|
+| Create The HttpFoundation Request
|
|
|
+|--------------------------------------------------------------------------
|
|
|
+|
|
|
|
+| Laravel uses the HttpFoundation Symfony component to handle the request
|
|
|
+| and response functionality for the framework. This allows us to not
|
|
|
+| worry about that boilerplate code and focus on what matters.
|
|
|
+|
|
|
|
+*/
|
|
|
|
|
|
- $_SERVER['CLI'] = $options;
|
|
|
-}
|
|
|
+use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
|
|
+
|
|
|
+Request::$foundation = RequestFoundation::createFromGlobals();
|
|
|
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
-| Set The CLI Laravel Environment
|
|
|
+| Determine The Application Environment
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
-| Next we'll set the LARAVEL_ENV variable if the current request is from
|
|
|
-| the Artisan command-line interface. Since the environment is often
|
|
|
-| specified within an Apache .htaccess file, we need to set it here
|
|
|
-| when the request is not coming through Apache.
|
|
|
+| Next we're ready to determine the application environment. This may be
|
|
|
+| set either via the command line options, or, if the request is from
|
|
|
+| the web, via the mapping of URIs to environments that lives in
|
|
|
+| the "paths.php" file for the application and is parsed.
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
-if (isset($_SERVER['CLI']['ENV']))
|
|
|
+if (Request::cli())
|
|
|
+{
|
|
|
+ foreach (Request::foundation()->server->get('argv') as $argument)
|
|
|
+ {
|
|
|
+ if (starts_with($argument, '--env='))
|
|
|
+ {
|
|
|
+ $environment = substr($argument, 6);
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+else
|
|
|
{
|
|
|
- $_SERVER['LARAVEL_ENV'] = $_SERVER['CLI']['ENV'];
|
|
|
+ $environment = Request::detect_env($environments);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
-| Register The Laravel Bundles
|
|
|
+| Set The Application Environment
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
-| Finally we will register all of the bundles that have been defined for
|
|
|
-| the application. None of them will be started, yet but will be setup
|
|
|
-| so that they may be started by the develop at any time.
|
|
|
+| Once we have determined the application environment, we will set it on
|
|
|
+| the global server array of the HttpFoundation request. This makes it
|
|
|
+| available throughout the application, thought it is mainly only
|
|
|
+| used to determine which configuration files to merge in.
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
-$bundles = require path('app').'bundles'.EXT;
|
|
|
-
|
|
|
-foreach ($bundles as $bundle => $config)
|
|
|
+if ( ! is_null($environment))
|
|
|
{
|
|
|
- Bundle::register($bundle, $config);
|
|
|
+ Request::foundation()->server->set('LARAVEL_ENV', $environment);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
-| Magic Quotes Strip Slashes
|
|
|
+| Set The CLI Options Array
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
-| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still
|
|
|
-| be enabled on the server. To account for this, we will strip slashes
|
|
|
-| on all input arrays if magic quotes are enabled for the server.
|
|
|
+| If the current request is from the Artisan command-line interface, we
|
|
|
+| will parse the command line arguments and options and set them the
|
|
|
+| array of options in the $_SERVER global array for convenience.
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
-if (magic_quotes())
|
|
|
+if (defined('STDIN'))
|
|
|
{
|
|
|
- $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
|
|
|
+ $console = CLI\Command::options($_SERVER['argv']);
|
|
|
|
|
|
- foreach ($magics as &$magic)
|
|
|
- {
|
|
|
- $magic = array_strip_slashes($magic);
|
|
|
- }
|
|
|
+ list($arguments, $options) = $console;
|
|
|
+
|
|
|
+ $options = array_change_key_case($options, CASE_UPPER);
|
|
|
+
|
|
|
+ $_SERVER['CLI'] = $options;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
-| Create The HttpFoundation Request
|
|
|
+| Register The Laravel Bundles
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
|
|
-| Laravel uses the HttpFoundation Symfony component to handle the request
|
|
|
-| and response functionality for the framework. This allows us to not
|
|
|
-| worry about that boilerplate code and focus on what matters.
|
|
|
+| Finally we will register all of the bundles that have been defined for
|
|
|
+| the application. None of them will be started, yet but will be setup
|
|
|
+| so that they may be started by the develop at any time.
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
-use Symfony\Component\HttpFoundation\LaravelRequest as RequestFoundation;
|
|
|
+$bundles = require path('app').'bundles'.EXT;
|
|
|
|
|
|
-Request::$foundation = RequestFoundation::createFromGlobals();
|
|
|
+foreach ($bundles as $bundle => $config)
|
|
|
+{
|
|
|
+ Bundle::register($bundle, $config);
|
|
|
+}
|