From 34b2ff6ea4bba3d3c6fed936078607ffded52675 Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Wed, 6 Sep 2017 10:33:22 +0100 Subject: [PATCH] #25: Updated the installer to work with a brand-new system with just PHP installed. Changed the way the base URL is determined to work with systems that have to access the app using /public. --- app/Providers/AppServiceProvider.php | 9 ++ public/install.php | 101 ++++++++++++++++--- resources/views/install/layout.blade.php | 2 +- resources/views/themes/base/layout.blade.php | 2 +- 4 files changed, 100 insertions(+), 14 deletions(-) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 4d78745..d7e3d17 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -53,6 +53,15 @@ class AppServiceProvider extends ServiceProvider { LengthAwarePaginator::defaultView($themeHelper->viewName('partials.pager_links')); } + + // Set base URL variable (used in both the main app and the installer) + $baseUrl = url('/'); + if (!substr($baseUrl, strlen($baseUrl) - 1, 1) != '/') + { + $baseUrl .= '/'; + } + + View::share('appBaseUrl', $baseUrl); } /** diff --git a/public/install.php b/public/install.php index 8fed6ec..44e5ba6 100644 --- a/public/install.php +++ b/public/install.php @@ -11,6 +11,7 @@ class BlueTwilightInstaller { $this->baseDirectory = dirname(__DIR__); chdir($this->baseDirectory); + putenv('HOME=' . $this->baseDirectory); // Display errors so installer never gets a WSOD! ini_set('display_errors', true); @@ -25,19 +26,27 @@ class BlueTwilightInstaller exit(); } ?> -

Blue Twilight Setup

-

We need to download a few things - namely Composer and related packages - before we can kick off the Blue Twilight installer.

-

We can do this for you - simply click the button below.

-
- -
+ + + Blue Twilight Setup + + +

Blue Twilight Setup

+

We need to download a few things - namely Composer and related packages - before we can kick off the Blue Twilight installer.

+

We can do this for you - simply click the button below.

+

This can take a few minutes so please be patient!

+
+ +
-
-

Got Composer?

+
+

Got Composer?

-

If you already have Composer installed, however, you may want to use that instead. Just run the below commands on your server, changing the path to Composer as appropriate:

-

Please note: "composer.phar" may actually be "composer" on your system.

-
cd baseDirectory; ?>
/path/to/composer.phar install
+

If you already have Composer installed, however, you may want to use that instead. Just run the below commands on your server, changing the path to Composer as appropriate:

+

Please note: "composer.phar" may actually be "composer" on your system.

+
cd baseDirectory; ?>
/path/to/composer.phar install
+ + %s...%s", $step[0], PHP_EOL); @@ -62,15 +74,49 @@ class BlueTwilightInstaller if (!$result) { + $successful = false; break; } } + if ($successful) + { + header('Location: install/check'); + exit(); + } + ?> 0) + { + $this->echoError(sprintf('The following PHP modules are missing and need to be installed to continue: %s', join(', ', $invalidModules))); + return false; + } + + return true; + } + private function echoError($message) { echo sprintf("%s.%s", $message, PHP_EOL); @@ -105,11 +151,42 @@ class BlueTwilightInstaller return true; } + private function generateAppKey() + { + if (!file_exists('.env') && file_exists('.env.example')) + { + copy('.env.example', '.env'); + } + + ob_start(); + system('touch .env', $rc); + $result = ob_get_clean(); + echo nl2br($result); + + ob_start(); + system('php artisan key:generate', $rc); + $result = ob_get_clean(); + echo nl2br($result); + + if ($rc != 0) + { + $this->echoError('Failed to generate application key'); + return false; + } + + $this->echoOK(); + return true; + } + private function installComposer() { $rc = -1; + ob_start(); system('php -r "copy(\'https://getcomposer.org/installer\', \'composer-setup.php\');"', $rc); + $result = ob_get_clean(); + echo nl2br($result); + if ($rc != 0) { $this->echoError('Failed to fetch Composer'); diff --git a/resources/views/install/layout.blade.php b/resources/views/install/layout.blade.php index 0d7026d..be00d72 100644 --- a/resources/views/install/layout.blade.php +++ b/resources/views/install/layout.blade.php @@ -7,7 +7,7 @@ @yield('title') | @lang('global.app_name') - + diff --git a/resources/views/themes/base/layout.blade.php b/resources/views/themes/base/layout.blade.php index 1a9cb19..6e2be77 100644 --- a/resources/views/themes/base/layout.blade.php +++ b/resources/views/themes/base/layout.blade.php @@ -7,7 +7,7 @@ @yield('title') | {{ UserConfig::get('app_name') }} - +