Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F256579
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/config.prod/src/database/seeds/AppKeySeeder.php b/config.prod/src/database/seeds/AppKeySeeder.php
index 4554bf5d..56063a9e 100644
--- a/config.prod/src/database/seeds/AppKeySeeder.php
+++ b/config.prod/src/database/seeds/AppKeySeeder.php
@@ -1,62 +1,61 @@
<?php
namespace Database\Seeds;
use Laravel\Passport\Passport;
use Illuminate\Database\Seeder;
use Illuminate\Encryption\Encrypter;
class AppKeySeeder extends Seeder
{
/**
* Run the database seeds.
*
* This emulates './artisan key:generate'
*
* @return void
*/
public function run()
{
$key = $this->generateRandomKey();
$this->writeNewEnvironmentFileWith($key);
}
/**
* Generate a random key for the application.
*
* @return string
*/
protected function generateRandomKey()
{
return 'base64:' . base64_encode(
Encrypter::generateKey(\config('app.cipher'))
);
}
/**
* Write a new environment file with the given key.
*
* @param string $key
* @return void
*/
protected function writeNewEnvironmentFileWith($key)
{
file_put_contents(\app()->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY=' . $key,
file_get_contents(\app()->environmentFilePath())
));
}
/**
* Get a regex pattern that will match env APP_KEY with any random key.
*
* @return string
*/
protected function keyReplacementPattern()
{
$escaped = preg_quote('=' . \config('app.key'), '/');
return "/^APP_KEY{$escaped}/m";
}
}
-
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jun 8, 1:08 AM (58 m, 30 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
196664
Default Alt Text
(1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment