2017-12-17 12:13:53 +08:00
|
|
|
<?php
|
|
|
|
|
2018-01-30 03:16:39 +08:00
|
|
|
use App\Bootstrap\LoadConfiguration;
|
2017-12-17 12:13:53 +08:00
|
|
|
|
2017-12-17 15:03:19 +08:00
|
|
|
if (!defined('DS')) {
|
|
|
|
define('DS', DIRECTORY_SEPARATOR);
|
|
|
|
}
|
|
|
|
|
2017-12-17 12:13:53 +08:00
|
|
|
/**
|
|
|
|
* Customized container to allow some of the base Laravel
|
|
|
|
* configurations to be overridden
|
|
|
|
*/
|
2018-08-27 00:40:04 +08:00
|
|
|
class application extends Illuminate\Foundation\Application
|
2017-12-17 12:13:53 +08:00
|
|
|
{
|
2018-08-27 00:40:04 +08:00
|
|
|
private $publicDirPath;
|
|
|
|
private $publicUrlPath = '/';
|
2017-12-17 15:03:19 +08:00
|
|
|
|
2017-12-17 12:13:53 +08:00
|
|
|
public function __construct(string $basePath = null)
|
|
|
|
{
|
2018-03-14 22:46:02 +08:00
|
|
|
parent::__construct(dirname(__DIR__).'/');
|
2017-12-17 12:13:53 +08:00
|
|
|
|
2017-12-17 15:10:49 +08:00
|
|
|
$this->loadEnvironmentFrom('env.php');
|
2018-03-14 22:46:02 +08:00
|
|
|
$this->useDatabasePath($this->basePath.'/app/Database');
|
|
|
|
$this->useStoragePath($this->basePath.'/storage');
|
2017-12-17 12:13:53 +08:00
|
|
|
}
|
|
|
|
|
2018-01-30 03:16:39 +08:00
|
|
|
/**
|
|
|
|
* Override this method so we can inject our own LoadConfiguration
|
|
|
|
* class, which looks for any configurations that have been overridden
|
|
|
|
* in the root's config.php file
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-01-30 03:16:39 +08:00
|
|
|
* @param array $bootstrappers
|
|
|
|
*/
|
|
|
|
public function bootstrapWith(array $bootstrappers)
|
|
|
|
{
|
2018-03-14 22:46:02 +08:00
|
|
|
$find = \Illuminate\Foundation\Bootstrap\LoadConfiguration::class;
|
2018-01-30 03:16:39 +08:00
|
|
|
$replace = LoadConfiguration::class;
|
|
|
|
|
2018-03-14 22:46:02 +08:00
|
|
|
$bootstrappers = array_replace(
|
|
|
|
$bootstrappers,
|
|
|
|
array_fill_keys(
|
2021-12-03 22:23:59 +08:00
|
|
|
array_keys($bootstrappers, $find, true),
|
2018-03-14 22:46:02 +08:00
|
|
|
$replace
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
parent::bootstrapWith($bootstrappers);
|
2018-01-30 03:16:39 +08:00
|
|
|
}
|
|
|
|
|
2017-12-17 12:13:53 +08:00
|
|
|
public function bindInterfaces()
|
|
|
|
{
|
|
|
|
$this->singleton(
|
|
|
|
Illuminate\Contracts\Http\Kernel::class,
|
|
|
|
App\Http\Kernel::class
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->singleton(
|
|
|
|
Illuminate\Contracts\Console\Kernel::class,
|
|
|
|
App\Console\Kernel::class
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->singleton(
|
|
|
|
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
|
|
|
App\Exceptions\Handler::class
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override paths
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param mixed $publicDirPath
|
2017-12-17 12:13:53 +08:00
|
|
|
*/
|
2017-12-18 06:58:53 +08:00
|
|
|
public function setPublicPath($publicDirPath)
|
2017-12-17 15:03:19 +08:00
|
|
|
{
|
2017-12-18 06:58:53 +08:00
|
|
|
$this->publicDirPath = $publicDirPath;
|
2020-11-24 02:39:26 +08:00
|
|
|
$this->instance('path.public', $publicDirPath);
|
2017-12-18 06:58:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Added for the custom filesystem driver. Used in the index.php
|
|
|
|
* in the root of the install to set it to point to /public,
|
|
|
|
* instead of just /
|
|
|
|
*
|
|
|
|
* @param $publicUrlPath
|
|
|
|
*/
|
|
|
|
public function setPublicUrlPath($publicUrlPath)
|
|
|
|
{
|
|
|
|
$this->publicUrlPath = $publicUrlPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Added for the custom filesystem driver lookup on what to use
|
|
|
|
* for the base URL
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function publicUrlPath()
|
|
|
|
{
|
|
|
|
return $this->publicUrlPath ?: '/';
|
2017-12-17 15:03:19 +08:00
|
|
|
}
|
|
|
|
|
2017-12-17 12:13:53 +08:00
|
|
|
public function configPath($path = '')
|
|
|
|
{
|
2018-03-14 22:46:02 +08:00
|
|
|
return $this->basePath.DS.'config'.($path ? DS.$path : $path);
|
2017-12-17 12:13:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function langPath()
|
|
|
|
{
|
2018-03-14 22:46:02 +08:00
|
|
|
return $this->resourcePath().DS.'lang';
|
2017-12-17 12:13:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function publicPath()
|
|
|
|
{
|
2020-11-24 02:39:26 +08:00
|
|
|
if (empty($this->publicDirPath)) {
|
|
|
|
return $this->basePath.DS.'public';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->publicDirPath;
|
2017-12-17 12:13:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public function resourcePath($path = '')
|
|
|
|
{
|
2018-03-14 22:46:02 +08:00
|
|
|
return $this->basePath.DS.'resources'.($path ? DS.$path : $path);
|
2017-12-17 12:13:53 +08:00
|
|
|
}
|
|
|
|
}
|