Conditions | 6 |
Paths | 17 |
Total Lines | 70 |
Code Lines | 35 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php namespace crocodicstudio\crudbooster\commands; |
||
31 | public function handle() |
||
32 | { |
||
33 | |||
34 | $this->header(); |
||
35 | |||
36 | $this->checkRequirements(); |
||
37 | |||
38 | $this->info('Installing: '); |
||
39 | |||
40 | if ($this->confirm('Do you have setting the database configuration at .env ?')) { |
||
41 | |||
42 | if (! file_exists(public_path('vendor')) ) { |
||
43 | mkdir(public_path('vendor')); |
||
44 | } |
||
45 | |||
46 | $this->info('Please wait CRUDBooster publish assets...'); |
||
47 | $this->call('vendor:publish', ['--tag' => 'cb_config']); |
||
48 | $this->call('vendor:publish', ['--tag' => 'cb_hook']); |
||
49 | $this->call('vendor:publish', ['--tag' => 'cb_asset', '--force' => true]); |
||
50 | $this->call('vendor:publish', ['--tag' => 'cb_migration', '--force' => true]); |
||
51 | |||
52 | /* |
||
53 | * Create CBPlugins |
||
54 | */ |
||
55 | if(!file_exists(app_path("CBPlugins"))) { |
||
56 | mkdir(app_path("CBPlugins")); |
||
57 | } |
||
58 | |||
59 | /* |
||
60 | * Create storage dir on public |
||
61 | * We need it to change default laravel local filesystem from storage to public |
||
62 | * We won't use symlink because of a security issue in many server |
||
63 | */ |
||
64 | if(!file_exists(public_path("storage"))) { |
||
65 | $this->info("Create storage directory on /public"); |
||
66 | mkdir(public_path("storage")); |
||
67 | file_put_contents(public_path("storage/.gitignore"),"!.gitignore"); |
||
68 | file_put_contents(public_path("storage/index.html")," "); |
||
69 | } |
||
70 | |||
71 | /* |
||
72 | * We want to add more security to your Laravel |
||
73 | * Disable index listing |
||
74 | * Disable php execution on /vendor/* |
||
75 | */ |
||
76 | $this->info("Tweak some security for your laravel"); |
||
77 | file_put_contents(base_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
||
78 | file_put_contents(public_path(".htaccess"), "\n\n# Generated by CRUDBooster\nServerSignature Off\nIndexIgnore *\nRewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]\nRewriteRule ^vendor/.*\.(php|rb|py)$ - [F,L,NC]\n<FilesMatch \"^\.\">\nOrder allow,deny\nDeny from all\n</FilesMatch>",FILE_APPEND); |
||
79 | |||
80 | |||
81 | $this->info('Dumping the autoloaded files and reloading all new files...'); |
||
82 | $composer = $this->findComposer(); |
||
83 | $process = new Process($composer.' dump-autoload'); |
||
|
|||
84 | $process->setWorkingDirectory(base_path())->run(); |
||
85 | |||
86 | $this->info('Migrating database...'); |
||
87 | $this->call('migrate'); |
||
88 | |||
89 | $this->call('config:clear'); |
||
90 | if (app()->version() < 5.6) { |
||
91 | $this->call('optimize'); |
||
92 | } |
||
93 | |||
94 | $this->info('Installing CRUDBooster Is Completed ! Thank You :)'); |
||
95 | } else { |
||
96 | $this->info('Setup Aborted !'); |
||
97 | $this->info('Please setting the database configuration for first !'); |
||
98 | } |
||
99 | |||
100 | $this->footer(); |
||
101 | } |
||
233 |