Skip to content

Commit 4239523

Browse files
committed
fixes #2506 - installation process bugs
1 parent 1b76b0a commit 4239523

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ All Notable changes to `Backpack CRUD` will be documented in this file.
88

99
-----------
1010

11+
## 4.0.45 - 2020-03-05
12+
13+
### Fixed
14+
- installation command did not correctly use the new version of Symphony Process;
15+
16+
1117
## 4.0.44 - 2020-03-04
1218

1319
### Fixed

src/app/Console/Commands/AddSidebarContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function handle()
5353
$this->error('Could not write to sidebar_content file.');
5454
}
5555
} else {
56-
$this->error("The sidebar_content file does not exist. Make sure Backpack\Base is properly installed.");
56+
$this->error("The sidebar_content file does not exist. Make sure Backpack is properly installed.");
5757
}
5858
}
5959
}

src/app/Console/Commands/Install.php

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Console\Command;
66
use Symfony\Component\Process\Exception\ProcessFailedException;
77
use Symfony\Component\Process\Process;
8+
use Artisan;
89

910
class Install extends Command
1011
{
@@ -63,33 +64,38 @@ public function handle()
6364
$this->progressBar->advance();
6465

6566
$this->line(' Publishing configs, langs, views, js and css files');
66-
$this->executeProcess('php artisan vendor:publish --provider="Backpack\CRUD\BackpackServiceProvider" --tag="minimum"');
67+
$this->executeArtisanProcess('vendor:publish', [
68+
'--provider' => 'Backpack\CRUD\BackpackServiceProvider',
69+
'--tag' => 'minimum'
70+
]);
6771

6872
$this->line(' Publishing config for notifications - prologue/alerts');
69-
$this->executeProcess('php artisan vendor:publish --provider="Prologue\Alerts\AlertsServiceProvider"');
73+
$this->executeArtisanProcess('vendor:publish', [
74+
'--provider' => 'Prologue\Alerts\AlertsServiceProvider'
75+
]);
7076

7177
$this->line(" Generating users table (using Laravel's default migrations)");
72-
$this->executeProcess('php artisan migrate');
78+
$this->executeArtisanProcess('migrate');
7379

7480
$this->line(" Creating App\Models\BackpackUser.php");
75-
$this->executeProcess('php artisan backpack:publish-user-model');
81+
$this->executeArtisanProcess('backpack:publish-user-model');
7682

7783
$this->line(" Creating App\Http\Middleware\CheckIfAdmin.php");
78-
$this->executeProcess('php artisan backpack:publish-middleware');
84+
$this->executeArtisanProcess('backpack:publish-middleware');
7985

8086
// elFinder steps
8187
if ($shouldInstallElfinder) {
8288
$this->line(' Installing barryvdh/laravel-elfinder');
83-
$this->executeProcess('composer require barryvdh/laravel-elfinder');
89+
$this->executeProcess(['composer', 'require', 'barryvdh/laravel-elfinder']);
8490

8591
$this->line(' Creating uploads directory');
8692
switch (DIRECTORY_SEPARATOR) {
8793
case '/': // unix
88-
$createUploadDirectoryCommand = 'mkdir -p public/uploads';
94+
$createUploadDirectoryCommand = ['mkdir', '-p', 'public/uploads'];
8995
break;
9096
case '\\': // windows
9197
if (! file_exists('public\uploads')) {
92-
$createUploadDirectoryCommand = 'mkdir public\uploads';
98+
$createUploadDirectoryCommand = ['mkdir', 'public\uploads'];
9399
}
94100
break;
95101
}
@@ -98,18 +104,23 @@ public function handle()
98104
}
99105

100106
$this->line(' Publishing elFinder assets');
101-
$this->executeProcess('php artisan elfinder:publish');
107+
$this->executeArtisanProcess('elfinder:publish');
102108

103109
$this->line(' Publishing custom elfinder views');
104-
$this->executeProcess('php artisan vendor:publish --provider="Backpack\CRUD\BackpackServiceProvider" --tag="elfinder"');
110+
$this->executeArtisanProcess('vendor:publish', [
111+
'--provider' => 'Backpack\CRUD\BackpackServiceProvider',
112+
'--tag' => 'elfinder'
113+
]);
105114

106115
$this->line(' Adding sidebar menu item for File Manager');
107116
switch (DIRECTORY_SEPARATOR) {
108117
case '/': // unix
109-
$this->executeProcess('php artisan backpack:add-sidebar-content "<li class="nav-item"><a class="nav-link" href=\"{{ backpack_url(\'elfinder\') }}\"><i class=\"nav-icon fa fa-files-o\"></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>"');
118+
$this->executeArtisanProcess('backpack:add-sidebar-content', [
119+
'code' => '<li class="nav-item"><a class="nav-link" href="{{ backpack_url(\'elfinder\') }}\"><i class="nav-icon fa fa-files-o"></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>']);
110120
break;
111121
case '\\': // windows
112-
$this->executeProcess('php artisan backpack:add-sidebar-content "<li class="nav-item"><a class="nav-link" href=""{{ backpack_url(\'elfinder\') }}""><i class=""nav-icon fa fa-files-o""></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>"');
122+
$this->executeArtisanProcess('backpack:add-sidebar-content', [
123+
'code' => '<li class="nav-item"><a class="nav-link" href=""{{ backpack_url(\'elfinder\') }}""><i class=""nav-icon fa fa-files-o""></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>']);
113124
break;
114125
}
115126
}
@@ -158,6 +169,37 @@ public function executeProcess($command, $beforeNotice = false, $afterNotice = f
158169
}
159170
}
160171

172+
/**
173+
* Run an artisan command.
174+
*
175+
* @param string $command The artisan command to be run.
176+
* @param array $arguments Key-value array of arguments to the artisan command.
177+
* @param bool $beforeNotice Information for the user before the command is run
178+
* @param bool $afterNotice Information for the user after the command is run
179+
*
180+
* @return mixed Command-line output
181+
*/
182+
public function executeArtisanProcess($command, $arguments = [], $beforeNotice = false, $afterNotice = false)
183+
{
184+
$beforeNotice = $beforeNotice ? ' '.$beforeNotice : 'php artisan '.$command.' '.implode(' ', $arguments);
185+
186+
$this->echo('info', $beforeNotice);
187+
188+
try {
189+
Artisan::call($command, $arguments);
190+
} catch (Exception $e) {
191+
throw new ProcessFailedException($e);
192+
}
193+
194+
if ($this->progressBar) {
195+
$this->progressBar->advance();
196+
}
197+
198+
if ($afterNotice) {
199+
$this->echo('info', $afterNotice);
200+
}
201+
}
202+
161203
/**
162204
* Write text to the screen for the user to see.
163205
*

0 commit comments

Comments
 (0)