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
69ec79c9
Commit
69ec79c9
authored
Aug 04, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved laravel framework request cycle into laravel.php, minimalized front controller.
parent
af5059a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
170 deletions
+176
-170
index.php
public/index.php
+6
-170
laravel.php
system/laravel.php
+170
-0
No files found.
public/index.php
View file @
69ec79c9
...
...
@@ -18,11 +18,6 @@ define('APP_PATH', realpath('../application').'/');
// --------------------------------------------------------------
define
(
'SYS_PATH'
,
realpath
(
$system
=
'../system'
)
.
'/'
);
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
define
(
'PUBLIC_PATH'
,
realpath
(
__DIR__
)
.
'/'
);
// --------------------------------------------------------------
// The path to the packages directory.
// --------------------------------------------------------------
...
...
@@ -39,175 +34,16 @@ define('MODULE_PATH', realpath('../modules').'/');
define
(
'STORAGE_PATH'
,
realpath
(
'../storage'
)
.
'/'
);
// --------------------------------------------------------------
// The path to the directory containing the system directory.
// --------------------------------------------------------------
define
(
'BASE_PATH'
,
realpath
(
str_replace
(
'system'
,
''
,
$system
))
.
'/'
);
// --------------------------------------------------------------
// Define various other framework paths.
// --------------------------------------------------------------
$constants
=
array
(
'CACHE_PATH'
=>
STORAGE_PATH
.
'cache/'
,
'CONFIG_PATH'
=>
APP_PATH
.
'config/'
,
'DATABASE_PATH'
=>
STORAGE_PATH
.
'db/'
,
'LANG_PATH'
=>
APP_PATH
.
'lang/'
,
'LIBRARY_PATH'
=>
APP_PATH
.
'libraries/'
,
'MODEL_PATH'
=>
APP_PATH
.
'models/'
,
'ROUTE_PATH'
=>
APP_PATH
.
'routes/'
,
'SCRIPT_PATH'
=>
PUBLIC_PATH
.
'js/'
,
'SESSION_PATH'
=>
STORAGE_PATH
.
'sessions/'
,
'STYLE_PATH'
=>
PUBLIC_PATH
.
'css/'
,
'VIEW_PATH'
=>
APP_PATH
.
'views/'
,
);
foreach
(
$constants
as
$key
=>
$value
)
{
define
(
$key
,
$value
);
}
unset
(
$constants
,
$system
);
// --------------------------------------------------------------
// Define the PHP file extension.
// --------------------------------------------------------------
define
(
'EXT'
,
'.php'
);
// --------------------------------------------------------------
// Load the classes used by the auto-loader.
// --------------------------------------------------------------
require
SYS_PATH
.
'loader'
.
EXT
;
require
SYS_PATH
.
'config'
.
EXT
;
require
SYS_PATH
.
'arr'
.
EXT
;
// --------------------------------------------------------------
// Register the auto-loader.
// --------------------------------------------------------------
System\Loader
::
bootstrap
();
spl_autoload_register
(
array
(
'System\\Loader'
,
'load'
));
// --------------------------------------------------------------
// Set the error reporting and display levels.
// --------------------------------------------------------------
error_reporting
(
E_ALL
|
E_STRICT
);
ini_set
(
'display_errors'
,
'Off'
);
// --------------------------------------------------------------
// Register the error handlers.
// --------------------------------------------------------------
set_exception_handler
(
function
(
$e
)
{
require_once
SYS_PATH
.
'error'
.
EXT
;
System\Error
::
handle
(
$e
);
});
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
{
require_once
SYS_PATH
.
'error'
.
EXT
;
System\Error
::
handle
(
new
ErrorException
(
$error
,
$number
,
0
,
$file
,
$line
));
});
register_shutdown_function
(
function
()
{
if
(
!
is_null
(
$error
=
error_get_last
()))
{
require_once
SYS_PATH
.
'error'
.
EXT
;
System\Error
::
handle
(
new
ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
0
,
$error
[
'file'
],
$error
[
'line'
]));
}
});
// --------------------------------------------------------------
// Set the default timezone.
// --------------------------------------------------------------
date_default_timezone_set
(
System\Config
::
get
(
'application.timezone'
));
// --------------------------------------------------------------
// Load the session.
// --------------------------------------------------------------
if
(
System\Config
::
get
(
'session.driver'
)
!=
''
)
{
System\Session
::
load
(
System\Cookie
::
get
(
'laravel_session'
));
}
// --------------------------------------------------------------
// Load all of the core routing classes.
// --------------------------------------------------------------
require
SYS_PATH
.
'request'
.
EXT
;
require
SYS_PATH
.
'response'
.
EXT
;
require
SYS_PATH
.
'routing/route'
.
EXT
;
require
SYS_PATH
.
'routing/router'
.
EXT
;
require
SYS_PATH
.
'routing/loader'
.
EXT
;
require
SYS_PATH
.
'routing/filter'
.
EXT
;
// --------------------------------------------------------------
// Load the packages that are in the auto-loaded packages array.
// --------------------------------------------------------------
require
SYS_PATH
.
'package'
.
EXT
;
System\Package
::
load
(
System\Config
::
get
(
'application.packages'
));
// --------------------------------------------------------------
// Register the route filters.
// --------------------------------------------------------------
System\Routing\Filter
::
register
(
require
APP_PATH
.
'filters'
.
EXT
);
// --------------------------------------------------------------
// Execute the global "before" filter.
// --------------------------------------------------------------
$response
=
System\Routing\Filter
::
call
(
'before'
,
array
(),
true
);
// --------------------------------------------------------------
// Execute the route function.
// --------------------------------------------------------------
if
(
is_null
(
$response
))
{
$segments
=
explode
(
'/'
,
$uri
=
System\Request
::
uri
());
if
(
in_array
(
$segments
[
0
],
System\Config
::
get
(
'application.modules'
)))
{
$route_path
=
MODULE_PATH
.
$segments
[
0
]
.
'/'
;
if
(
file_exists
(
$filters
=
$route_path
.
'filters'
.
EXT
))
{
System\Routing\Filter
::
register
(
require
$filters
);
}
}
else
{
$route_path
=
APP_PATH
;
}
$route
=
System\Routing\Router
::
make
(
System\Request
::
method
(),
$uri
,
new
System\Routing\Loader
(
$route_path
))
->
route
();
$response
=
(
is_null
(
$route
))
?
System\Response
::
error
(
'404'
)
:
$route
->
call
();
}
else
{
$response
=
System\Response
::
prepare
(
$response
);
}
// --------------------------------------------------------------
// Execute the global "after" filter.
// --------------------------------------------------------------
System\Routing\Filter
::
call
(
'after'
,
array
(
$response
));
// --------------------------------------------------------------
// Stringify the response.
// The path to the public directory.
// --------------------------------------------------------------
$response
->
content
=
(
string
)
$response
->
content
;
define
(
'PUBLIC_PATH'
,
realpath
(
__DIR__
)
.
'/'
)
;
// --------------------------------------------------------------
//
Close the session
.
//
The path to the directory containing the system directory
.
// --------------------------------------------------------------
if
(
System\Config
::
get
(
'session.driver'
)
!=
''
)
{
System\Session
::
close
();
}
define
(
'BASE_PATH'
,
realpath
(
str_replace
(
'system'
,
''
,
$system
))
.
'/'
);
// --------------------------------------------------------------
//
Send the response to the browser
.
//
Launch Laravel
.
// --------------------------------------------------------------
$response
->
send
();
\ No newline at end of file
require
SYS_PATH
.
'laravel.php'
;
\ No newline at end of file
system/laravel.php
0 → 100644
View file @
69ec79c9
<?php
namespace
System
;
// --------------------------------------------------------------
// Define the PHP file extension.
// --------------------------------------------------------------
define
(
'EXT'
,
'.php'
);
// --------------------------------------------------------------
// Define various other framework paths.
// --------------------------------------------------------------
$constants
=
array
(
'CACHE_PATH'
=>
STORAGE_PATH
.
'cache/'
,
'CONFIG_PATH'
=>
APP_PATH
.
'config/'
,
'DATABASE_PATH'
=>
STORAGE_PATH
.
'db/'
,
'LANG_PATH'
=>
APP_PATH
.
'lang/'
,
'LIBRARY_PATH'
=>
APP_PATH
.
'libraries/'
,
'MODEL_PATH'
=>
APP_PATH
.
'models/'
,
'ROUTE_PATH'
=>
APP_PATH
.
'routes/'
,
'SCRIPT_PATH'
=>
PUBLIC_PATH
.
'js/'
,
'SESSION_PATH'
=>
STORAGE_PATH
.
'sessions/'
,
'STYLE_PATH'
=>
PUBLIC_PATH
.
'css/'
,
'VIEW_PATH'
=>
APP_PATH
.
'views/'
,
);
foreach
(
$constants
as
$key
=>
$value
)
{
define
(
$key
,
$value
);
}
unset
(
$constants
,
$system
);
// --------------------------------------------------------------
// Load the classes used by the auto-loader.
// --------------------------------------------------------------
require
SYS_PATH
.
'loader'
.
EXT
;
require
SYS_PATH
.
'config'
.
EXT
;
require
SYS_PATH
.
'arr'
.
EXT
;
// --------------------------------------------------------------
// Detect all of the application modules.
// --------------------------------------------------------------
Config
::
set
(
'application.modules'
,
$modules
=
array_map
(
'basename'
,
glob
(
MODULE_PATH
.
'*'
,
GLOB_ONLYDIR
)));
// --------------------------------------------------------------
// Register the auto-loader.
// --------------------------------------------------------------
Loader
::
bootstrap
();
spl_autoload_register
(
array
(
'System\\Loader'
,
'load'
));
// --------------------------------------------------------------
// Set the error reporting and display levels.
// --------------------------------------------------------------
error_reporting
(
E_ALL
|
E_STRICT
);
ini_set
(
'display_errors'
,
'Off'
);
// --------------------------------------------------------------
// Register the error handlers.
// --------------------------------------------------------------
set_exception_handler
(
function
(
$e
)
{
require_once
SYS_PATH
.
'error'
.
EXT
;
Error
::
handle
(
$e
);
});
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
{
require_once
SYS_PATH
.
'error'
.
EXT
;
Error
::
handle
(
new
\ErrorException
(
$error
,
$number
,
0
,
$file
,
$line
));
});
register_shutdown_function
(
function
()
{
if
(
!
is_null
(
$error
=
error_get_last
()))
{
require_once
SYS_PATH
.
'error'
.
EXT
;
Error
::
handle
(
new
\ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
0
,
$error
[
'file'
],
$error
[
'line'
]));
}
});
// --------------------------------------------------------------
// Set the default timezone.
// --------------------------------------------------------------
date_default_timezone_set
(
Config
::
get
(
'application.timezone'
));
// --------------------------------------------------------------
// Load the session.
// --------------------------------------------------------------
if
(
Config
::
get
(
'session.driver'
)
!=
''
)
{
Session
::
load
(
Cookie
::
get
(
'laravel_session'
));
}
// --------------------------------------------------------------
// Load all of the core routing classes.
// --------------------------------------------------------------
require
SYS_PATH
.
'request'
.
EXT
;
require
SYS_PATH
.
'response'
.
EXT
;
require
SYS_PATH
.
'routing/route'
.
EXT
;
require
SYS_PATH
.
'routing/router'
.
EXT
;
require
SYS_PATH
.
'routing/loader'
.
EXT
;
require
SYS_PATH
.
'routing/filter'
.
EXT
;
// --------------------------------------------------------------
// Register the route filters.
// --------------------------------------------------------------
Routing\Filter
::
register
(
require
APP_PATH
.
'filters'
.
EXT
);
// --------------------------------------------------------------
// Load the packages that are in the auto-loaded packages array.
// --------------------------------------------------------------
require
SYS_PATH
.
'package'
.
EXT
;
Package
::
load
(
Config
::
get
(
'application.packages'
));
// --------------------------------------------------------------
// Execute the global "before" filter.
// --------------------------------------------------------------
$response
=
Routing\Filter
::
call
(
'before'
,
array
(),
true
);
// --------------------------------------------------------------
// Route the request and call the appropriate route function.
// --------------------------------------------------------------
if
(
is_null
(
$response
))
{
$path
=
(
in_array
(
$module
=
Request
::
segment
(
1
),
$modules
))
?
MODULE_PATH
.
$module
.
'/'
:
APP_PATH
;
if
(
$path
!==
APP_PATH
)
{
if
(
file_exists
(
$filters
=
$path
.
'filters'
.
EXT
))
{
Routing\Filter
::
register
(
require
$filters
);
}
}
$route
=
Routing\Router
::
make
(
Request
::
method
(),
Request
::
uri
(),
new
Routing\Loader
(
$path
))
->
route
();
$response
=
(
is_null
(
$route
))
?
Response
::
error
(
'404'
)
:
$route
->
call
();
}
else
{
$response
=
Response
::
prepare
(
$response
);
}
// --------------------------------------------------------------
// Execute the global "after" filter.
// --------------------------------------------------------------
Routing\Filter
::
call
(
'after'
,
array
(
$response
));
// --------------------------------------------------------------
// Stringify the response.
// --------------------------------------------------------------
$response
->
content
=
(
string
)
$response
->
content
;
// --------------------------------------------------------------
// Close the session.
// --------------------------------------------------------------
if
(
Config
::
get
(
'session.driver'
)
!=
''
)
{
Session
::
close
();
}
// --------------------------------------------------------------
// Send the response to the browser.
// --------------------------------------------------------------
$response
->
send
();
\ 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