1 | <?php namespace crocodicstudio\crudbooster\commands; |
||||
2 | |||||
3 | use App; |
||||
4 | use Cache; |
||||
5 | use CRUDBooster; |
||||
0 ignored issues
–
show
|
|||||
6 | use DB; |
||||
7 | use Illuminate\Console\Command; |
||||
8 | use Request; |
||||
9 | use Symfony\Component\Process\Process; |
||||
10 | |||||
11 | class CrudboosterUpdateCommand extends Command |
||||
12 | { |
||||
13 | /** |
||||
14 | * The console command name. |
||||
15 | * |
||||
16 | * @var string |
||||
17 | */ |
||||
18 | protected $name = 'crudbooster:update'; |
||||
19 | |||||
20 | /** |
||||
21 | * The console command description. |
||||
22 | * |
||||
23 | * @var string |
||||
24 | */ |
||||
25 | protected $description = 'CRUDBooster Update Command'; |
||||
26 | |||||
27 | /** |
||||
28 | * Execute the console command. |
||||
29 | * |
||||
30 | * @return mixed |
||||
31 | */ |
||||
32 | public function handle() |
||||
33 | { |
||||
34 | |||||
35 | $this->header(); |
||||
36 | $this->checkRequirements(); |
||||
37 | |||||
38 | $this->info('Updating: '); |
||||
39 | |||||
40 | if (! file_exists(public_path('vendor'))) { |
||||
41 | mkdir(public_path('vendor'), 0777); |
||||
42 | } |
||||
43 | |||||
44 | $this->info('Publishing CRUDBooster needs file...'); |
||||
45 | $this->call('vendor:publish'); |
||||
46 | $this->call('vendor:publish', ['--tag' => 'cb_migration', '--force' => true]); |
||||
47 | $this->call('vendor:publish', ['--tag' => 'cb_lfm', '--force' => true]); |
||||
48 | $this->call('vendor:publish', ['--tag' => 'cb_localization', '--force' => true]); |
||||
49 | |||||
50 | $configLFM = config_path('lfm.php'); |
||||
51 | $configLFM = file_get_contents($configLFM); |
||||
52 | $configLFMModified = str_replace("['web','auth']", "['web','\crocodicstudio\crudbooster\middlewares\CBBackend']", $configLFM); |
||||
53 | $configLFMModified = str_replace('Unisharp\Laravelfilemanager\Handlers\ConfigHandler::class', 'function() {return Session::get("admin_id");}', $configLFMModified); |
||||
54 | $configLFMModified = str_replace('auth()->user()->id', 'Session::get("admin_id")', $configLFMModified); |
||||
55 | $configLFMModified = str_replace("'alphanumeric_filename' => false", "'alphanumeric_filename' => true", $configLFMModified); |
||||
56 | $configLFMModified = str_replace("'alphanumeric_directory' => false", "'alphanumeric_directory' => true", $configLFMModified); |
||||
57 | $configLFMModified = str_replace("'alphanumeric_directory' => false", "'alphanumeric_directory' => true", $configLFMModified); |
||||
58 | $configLFMModified = str_replace("'base_directory' => 'public'", "'base_directory' => 'storage/app'", $configLFMModified); |
||||
59 | $configLFMModified = str_replace("'images_folder_name' => 'photos'", "'images_folder_name' => 'uploads'", $configLFMModified); |
||||
60 | $configLFMModified = str_replace("'files_folder_name' => 'files'", "'files_folder_name' => 'uploads'", $configLFMModified); |
||||
61 | file_put_contents(config_path('lfm.php'), $configLFMModified); |
||||
62 | |||||
63 | $this->info('Dumping the autoloaded files and reloading all new files...'); |
||||
64 | $composer = $this->findComposer(); |
||||
65 | $process = new Process($composer.' dumpautoload'); |
||||
0 ignored issues
–
show
$composer . ' dumpautoload' of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
66 | $process->setWorkingDirectory(base_path())->run(); |
||||
67 | |||||
68 | $this->info('Migrating database...'); |
||||
69 | $this->call('migrate'); |
||||
70 | |||||
71 | if (! class_exists('CBSeeder')) { |
||||
72 | require_once __DIR__.'/../database/seeds/CBSeeder.php'; |
||||
73 | } |
||||
74 | $this->call('db:seed', ['--class' => 'CBSeeder']); |
||||
75 | |||||
76 | $this->info('Clearing Cache...'); |
||||
77 | Cache::flush(); |
||||
78 | |||||
79 | $this->info('Clearing config cache...'); |
||||
80 | $this->call('config:clear'); |
||||
81 | |||||
82 | $this->footer(); |
||||
83 | } |
||||
84 | |||||
85 | private function header() |
||||
86 | { |
||||
87 | $this->info(" |
||||
88 | # __________ __ ______ ____ __ |
||||
89 | # / ____/ __ \/ / / / __ \/ __ )____ ____ _____/ /____ _____ |
||||
90 | # / / / /_/ / / / / / / / __ / __ \/ __ \/ ___/ __/ _ \/ ___/ |
||||
91 | # / /___/ _, _/ /_/ / /_/ / /_/ / /_/ / /_/ (__ ) /_/ __/ / |
||||
92 | # \____/_/ |_|\____/_____/_____/\____/\____/____/\__/\___/_/ |
||||
93 | # |
||||
94 | "); |
||||
95 | $this->info('--------- :===: Thanks for choosing CRUDBooster :==: ---------------'); |
||||
96 | $this->info('===================================================================='); |
||||
97 | } |
||||
98 | |||||
99 | private function checkRequirements() |
||||
100 | { |
||||
101 | $this->info('System Requirements Checking:'); |
||||
102 | $system_failed = 0; |
||||
103 | $laravel = app(); |
||||
104 | |||||
105 | if ($laravel::VERSION >= 5.3) { |
||||
0 ignored issues
–
show
|
|||||
106 | $this->info('Laravel Version (>= 5.3.*): [Good]'); |
||||
107 | } else { |
||||
108 | $this->info('Laravel Version (>= 5.3.*): [Bad]'); |
||||
109 | $system_failed++; |
||||
110 | } |
||||
111 | |||||
112 | if (version_compare(phpversion(), '5.6.0', '>=')) { |
||||
113 | $this->info('PHP Version (>= 5.6.*): [Good]'); |
||||
114 | } else { |
||||
115 | $this->info('PHP Version (>= 5.6.*): [Bad] Yours: '.phpversion()); |
||||
116 | $system_failed++; |
||||
117 | } |
||||
118 | |||||
119 | if (extension_loaded('mbstring')) { |
||||
120 | $this->info('Mbstring extension: [Good]'); |
||||
121 | } else { |
||||
122 | $this->info('Mbstring extension: [Bad]'); |
||||
123 | $system_failed++; |
||||
124 | } |
||||
125 | |||||
126 | if (extension_loaded('openssl')) { |
||||
127 | $this->info('OpenSSL extension: [Good]'); |
||||
128 | } else { |
||||
129 | $this->info('OpenSSL extension: [Bad]'); |
||||
130 | $system_failed++; |
||||
131 | } |
||||
132 | |||||
133 | if (extension_loaded('pdo')) { |
||||
134 | $this->info('PDO extension: [Good]'); |
||||
135 | } else { |
||||
136 | $this->info('PDO extension: [Bad]'); |
||||
137 | $system_failed++; |
||||
138 | } |
||||
139 | |||||
140 | if (extension_loaded('tokenizer')) { |
||||
141 | $this->info('Tokenizer extension: [Good]'); |
||||
142 | } else { |
||||
143 | $this->info('Tokenizer extension: [Bad]'); |
||||
144 | $system_failed++; |
||||
145 | } |
||||
146 | |||||
147 | if (extension_loaded('xml')) { |
||||
148 | $this->info('XML extension: [Good]'); |
||||
149 | } else { |
||||
150 | $this->info('XML extension: [Bad]'); |
||||
151 | $system_failed++; |
||||
152 | } |
||||
153 | |||||
154 | if (extension_loaded('gd')) { |
||||
155 | $this->info('GD extension: [Good]'); |
||||
156 | } else { |
||||
157 | $this->info('GD extension: [Bad]'); |
||||
158 | $system_failed++; |
||||
159 | } |
||||
160 | |||||
161 | if (extension_loaded('fileinfo')) { |
||||
162 | $this->info('PHP Fileinfo extension: [Good]'); |
||||
163 | } else { |
||||
164 | $this->info('PHP Fileinfo extension: [Bad]'); |
||||
165 | $system_failed++; |
||||
166 | } |
||||
167 | |||||
168 | if (is_writable(base_path('public'))) { |
||||
169 | $this->info('public dir is writable: [Good]'); |
||||
170 | } else { |
||||
171 | $this->info('public dir is writable: [Bad]'); |
||||
172 | $system_failed++; |
||||
173 | } |
||||
174 | |||||
175 | if ($system_failed != 0) { |
||||
176 | $this->info('Sorry unfortunately your system is not meet with our requirements !'); |
||||
177 | $this->footer(false); |
||||
178 | } |
||||
179 | $this->info('--'); |
||||
180 | } |
||||
181 | |||||
182 | private function footer($success = true) |
||||
183 | { |
||||
184 | $this->info('--'); |
||||
185 | $this->info('Homepage : http://www.crudbooster.com'); |
||||
186 | $this->info('Github : https://github.com/crocodic-studio/crudbooster'); |
||||
187 | $this->info('Documentation : https://github.com/crocodic-studio/crudbooster/blob/master/docs/en/index.md'); |
||||
188 | $this->info('===================================================================='); |
||||
189 | if ($success == true) { |
||||
190 | $this->info('------------------- :===: Completed !! :===: ------------------------'); |
||||
191 | } else { |
||||
192 | $this->info('------------------- :===: Failed !! :===: ------------------------'); |
||||
193 | } |
||||
194 | exit; |
||||
0 ignored issues
–
show
|
|||||
195 | } |
||||
196 | |||||
197 | /** |
||||
198 | * Get the composer command for the environment. |
||||
199 | * |
||||
200 | * @return string |
||||
201 | */ |
||||
202 | protected function findComposer() |
||||
203 | { |
||||
204 | if (file_exists(getcwd().'/composer.phar')) { |
||||
205 | return '"'.PHP_BINARY.'" '.getcwd().'/composer.phar'; |
||||
206 | } |
||||
207 | |||||
208 | return 'composer'; |
||||
209 | } |
||||
210 | } |
||||
211 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths