Replace the Application loader to facilitate moving the public/ dir to the root
This commit is contained in:
parent
d768589cb1
commit
7d414ce017
22
app/Console/Commands/Test.php
Normal file
22
app/Console/Commands/Test.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
|
||||
class Test extends Command
|
||||
{
|
||||
protected $signature = 'phpvms:test';
|
||||
protected $description = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
print resource_path();
|
||||
}
|
||||
}
|
@ -1,66 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Create The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The first thing we will do is create a new Laravel application instance
|
||||
| which serves as the "glue" for all the components of Laravel, and is
|
||||
| the IoC container for the system binding all of the various parts.
|
||||
|
|
||||
*/
|
||||
|
||||
if(!defined('LUMEN_START')) {
|
||||
define('LUMEN_START', microtime(true));
|
||||
}
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
realpath(__DIR__.'/../')
|
||||
);
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$app->bind('path.public', function () {
|
||||
return __DIR__.'/../public';
|
||||
});
|
||||
/**
|
||||
* Customized container to allow some of the base Laravel
|
||||
* configurations to be overridden
|
||||
*/
|
||||
class App extends Illuminate\Foundation\Application
|
||||
{
|
||||
public function __construct(string $basePath = null)
|
||||
{
|
||||
parent::__construct(dirname(__DIR__) . '/');
|
||||
|
||||
#$app->loadEnvironmentFrom('.env.php');
|
||||
$app->useDatabasePath(realpath(__DIR__.'/../app/Database'));
|
||||
$this->loadEnvironmentFrom('.env');
|
||||
$this->useDatabasePath($this->basePath . '/app/Database');
|
||||
$this->useStoragePath($this->basePath . '/storage');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, we need to bind some important interfaces into the container so
|
||||
| we will be able to resolve them when needed. The kernels serve the
|
||||
| incoming requests to this application from both the web and CLI.
|
||||
|
|
||||
*/
|
||||
$this->bind('path.public', function () {
|
||||
return __DIR__ . '/../public';
|
||||
});
|
||||
}
|
||||
|
||||
$app->singleton(
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function bindInterfaces()
|
||||
{
|
||||
$this->singleton(
|
||||
Illuminate\Contracts\Http\Kernel::class,
|
||||
App\Http\Kernel::class
|
||||
);
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
$this->singleton(
|
||||
Illuminate\Contracts\Console\Kernel::class,
|
||||
App\Console\Kernel::class
|
||||
);
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
$this->singleton(
|
||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
||||
App\Exceptions\Handler::class
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Return The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This script returns the application instance. The instance is given to
|
||||
| the calling script so we can separate the building of the instances
|
||||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
/**
|
||||
* Override paths
|
||||
*/
|
||||
|
||||
public function configPath($path = '')
|
||||
{
|
||||
return $this->basePath . DS . 'config' . ($path ? DS . $path : $path);
|
||||
}
|
||||
|
||||
public function resourcePath($path = '')
|
||||
{
|
||||
return $this->basePath . DS . 'resources' . ($path ? DS . $path : $path);
|
||||
}
|
||||
}
|
||||
|
||||
$app = new App();
|
||||
$app->bindInterfaces();
|
||||
|
||||
return $app;
|
||||
|
Loading…
Reference in New Issue
Block a user