2017-01-15 23:06:39 -06:00
|
|
|
<?php
|
|
|
|
|
2017-01-20 00:57:53 -08:00
|
|
|
/**
|
2020-10-24 16:38:41 +08:00
|
|
|
* This file is part of the CodeIgniter 4 framework.
|
2017-01-20 00:57:53 -08:00
|
|
|
*
|
2020-10-24 16:38:41 +08:00
|
|
|
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
2017-01-20 00:57:53 -08:00
|
|
|
*
|
2020-10-24 16:38:41 +08:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2017-01-20 00:57:53 -08:00
|
|
|
*/
|
|
|
|
|
2020-10-18 15:36:32 +07:00
|
|
|
use CodeIgniter\Config\DotEnv;
|
|
|
|
use Config\Autoload;
|
|
|
|
use Config\Modules;
|
2021-01-05 22:20:17 +07:00
|
|
|
use Config\Paths;
|
2020-11-03 19:46:10 +02:00
|
|
|
use Config\Services;
|
2020-10-18 15:36:32 +07:00
|
|
|
|
2017-01-15 23:06:39 -06:00
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
* SETUP OUR PATH CONSTANTS
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* The path constants provide convenient access to the folders
|
|
|
|
* throughout the application. We have to setup them up here
|
|
|
|
* so they are available in the config files that are loaded.
|
|
|
|
*/
|
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
// The path to the application directory.
|
2018-12-03 17:31:31 -02:00
|
|
|
if (! defined('APPPATH'))
|
2018-05-08 00:02:34 -05:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
/**
|
|
|
|
* @var Paths $paths
|
|
|
|
*/
|
|
|
|
define('APPPATH', realpath(rtrim($paths->appDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
2018-05-08 00:02:34 -05:00
|
|
|
}
|
2017-01-15 23:06:39 -06:00
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
// The path to the project root directory. Just above APPPATH.
|
2018-12-03 17:31:31 -02:00
|
|
|
if (! defined('ROOTPATH'))
|
2018-05-08 00:02:34 -05:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR);
|
2018-05-08 00:02:34 -05:00
|
|
|
}
|
2017-01-15 23:35:14 -06:00
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
// The path to the system directory.
|
2018-12-07 17:44:44 -02:00
|
|
|
if (! defined('SYSTEMPATH'))
|
2018-05-08 00:02:34 -05:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
/**
|
|
|
|
* @var Paths $paths
|
|
|
|
*/
|
|
|
|
define('SYSTEMPATH', realpath(rtrim($paths->systemDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
2018-05-08 00:02:34 -05:00
|
|
|
}
|
2017-01-15 23:35:14 -06:00
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
// The path to the writable directory.
|
2018-05-08 00:02:34 -05:00
|
|
|
if (! defined('WRITEPATH'))
|
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
/**
|
|
|
|
* @var Paths $paths
|
|
|
|
*/
|
|
|
|
define('WRITEPATH', realpath(rtrim($paths->writableDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
2018-05-08 00:02:34 -05:00
|
|
|
}
|
2017-01-15 23:06:39 -06:00
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
// The path to the tests directory
|
2018-05-08 00:02:34 -05:00
|
|
|
if (! defined('TESTPATH'))
|
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
/**
|
|
|
|
* @var Paths $paths
|
|
|
|
*/
|
|
|
|
define('TESTPATH', realpath(rtrim($paths->testsDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);
|
2018-05-08 00:02:34 -05:00
|
|
|
}
|
2017-01-15 23:06:39 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
* GRAB OUR CONSTANTS & COMMON
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
*/
|
2019-01-01 13:59:57 -06:00
|
|
|
if (! defined('APP_NAMESPACE'))
|
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
require_once APPPATH . 'Config/Constants.php';
|
2019-01-01 13:59:57 -06:00
|
|
|
}
|
2017-01-15 23:06:39 -06:00
|
|
|
|
2020-11-03 18:56:41 +02:00
|
|
|
// Require app/Common.php file if exists.
|
2020-11-04 18:56:49 +02:00
|
|
|
if (is_file(APPPATH . 'Common.php'))
|
2019-08-27 23:00:26 -05:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
require_once APPPATH . 'Common.php';
|
2019-07-27 18:17:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Require system/Common.php
|
2018-12-07 17:44:44 -02:00
|
|
|
require_once SYSTEMPATH . 'Common.php';
|
2017-01-15 23:06:39 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
* LOAD OUR AUTOLOADER
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
*
|
2020-11-03 18:56:41 +02:00
|
|
|
* The autoloader allows all of the pieces to work together in the
|
|
|
|
* framework. We have to load it here, though, so that the config
|
|
|
|
* files can use the path constants.
|
2017-01-15 23:06:39 -06:00
|
|
|
*/
|
|
|
|
|
2020-08-28 19:29:52 +08:00
|
|
|
if (! class_exists('Config\Autoload', false))
|
2019-01-01 13:59:57 -06:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
require_once SYSTEMPATH . 'Config/AutoloadConfig.php';
|
|
|
|
require_once APPPATH . 'Config/Autoload.php';
|
|
|
|
require_once SYSTEMPATH . 'Modules/Modules.php';
|
|
|
|
require_once APPPATH . 'Config/Modules.php';
|
2019-01-01 13:59:57 -06:00
|
|
|
}
|
|
|
|
|
2018-12-07 17:44:44 -02:00
|
|
|
require_once SYSTEMPATH . 'Autoloader/Autoloader.php';
|
|
|
|
require_once SYSTEMPATH . 'Config/BaseService.php';
|
2020-11-03 19:46:10 +02:00
|
|
|
require_once SYSTEMPATH . 'Config/Services.php';
|
|
|
|
require_once APPPATH . 'Config/Services.php';
|
|
|
|
|
|
|
|
// Use Config\Services as CodeIgniter\Services
|
|
|
|
if (! class_exists('CodeIgniter\Services', false))
|
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
class_alias('Config\Services', 'CodeIgniter\Services');
|
2020-11-03 19:46:10 +02:00
|
|
|
}
|
2017-01-15 23:06:39 -06:00
|
|
|
|
2020-11-03 18:56:41 +02:00
|
|
|
// Initialize and register the loader with the SPL autoloader stack.
|
2020-11-03 19:46:10 +02:00
|
|
|
Services::autoloader()->initialize(new Autoload(), new Modules())->register();
|
2017-01-15 23:06:39 -06:00
|
|
|
|
|
|
|
// Now load Composer's if it's available
|
2018-11-28 01:33:43 +09:00
|
|
|
if (is_file(COMPOSER_PATH))
|
2017-01-15 23:06:39 -06:00
|
|
|
{
|
2021-06-04 22:51:52 +08:00
|
|
|
/*
|
|
|
|
* The path to the vendor directory.
|
|
|
|
*
|
|
|
|
* We do not want to enforce this, so set the constant if Composer was used.
|
|
|
|
*/
|
|
|
|
if (! defined('VENDORPATH'))
|
|
|
|
{
|
|
|
|
define('VENDORPATH', realpath(ROOTPATH . 'vendor') . DIRECTORY_SEPARATOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once COMPOSER_PATH;
|
2017-01-15 23:06:39 -06:00
|
|
|
}
|
|
|
|
|
2020-11-03 18:56:41 +02:00
|
|
|
// Load environment settings from .env files into $_SERVER and $_ENV
|
2018-12-07 17:44:44 -02:00
|
|
|
require_once SYSTEMPATH . 'Config/DotEnv.php';
|
2017-12-17 22:33:52 -06:00
|
|
|
|
2020-10-04 00:27:56 +07:00
|
|
|
$env = new DotEnv(ROOTPATH);
|
2017-12-17 22:33:52 -06:00
|
|
|
$env->load();
|
|
|
|
|
2020-11-03 18:56:41 +02:00
|
|
|
// Always load the URL helper, it should be used in most of apps.
|
2017-02-10 00:11:08 -06:00
|
|
|
helper('url');
|
|
|
|
|
2017-01-15 23:06:39 -06:00
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
* GRAB OUR CODEIGNITER INSTANCE
|
|
|
|
* ---------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* The CodeIgniter class contains the core functionality to make
|
|
|
|
* the application run, and does all of the dirty work to get
|
|
|
|
* the pieces all working together.
|
|
|
|
*/
|
|
|
|
|
2021-03-01 20:44:40 +02:00
|
|
|
$app = Services::codeigniter();
|
2017-01-15 23:06:39 -06:00
|
|
|
$app->initialize();
|
|
|
|
|
|
|
|
return $app;
|