File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
src/Illuminate/Foundation/Console Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,9 @@ protected function setKeyInEnvironmentFile($key)
90
90
return false ;
91
91
}
92
92
93
- $ this ->writeNewEnvironmentFileWith ($ key );
93
+ if (! $ this ->writeNewEnvironmentFileWith ($ key )) {
94
+ return false ;
95
+ }
94
96
95
97
return true ;
96
98
}
@@ -99,15 +101,25 @@ protected function setKeyInEnvironmentFile($key)
99
101
* Write a new environment file with the given key.
100
102
*
101
103
* @param string $key
102
- * @return void
104
+ * @return bool
103
105
*/
104
106
protected function writeNewEnvironmentFileWith ($ key )
105
107
{
106
- file_put_contents ( $ this -> laravel -> environmentFilePath (), preg_replace (
108
+ $ replaced = preg_replace (
107
109
$ this ->keyReplacementPattern (),
108
110
'APP_KEY= ' .$ key ,
109
- file_get_contents ($ this ->laravel ->environmentFilePath ())
110
- ));
111
+ $ input = file_get_contents ($ this ->laravel ->environmentFilePath ())
112
+ );
113
+
114
+ if ($ replaced === $ input || $ replaced === null ) {
115
+ $ this ->error ('Unable to set application key. No APP_KEY variable was found in the .env file. ' );
116
+
117
+ return false ;
118
+ }
119
+
120
+ file_put_contents ($ this ->laravel ->environmentFilePath (), $ replaced );
121
+
122
+ return true ;
111
123
}
112
124
113
125
/**
You can’t perform that action at this time.
0 commit comments