From e2f195f5bec663d8cb91af714bc492369258d6c3 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Mon, 27 Apr 2020 08:57:13 +0100 Subject: [PATCH] Refactored the installer so it all comes under the /install URL, and the AppInstaller namespace and source is outside of the public/ folder. --- .../Installer.php | 32 +++++++++---------- {public/bootstrap => installer}/composer.json | 8 ++--- {public/bootstrap => installer}/helpers.php | 3 ++ .../bootstrap => installer}/temp/.gitignore | 0 .../vendor/autoload.php | 2 +- .../vendor/composer/ClassLoader.php | 0 .../vendor/composer/LICENSE | 0 .../vendor/composer/autoload_classmap.php | 0 .../vendor/composer/autoload_namespaces.php | 0 .../vendor/composer/autoload_psr4.php | 4 +-- .../vendor/composer/autoload_real.php | 8 ++--- .../vendor/composer/autoload_static.php | 14 ++++---- .../bootstrap => installer}/views/index.php | 0 public/index.php | 2 +- .../images/completed.svg | 0 .../{bootstrap => install}/images/loading.svg | 0 .../{bootstrap => install}/images/waiting.svg | 0 public/{bootstrap => install}/index.php | 11 ++++--- 18 files changed, 44 insertions(+), 40 deletions(-) rename public/bootstrap/src/Bootstrapper.php => installer/Installer.php (93%) rename {public/bootstrap => installer}/composer.json (58%) rename {public/bootstrap => installer}/helpers.php (94%) rename {public/bootstrap => installer}/temp/.gitignore (100%) rename {public/bootstrap => installer}/vendor/autoload.php (64%) rename {public/bootstrap => installer}/vendor/composer/ClassLoader.php (100%) rename {public/bootstrap => installer}/vendor/composer/LICENSE (100%) rename {public/bootstrap => installer}/vendor/composer/autoload_classmap.php (100%) rename {public/bootstrap => installer}/vendor/composer/autoload_namespaces.php (100%) rename {public/bootstrap => installer}/vendor/composer/autoload_psr4.php (59%) rename {public/bootstrap => installer}/vendor/composer/autoload_real.php (79%) rename {public/bootstrap => installer}/vendor/composer/autoload_static.php (53%) rename {public/bootstrap => installer}/views/index.php (100%) rename public/{bootstrap => install}/images/completed.svg (100%) rename public/{bootstrap => install}/images/loading.svg (100%) rename public/{bootstrap => install}/images/waiting.svg (100%) rename public/{bootstrap => install}/index.php (58%) diff --git a/public/bootstrap/src/Bootstrapper.php b/installer/Installer.php similarity index 93% rename from public/bootstrap/src/Bootstrapper.php rename to installer/Installer.php index 19283a1..11cd304 100644 --- a/public/bootstrap/src/Bootstrapper.php +++ b/installer/Installer.php @@ -1,6 +1,6 @@ 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); diff --git a/public/bootstrap/composer.json b/installer/composer.json similarity index 58% rename from public/bootstrap/composer.json rename to installer/composer.json index 27c2f40..d6d44ad 100644 --- a/public/bootstrap/composer.json +++ b/installer/composer.json @@ -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\\": "./" } } } \ No newline at end of file diff --git a/public/bootstrap/helpers.php b/installer/helpers.php similarity index 94% rename from public/bootstrap/helpers.php rename to installer/helpers.php index 867f9fc..65a9328 100644 --- a/public/bootstrap/helpers.php +++ b/installer/helpers.php @@ -1,4 +1,7 @@ = strlen($stringToFind) && diff --git a/public/bootstrap/temp/.gitignore b/installer/temp/.gitignore similarity index 100% rename from public/bootstrap/temp/.gitignore rename to installer/temp/.gitignore diff --git a/public/bootstrap/vendor/autoload.php b/installer/vendor/autoload.php similarity index 64% rename from public/bootstrap/vendor/autoload.php rename to installer/vendor/autoload.php index 400d928..a7811ce 100644 --- a/public/bootstrap/vendor/autoload.php +++ b/installer/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitae2939a73e74219a5e53fe33357ebb1a::getLoader(); +return ComposerAutoloaderInitae1de26c658d13c195b98449ea1bf6a1::getLoader(); diff --git a/public/bootstrap/vendor/composer/ClassLoader.php b/installer/vendor/composer/ClassLoader.php similarity index 100% rename from public/bootstrap/vendor/composer/ClassLoader.php rename to installer/vendor/composer/ClassLoader.php diff --git a/public/bootstrap/vendor/composer/LICENSE b/installer/vendor/composer/LICENSE similarity index 100% rename from public/bootstrap/vendor/composer/LICENSE rename to installer/vendor/composer/LICENSE diff --git a/public/bootstrap/vendor/composer/autoload_classmap.php b/installer/vendor/composer/autoload_classmap.php similarity index 100% rename from public/bootstrap/vendor/composer/autoload_classmap.php rename to installer/vendor/composer/autoload_classmap.php diff --git a/public/bootstrap/vendor/composer/autoload_namespaces.php b/installer/vendor/composer/autoload_namespaces.php similarity index 100% rename from public/bootstrap/vendor/composer/autoload_namespaces.php rename to installer/vendor/composer/autoload_namespaces.php diff --git a/public/bootstrap/vendor/composer/autoload_psr4.php b/installer/vendor/composer/autoload_psr4.php similarity index 59% rename from public/bootstrap/vendor/composer/autoload_psr4.php rename to installer/vendor/composer/autoload_psr4.php index 070042b..e221e30 100644 --- a/public/bootstrap/vendor/composer/autoload_psr4.php +++ b/installer/vendor/composer/autoload_psr4.php @@ -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 . '/'), ); diff --git a/public/bootstrap/vendor/composer/autoload_real.php b/installer/vendor/composer/autoload_real.php similarity index 79% rename from public/bootstrap/vendor/composer/autoload_real.php rename to installer/vendor/composer/autoload_real.php index 60669ec..4fa66e6 100644 --- a/public/bootstrap/vendor/composer/autoload_real.php +++ b/installer/vendor/composer/autoload_real.php @@ -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) { diff --git a/public/bootstrap/vendor/composer/autoload_static.php b/installer/vendor/composer/autoload_static.php similarity index 53% rename from public/bootstrap/vendor/composer/autoload_static.php rename to installer/vendor/composer/autoload_static.php index 23bfb55..f581139 100644 --- a/public/bootstrap/vendor/composer/autoload_static.php +++ b/installer/vendor/composer/autoload_static.php @@ -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); } diff --git a/public/bootstrap/views/index.php b/installer/views/index.php similarity index 100% rename from public/bootstrap/views/index.php rename to installer/views/index.php diff --git a/public/index.php b/public/index.php index 74b1342..2edc992 100644 --- a/public/index.php +++ b/public/index.php @@ -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(); } diff --git a/public/bootstrap/images/completed.svg b/public/install/images/completed.svg similarity index 100% rename from public/bootstrap/images/completed.svg rename to public/install/images/completed.svg diff --git a/public/bootstrap/images/loading.svg b/public/install/images/loading.svg similarity index 100% rename from public/bootstrap/images/loading.svg rename to public/install/images/loading.svg diff --git a/public/bootstrap/images/waiting.svg b/public/install/images/waiting.svg similarity index 100% rename from public/bootstrap/images/waiting.svg rename to public/install/images/waiting.svg diff --git a/public/bootstrap/index.php b/public/install/index.php similarity index 58% rename from public/bootstrap/index.php rename to public/install/index.php index da5781b..a3fbeb2 100644 --- a/public/bootstrap/index.php +++ b/public/install/index.php @@ -1,9 +1,10 @@ handleRequest(); + $installer = new \AppInstaller\Installer(); + $installer->handleRequest(); } catch (\Exception $ex) {