Closed totoprayogo1916 closed 2 years ago
You mean you cleared the contents of .env
?
You mean you cleared the contents of
.env
?
yes
You mean you cleared the contents of
.env
?yes
The question is, why should you delete the contents of this file?
The question is, why should you delete the contents of this file?
Here I only try it locally, not for production purposes.
I'm not sure which behavior is more intuitive to handle such edge case:
--show
flag; orI chose the second option.😀
2️⃣
2.
I tried this code it works. but I can't write the test
- $ret = file_put_contents($envFile, preg_replace(
- $this->keyPattern($oldKey),
- "\nencryption.key = {$newKey}",
- file_get_contents($envFile)
- ));
+ // get the file contents
+ $contents = file_get_contents($envFile);
+
+ // is encryption.key found?
+ $searchfor = 'encryption.key';
+
+ // escape special characters in the query
+ $pattern = preg_quote($searchfor, '/');
+
+ // finalise the regular expression, matching the whole line
+ $pattern = "/^.*$pattern.*\$/m";
+
+ if (preg_match_all($pattern, $contents, $matches)) {
+ $ins = preg_replace(
+ $this->keyPattern($oldKey),
+ "\nencryption.key = {$newKey}",
+ file_get_contents($envFile)
+ );
+ }
+ else {
+ $ins = $contents . "\nencryption.key = {$newKey}";
+ }
+
+ $ret = file_put_contents($envFile, $ins);
Fix is underway.
PHP Version
7.4
CodeIgniter4 Version
4.2.10
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
cli-server (PHP built-in webserver)
Database
No response
What happened?
Try deleting all entries in
.env
so you can sort out which ones to use. But when runningspark key:generate
noencryption.key
is created even though the message on the shell is successful.Steps to Reproduce
remove all
.env
then runphp spark key:generate
Expected Output
In
.env
should createencryption.key =
even without templateAnything else?
No response