Optimize Added

This commit is contained in:
devansh bawari 2021-02-09 11:02:31 +05:30
parent 266eb7874c
commit bfc2b0a554
1 changed files with 31 additions and 11 deletions

View File

@ -1,21 +1,41 @@
<?php
/* max execution time limit */
ini_set('max_execution_time', 900);
// array to pass back data
$data = array();
/* php bin path */
$phpbin = PHP_BINDIR . '/php';
// run command on terminal
$key = 'cd ../.. && '. $phpbin .' artisan key:generate 2>&1';
$seeder = 'cd ../.. && '. $phpbin .' artisan db:seed 2>&1';
$publish = 'cd ../.. && '. $phpbin .' artisan vendor:publish --all --force 2>&1';
/* commands sequence */
$commands = [
'seeder' => [
'key' => 'seeder_results',
'command' => 'cd ../.. && '. $phpbin .' artisan db:seed 2>&1'
],
'publish' => [
'key' => 'publish_results',
'command' => 'cd ../.. && '. $phpbin .' artisan vendor:publish --all --force 2>&1'
],
'storage_link' => [
'key' => 'storage_link_results',
'command' => 'cd ../.. && '. $phpbin .' artisan storage:link 2>&1'
],
'key' => [
'key' => 'key_results',
'command' => 'cd ../.. && '. $phpbin .' artisan key:generate 2>&1'
],
'optimize' => [
'key' => 'optimize_results',
'command' => 'cd ../.. && '. $phpbin .' artisan optimize 2>&1'
],
];
$key_output = exec($key, $data['key'], $data['key_results']);
$seeder_output = exec($seeder, $data['seeder'], $data['seeder_results']);
$publish = exec($publish, $data['publish'], $data['publish_results']);
// run command on terminal
$data = [];
foreach ($commands as $key => $value) {
exec($value['command'], $data[$key], $data[$value['key']]);
}
// return a response
//return all our data to an AJAX call
// return all our data to an AJAX call
echo json_encode($data);