Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
ab6e3645
Commit
ab6e3645
authored
Apr 13, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added simpler and easier environment handling.
parent
34cb9a00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
106 additions
and
44 deletions
+106
-44
core.php
laravel/core.php
+70
-41
request.php
laravel/request.php
+25
-0
url.php
laravel/url.php
+1
-3
LaravelRequest.php
...endor/Symfony/Component/HttpFoundation/LaravelRequest.php
+10
-0
No files found.
laravel/core.php
View file @
ab6e3645
...
...
@@ -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
();
\ No newline at end of file
foreach
(
$bundles
as
$bundle
=>
$config
)
{
Bundle
::
register
(
$bundle
,
$config
);
}
\ No newline at end of file
laravel/request.php
View file @
ab6e3645
...
...
@@ -208,6 +208,31 @@ class Request {
return
static
::
env
()
===
$env
;
}
/**
* Detect the current environment from an environment configuration.
*
* @param array $environments
* @return string|null
*/
public
static
function
detect_env
(
array
$environments
)
{
$root
=
static
::
foundation
()
->
getRootUrl
();
foreach
(
$environments
as
$environment
=>
$patterns
)
{
// Essentially we just want to loop through each environment pattern
// and determine if the current URI matches the pattern and if so
// we'll simply return the environment for that URI pattern.
foreach
(
$patterns
as
$pattern
)
{
if
(
Str
::
is
(
$pattern
,
$root
))
{
return
$environment
;
}
}
}
}
/**
* Get the main route handling the request.
*
...
...
laravel/url.php
View file @
ab6e3645
...
...
@@ -70,9 +70,7 @@ class URL {
}
else
{
$f
=
Request
::
foundation
();
$base
=
$f
->
getScheme
()
.
'://'
.
$f
->
getHttpHost
()
.
$f
->
getBasePath
();
$base
=
Request
::
foundation
()
->
getRootUrl
();
}
return
static
::
$base
=
$base
;
...
...
laravel/vendor/Symfony/Component/HttpFoundation/LaravelRequest.php
View file @
ab6e3645
...
...
@@ -24,4 +24,14 @@ class LaravelRequest extends Request {
return
$request
;
}
/**
* Get the root URL of the application.
*
* @return string
*/
public
function
getRootUrl
()
{
return
$this
->
getScheme
()
.
'://'
.
$this
->
getHttpHost
()
.
$this
->
getBasePath
();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment