Refactored the installer so it all comes under the /install URL, and the AppInstaller namespace and source is outside of the public/ folder.

This commit is contained in:
Andy Heathershaw 2020-04-27 08:57:13 +01:00
parent 6ad1cdda8f
commit e2f195f5be
18 changed files with 44 additions and 40 deletions

View File

@ -1,6 +1,6 @@
<?php
namespace AppBootstrap;
namespace AppInstaller;
use App\Services\GiteaService;
use Illuminate\Support\Facades\Artisan;
@ -10,22 +10,22 @@ use Illuminate\Support\Facades\Artisan;
* Because Laravel and other vendors are not yet available, it uses "raw" PHP and the odd few classes within Blue
* Twilight, such as GiteaService.
*
* @package AppBootstrap
* @package AppInstaller
*/
class Bootstrapper
class Installer
{
/**
* Path to /public/bootstrap
* @var string
*/
private $bootstrapDir;
/**
* Path to /app/config
* @var string
*/
private $configDir;
/**
* Path to /installer
* @var string
*/
private $installerDir;
/**
* Path to / - the app's root
* @var string
@ -33,7 +33,7 @@ class Bootstrapper
private $rootDir;
/**
* Path to /public/bootstrap/temp
* Path to /installer/temp
* @var string
*/
private $tempDir;
@ -45,20 +45,20 @@ class Bootstrapper
private $vendorDir;
/**
* Path to /public/bootstrap/views
* Path to /installer/views
* @var string
*/
private $viewsDir;
public function __construct()
{
$this->bootstrapDir = dirname(__DIR__);
$this->rootDir = dirname(dirname($this->bootstrapDir));
$this->installerDir = __DIR__;
$this->rootDir = dirname($this->installerDir);
$this->configDir = sprintf('%s/config', dirname(dirname($this->bootstrapDir)));
$this->tempDir = sprintf('%s/temp', $this->bootstrapDir);
$this->configDir = sprintf('%s/config', dirname(dirname($this->installerDir)));
$this->tempDir = sprintf('%s/temp', $this->installerDir);
$this->vendorDir = sprintf('%s/vendor', $this->rootDir);
$this->viewsDir = sprintf('%s/views', $this->bootstrapDir);
$this->viewsDir = sprintf('%s/views', $this->installerDir);
chdir($this->rootDir);
putenv('HOME=' . $this->rootDir);

View File

@ -1,6 +1,6 @@
{
"name": "aheathershaw/blue-twilight-bootstrapper",
"description": "Bootstrapper component for Blue Twilight - self-hosted photo gallery software.",
"name": "aheathershaw/blue-twilight-installer",
"description": "Installer for Blue Twilight - self-hosted photo gallery software.",
"keywords": [
"blue",
"twilight",
@ -19,8 +19,8 @@
},
"autoload": {
"psr-4": {
"App\\": "../../app/",
"AppBootstrap\\": "src/"
"App\\": "../app/",
"AppInstaller\\": "./"
}
}
}

View File

@ -1,4 +1,7 @@
<?php
namespace AppInstaller;
function ends_with($stringToCheck, $stringToFind)
{
return strlen($stringToCheck) >= strlen($stringToFind) &&

View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a::getLoader();
return ComposerAutoloaderInitae1de26c658d13c195b98449ea1bf6a1::getLoader();

View File

@ -6,6 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'App\\' => array($baseDir . '/../../app'),
'AppBootstrap\\' => array($baseDir . '/src'),
'App\\' => array($baseDir . '/../app'),
'AppInstaller\\' => array($baseDir . '/'),
);

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a
class ComposerAutoloaderInitae1de26c658d13c195b98449ea1bf6a1
{
private static $loader;
@ -19,15 +19,15 @@ class ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitae1de26c658d13c195b98449ea1bf6a1', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitae1de26c658d13c195b98449ea1bf6a1', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitae2939a73e74219a5e53fe33357ebb1a::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitae1de26c658d13c195b98449ea1bf6a1::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {

View File

@ -4,32 +4,32 @@
namespace Composer\Autoload;
class ComposerStaticInitae2939a73e74219a5e53fe33357ebb1a
class ComposerStaticInitae1de26c658d13c195b98449ea1bf6a1
{
public static $prefixLengthsPsr4 = array (
'A' =>
array (
'App\\' => 4,
'AppBootstrap\\' => 13,
'AppInstaller\\' => 13,
),
);
public static $prefixDirsPsr4 = array (
'App\\' =>
array (
0 => __DIR__ . '/../..' . '/../../app',
0 => __DIR__ . '/../..' . '/../app',
),
'AppBootstrap\\' =>
'AppInstaller\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
0 => __DIR__ . '/../..' . '/',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitae2939a73e74219a5e53fe33357ebb1a::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitae2939a73e74219a5e53fe33357ebb1a::$prefixDirsPsr4;
$loader->prefixLengthsPsr4 = ComposerStaticInitae1de26c658d13c195b98449ea1bf6a1::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitae1de26c658d13c195b98449ea1bf6a1::$prefixDirsPsr4;
}, null, ClassLoader::class);
}

View File

@ -11,7 +11,7 @@
if (!file_exists(__DIR__.'/../vendor/autoload.php'))
{
$currentUrl = $_SERVER['PHP_SELF']; // e.g. /some/directory/index.php
$bootstrapUrl = sprintf('%sbootstrap', dirname($currentUrl));
$bootstrapUrl = sprintf('%sinstall', dirname($currentUrl));
header(sprintf('Location: %s', $bootstrapUrl));
exit();
}

View File

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

View File

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 581 B

View File

Before

Width:  |  Height:  |  Size: 610 B

After

Width:  |  Height:  |  Size: 610 B

View File

@ -1,9 +1,10 @@
<?php
require_once sprintf('%s/vendor/autoload.php', __DIR__);
require_once sprintf('%s/helpers.php', __DIR__);
ini_set('display_errors', 'on');
$installerDir = sprintf('%s/installer', dirname(dirname(__DIR__)));
require_once sprintf('%s/vendor/autoload.php', $installerDir);
require_once sprintf('%s/helpers.php', $installerDir);
if (!function_exists('env'))
{
// Define a dummy env() function that always returns the default value so we can load the config/app.php file
@ -16,8 +17,8 @@ if (!function_exists('env'))
try
{
$bs = new \AppBootstrap\Bootstrapper();
$bs->handleRequest();
$installer = new \AppInstaller\Installer();
$installer->handleRequest();
}
catch (\Exception $ex)
{