25 lines
		
	
	
		
			569 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			569 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace kernel\console\controllers;
 | 
						|
 | 
						|
use kernel\console\ConsoleController;
 | 
						|
use kernel\services\TokenService;
 | 
						|
use Random\RandomException;
 | 
						|
 | 
						|
class SecureController extends ConsoleController
 | 
						|
{
 | 
						|
 | 
						|
    /**
 | 
						|
     * @throws RandomException
 | 
						|
     */
 | 
						|
    public function actionCreateSecretKey(): void
 | 
						|
    {
 | 
						|
        $envFile = \EnvEditor\EnvFile::loadFrom(ROOT_DIR . "/.env");
 | 
						|
 | 
						|
        $envFile->setValue("SECRET_KEY", TokenService::random_bytes(15));
 | 
						|
 | 
						|
        $envFile->saveTo(ROOT_DIR . "/.env");
 | 
						|
        $this->out->r("Secret key successfully created.", "green");
 | 
						|
    }
 | 
						|
 | 
						|
} |