88class InstallGrokCommand extends Command
99{
1010 protected $ signature = 'grok:install ' ;
11+
1112 protected $ description = 'Prepares the Grok AI client for use in Laravel. ' ;
1213
1314 private const REPO_URL = 'https://github.com/grok-php/laravel ' ;
@@ -17,6 +18,7 @@ public function handle(): void
1718 // Check if the package is already installed
1819 if ($ this ->isAlreadyInstalled ()) {
1920 $ this ->warn ('⚠️ Grok AI is already installed. No changes were made. ' );
21+
2022 return ;
2123 }
2224
@@ -60,6 +62,7 @@ private function copyConfig(): void
6062 {
6163 if (file_exists (config_path ('grok.php ' ))) {
6264 $ this ->warn ('⚠️ Config file already exists: config/grok.php ' );
65+
6366 return ;
6467 }
6568
@@ -79,13 +82,14 @@ private function addEnvKeys(string $envFile): void
7982
8083 if (! file_exists ($ filePath )) {
8184 $ this ->warn ("⚠️ Skipping: {$ envFile } not found. " );
85+
8286 return ;
8387 }
8488
8589 $ fileContent = file_get_contents ($ filePath );
8690
8791 // Grok AI environment variables with comments
88- $ envSection = <<<EOL
92+ $ envSection = <<<' EOL'
8993
9094# --------------------------------------------------------------------------
9195# 🧠 GROK AI CONFIGURATION
@@ -104,11 +108,12 @@ private function addEnvKeys(string $envFile): void
104108 // Check if any of the variables already exist
105109 if (str_contains ($ fileContent , 'GROK_API_KEY ' )) {
106110 $ this ->info ("✅ {$ envFile } is already up to date. " );
111+
107112 return ;
108113 }
109114
110115 // Append the section to the .env file
111- file_put_contents ($ filePath , PHP_EOL . $ envSection . PHP_EOL , FILE_APPEND );
116+ file_put_contents ($ filePath , PHP_EOL . $ envSection. PHP_EOL , FILE_APPEND );
112117
113118 $ this ->info ("✅ Added Grok AI environment variables to {$ envFile }" );
114119 }
@@ -133,11 +138,11 @@ private function openRepositoryInBrowser(): void
133138 $ this ->info ('Opening GitHub repository... 🌍 ' );
134139
135140 if (PHP_OS_FAMILY === 'Darwin ' ) {
136- exec ('open ' . self ::REPO_URL );
141+ exec ('open ' . self ::REPO_URL );
137142 } elseif (PHP_OS_FAMILY === 'Windows ' ) {
138- exec ('start ' . self ::REPO_URL );
143+ exec ('start ' . self ::REPO_URL );
139144 } elseif (PHP_OS_FAMILY === 'Linux ' ) {
140- exec ('xdg-open ' . self ::REPO_URL );
145+ exec ('xdg-open ' . self ::REPO_URL );
141146 }
142147 }
143148}
0 commit comments