-
Notifications
You must be signed in to change notification settings - Fork 1
/
laravel-fix.php
59 lines (45 loc) · 1.54 KB
/
laravel-fix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
$currentDir = __DIR__ . DIRECTORY_SEPARATOR;
echo "START: Laravel fix\n";
echo "1. Removing vendor directory...\n";
$cmd = 'rm -rf ' . $currentDir . 'vendor';
echo cmd($cmd) . "\n";
echo "2. Updating composer...\n";
$cmd = 'composer update --prefer-dist -o';
echo cmd($cmd) . "\n";
echo "3. Changing overall owner to www-data...\n";
$cmd = 'chown -R www-data:www-data ' . $currentDir . '*';
$output = cmd($cmd);
echo $output . "\n";
echo "4. Changing overall mod to 770...\n";
$cmd = 'chmod -R 770 ' . $currentDir . '*';
$output = cmd($cmd);
echo $output . "\n";
echo "5. Repair all directories\n";
$cmd = 'chown -R www-data:www-data ' . $currentDir . '*';
echo cmd($cmd) . "\n";
$cmd = 'chmod -R 775 ' . $currentDir . 'public/';
echo cmd($cmd) . "\n";
echo "6. Repair storage directory\n";
$cmd = 'chown -R www-data:www-data ' . $currentDir . 'storage/';
echo cmd($cmd) . "\n";
$cmd = 'chmod -R 775 ' . $currentDir . 'storage/';
echo cmd($cmd) . "\n";
echo "7. Repair bootstrap/cache directory\n";
$cmd = 'chown -R www-data:www-data ' . $currentDir . 'bootstrap/cache/';
echo cmd($cmd) . "\n";
$cmd = 'chmod -R 775 ' . $currentDir . 'bootstrap/cache/';
echo cmd($cmd) . "\n";
echo "8. Repair public directory\n";
$cmd = 'chown -R www-data:www-data ' . $currentDir . 'public/';
$output = cmd($cmd);
echo $output . "\n";
$cmd = 'chmod -R 770 ' . $currentDir . 'public/';
echo cmd($cmd) . "\n";
echo "END: Laravel fix\n";
/* Required functions */
function cmd($cmd) {
echo "Executing command: $cmd\n";
$output = shell_exec($cmd);
return $output;
}