Tweaked index.php to be more robust, added bootstrap.php in APPPATH
This commit is contained in:
parent
167f397de7
commit
d59f66b4a8
25
application/bootstrap.php
Normal file
25
application/bootstrap.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
/**
|
||||
* Enable modules.
|
||||
*/
|
||||
Kohana::modules(array(
|
||||
'database' => MODPATH.'database'));
|
||||
|
||||
/**
|
||||
* Add routes.
|
||||
*/
|
||||
Route::set('static', 'static/<page>', array('page' => '.+'))
|
||||
->defaults(array(
|
||||
'controller' => 'pages',
|
||||
'action' => 'load'));
|
||||
|
||||
Route::set('default', '(<controller>(/<action>(/<id>)))')
|
||||
->defaults(array(
|
||||
'controller' => 'welcome',
|
||||
'action' => 'index',
|
||||
'id' => NULL));
|
||||
|
||||
$q = Request::instance(@$_SERVER['PATH_INFO']);
|
||||
|
||||
$q->process();
|
35
index.php
35
index.php
|
@ -39,14 +39,25 @@ define('EXT', '.php');
|
|||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Define the name of the front controller index
|
||||
define('FCINDEX', basename(__FILE__));
|
||||
// Set the full path to the docroot
|
||||
define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
|
||||
|
||||
// Make the application relative to the docroot
|
||||
if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
|
||||
$application = DOCROOT.$application;
|
||||
|
||||
// Make the modules relative to the docroot
|
||||
if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
|
||||
$modules = DOCROOT.$modules;
|
||||
|
||||
// Make the system relative to the docroot
|
||||
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
|
||||
$modules = DOCROOT.$system;
|
||||
|
||||
// Define the absolute paths for configured directories
|
||||
define('DOCROOT', str_replace('\\', '/', realpath(getcwd())).'/');
|
||||
define('APPPATH', str_replace('\\', '/', realpath($application)).'/');
|
||||
define('MODPATH', str_replace('\\', '/', realpath($modules)).'/');
|
||||
define('SYSPATH', str_replace('\\', '/', realpath($system)).'/');
|
||||
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
|
||||
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
|
||||
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
|
||||
|
||||
// Clean up the configuration vars
|
||||
unset($application, $modules, $system);
|
||||
|
@ -67,13 +78,7 @@ spl_autoload_register(array('Kohana', 'auto_load'));
|
|||
// set_exception_handler(array('Kohana', 'exception_handler'));
|
||||
|
||||
// Enable the error-to-exception handler
|
||||
set_error_handler(array('Kohana', 'error_handler'));
|
||||
// set_error_handler(array('Kohana', 'error_handler'));
|
||||
|
||||
// Initialize the environment
|
||||
Kohana::init();
|
||||
|
||||
// Create the main instance
|
||||
Kohana::instance();
|
||||
|
||||
// Shutdown the environment
|
||||
Kohana::shutdown();
|
||||
// Bootstrap the application
|
||||
require APPPATH.'bootstrap'.EXT;
|
|
@ -56,7 +56,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Application Directory</th>
|
||||
<?php if (is_dir(APPPATH) AND is_dir(APPPATH.'cache')): ?>
|
||||
<?php if (is_dir(APPPATH) AND is_file(APPPATH.'bootstrap'.EXT)): ?>
|
||||
<td class="pass"><?php echo APPPATH ?></td>
|
||||
<?php else: $failed = TRUE ?>
|
||||
<td class="fail">The configured <code>application</code> directory does not exist or does not contain required files.</td>
|
||||
|
|
Loading…
Reference in a new issue