mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Remove Bootstrap class and update _bootstrap.php
This commit is contained in:
parent
a8a932b320
commit
cdfdb93476
42
index.php
42
index.php
@ -188,6 +188,46 @@ $loader->initialize(new Config\Autoload());
|
||||
// the psr4 loader.
|
||||
$loader->register();
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the global functions
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
require_once BASEPATH.'Common.php';
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Set custom exception handling
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$config = new \Config\App();
|
||||
|
||||
Config\Services::exceptions($config, true)
|
||||
->initialize();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Should we use a Composer autoloader?
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
if ($composer_autoload = $config->composerAutoload)
|
||||
{
|
||||
if ($composer_autoload === TRUE)
|
||||
{
|
||||
file_exists(APPPATH.'vendor/autoload.php')
|
||||
? require_once(APPPATH.'vendor/autoload.php')
|
||||
: log_message('error', '$config->\'composerAutoload\' is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
|
||||
}
|
||||
elseif (file_exists($composer_autoload))
|
||||
{
|
||||
require_once($composer_autoload);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'Could not find the specified $config->\'composerAutoload\' path: '.$composer_autoload);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* LOAD THE BOOTSTRAP FILE
|
||||
@ -195,7 +235,5 @@ $loader->register();
|
||||
*
|
||||
* And away we go...
|
||||
*/
|
||||
$config = new Config\App();
|
||||
new CodeIgniter\Bootstrap($config);
|
||||
$codeigniter = new CodeIgniter\CodeIgniter($startMemory, $startTime, $config);
|
||||
$codeigniter->run();
|
||||
|
@ -18,7 +18,6 @@
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./system</directory>
|
||||
<exclude>
|
||||
<file>./system/Bootstrap.php</file>
|
||||
<file>./system/ComposerScripts.php</file>
|
||||
<file>./system/View/Escaper.php</file>
|
||||
<directory suffix=".php">./system/View/Exception</directory>
|
||||
|
@ -1,117 +0,0 @@
|
||||
<?php namespace CodeIgniter;
|
||||
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @author CodeIgniter Dev Team
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link http://codeigniter.com
|
||||
* @since Version 4.0.0
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
use Config\App;
|
||||
use Config\Services;
|
||||
use Config\Autoload;
|
||||
|
||||
/**
|
||||
* Class Bootstrap
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @package CodeIgniter
|
||||
*/
|
||||
class Bootstrap
|
||||
{
|
||||
/**
|
||||
* The application configuration object.
|
||||
*
|
||||
* @var \Config\App
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
public function __construct(App $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
||||
require_once BASEPATH.'Common.php';
|
||||
|
||||
$this->setExceptionHandling();
|
||||
$this->loadComposerAutoloader();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set custom exception handling
|
||||
*/
|
||||
protected function setExceptionHandling()
|
||||
{
|
||||
Services::exceptions($this->config, true)
|
||||
->initialize();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Should we use a Composer autoloader?
|
||||
*
|
||||
* CodeIgniter provides its own PSR4-compatible autoloader, but many
|
||||
* third-party scripts will take advantage of the extra flexibility
|
||||
* that Composer provides. This allows that support to be provided,
|
||||
* and even with a customizable path to their autoloader.
|
||||
*/
|
||||
protected function loadComposerAutoloader()
|
||||
{
|
||||
$composer_autoload = $this->config->composerAutoload;
|
||||
|
||||
if (empty($composer_autoload))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($composer_autoload === true)
|
||||
{
|
||||
file_exists(APPPATH.'vendor/autoload.php')
|
||||
? require_once(APPPATH.'vendor/autoload.php')
|
||||
: log_message('error', '$this->config->\'composerAutoload\' is set to TRUE but '.APPPATH.
|
||||
'vendor/autoload.php was not found.');
|
||||
}
|
||||
elseif (file_exists($composer_autoload))
|
||||
{
|
||||
require_once($composer_autoload);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error',
|
||||
'Could not find the specified $this->config->\'composerAutoload\' path: '.$composer_autoload);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<?php namespace CodeIgniter;
|
||||
|
||||
class MockBootstrap extends Bootstrap
|
||||
{
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ switch (ENVIRONMENT)
|
||||
}
|
||||
|
||||
define('CI_DEBUG', 1);
|
||||
define('SHOW_DEBUG_BACKTRACE', TRUE);
|
||||
|
||||
$system_path = '../../system';
|
||||
|
||||
@ -31,25 +32,11 @@ $application_folder = '../../application';
|
||||
|
||||
$writable_directory = '../../writable';
|
||||
|
||||
|
||||
// Set the current directory correctly for CLI requests
|
||||
if (defined('STDIN'))
|
||||
{
|
||||
// Ensure the current directory is pointing to the front controller's directory
|
||||
chdir(__DIR__);
|
||||
}
|
||||
|
||||
if (($_temp = realpath($system_path)) !== false)
|
||||
{
|
||||
$system_path = $_temp.'/';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure there's a trailing slash
|
||||
$system_path = rtrim($system_path, '/').'/';
|
||||
}
|
||||
|
||||
// Is the system path correct?
|
||||
if ( ! is_dir($system_path))
|
||||
// Are the system and application paths correct?
|
||||
if ( ! realpath($system_path) OR ! is_dir($system_path))
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', true, 503);
|
||||
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.
|
||||
@ -57,43 +44,44 @@ if ( ! is_dir($system_path))
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
|
||||
// Path to the system folder
|
||||
define('BASEPATH', str_replace('\\', '/', $system_path));
|
||||
|
||||
// Path to the front controller (this file)
|
||||
define('FCPATH', realpath(__DIR__.'/../../') .'/');
|
||||
|
||||
// The name of the INDEX file
|
||||
define('SELF', pathinfo(FCPATH.'index.php', PATHINFO_BASENAME));
|
||||
|
||||
// Path to the writable directory.
|
||||
define('WRITEPATH', realpath(str_replace('\\', '/', $writable_directory)).'/');
|
||||
|
||||
// The path to the "application" folder
|
||||
if (is_dir($application_folder))
|
||||
{
|
||||
if (($_temp = realpath($application_folder)) !== false)
|
||||
{
|
||||
$application_folder = $_temp;
|
||||
}
|
||||
|
||||
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
|
||||
if ( ! realpath($application_folder) OR ! is_dir($application_folder))
|
||||
{
|
||||
header('HTTP/1.1 503 Service Unavailable.', true, 503);
|
||||
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.
|
||||
SELF;
|
||||
pathinfo(__FILE__, PATHINFO_BASENAME);
|
||||
exit(3); // EXIT_CONFIG
|
||||
}
|
||||
|
||||
define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR);
|
||||
}
|
||||
// The name of THIS file
|
||||
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
|
||||
|
||||
// Path to the system folder
|
||||
define('BASEPATH', realpath($system_path).DIRECTORY_SEPARATOR);
|
||||
|
||||
// Path to the front controller (this file)
|
||||
define('FCPATH', __DIR__.DIRECTORY_SEPARATOR);
|
||||
|
||||
// Path to the writable directory.
|
||||
define('WRITEPATH', realpath($writable_directory).DIRECTORY_SEPARATOR);
|
||||
|
||||
// The path to the "application" folder
|
||||
define('APPPATH', realpath($application_folder).DIRECTORY_SEPARATOR);
|
||||
|
||||
define('SUPPORTPATH', realpath(BASEPATH.'../tests/_support/').'/');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load any environment-specific settings from .env file
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Load environment settings from .env files
|
||||
// into $_SERVER and $_ENV
|
||||
require BASEPATH.'Config/DotEnv.php';
|
||||
$env = new CodeIgniter\Config\DotEnv(APPPATH);
|
||||
$env->load();
|
||||
unset($env);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the framework constants
|
||||
@ -130,12 +118,45 @@ $loader->register();
|
||||
$loader->addNamespace('CodeIgniter', SUPPORTPATH);
|
||||
$loader->addNamespace('Config', SUPPORTPATH.'Config');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the global functions
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
require_once BASEPATH.'Common.php';
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Set custom exception handling
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$config = new \Config\App();
|
||||
|
||||
Config\Services::exceptions($config, true)
|
||||
->initialize();
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// LOAD THE BOOTSTRAP FILE
|
||||
// Should we use a Composer autoloader?
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
$config = new Config\App();
|
||||
new CodeIgniter\MockBootstrap($config);
|
||||
if ($composer_autoload = $config->composerAutoload)
|
||||
{
|
||||
if ($composer_autoload === TRUE)
|
||||
{
|
||||
file_exists(APPPATH.'vendor/autoload.php')
|
||||
? require_once(APPPATH.'vendor/autoload.php')
|
||||
: log_message('error', '$config->\'composerAutoload\' is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
|
||||
}
|
||||
elseif (file_exists($composer_autoload))
|
||||
{
|
||||
require_once($composer_autoload);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', 'Could not find the specified $config->\'composerAutoload\' path: '.$composer_autoload);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Load our TestCase
|
||||
|
Loading…
x
Reference in New Issue
Block a user