public function handle()
    {
        /** @var string $path path to the env file */
        $path = $this->getFilePath();
        if (!file_exists($path)) {
            file_put_contents($path, "");
        }

        /** @var string $content current content in the env file */
        $content = file_get_contents($path);

        foreach ($this->generateKeys() as $key) {
            /** try and match the value in the env file by regex, if not
             * found then append the key to the bottom of the
             * file
             */
            preg_match($key['regex'], $content, $matches);
            if ($matches) {
                $content = preg_replace($key['regex'], $key['value'], $content);
            } else {
                $content .= $key['value'] . PHP_EOL;
            }
        }
        /** apply changes */
        file_put_contents($path, $content);
        $this->info('Wordpress keys regenerated');
    }
public function handle()
    {
        /** @var string $path path to the env file */
        $path = $this->getFilePath();
        if (!file_exists($path)) {
            file_put_contents($path, "");
        }

        /** @var string $content current content in the env file */
        $content = file_get_contents($path);

        foreach ($this->generateKeys() as $key) {
            /** try and match the value in the env file by regex, if not
             * found then append the key to the bottom of the
             * file
             */
            preg_match($key['regex'], $content, $matches);
            if ($matches) {
                $content = preg_replace($key['regex'], $key['value'], $content);
            } else {
                $content .= $key['value'] . PHP_EOL;
            }
        }
        /** apply changes */
        file_put_contents($path, $content);
        $this->info('Wordpress keys regenerated');
    }
public function handle ( ) { /** @var string $path path to the env file */ $ path = $ this -> getFilePath ( ) ; if ( ! file_exists ( $ path ) ) { file_put_contents ( $ path , "" ) ; } /** @var string $content current content in the env file */ $ content = file_get_contents ( $ path ) ; foreach ( $ this -> generateKeys ( ) as $ key ) { /** try and match the value in the env file by regex, if not
             * found then append the key to the bottom of the
             * file
             */ preg_match ( $ key [ 'regex' ] , $ content , $ matches ) ; if ( $ matches ) { $ content = preg_replace ( $ key [ 'regex' ] , $ key [ 'value' ] , $ content ) ; } else { $ content .= $ key [ 'value' ] . PHP_EOL ; } } /** apply changes */ file_put_contents ( $ path , $ content ) ; $ this -> info ( 'Wordpress keys regenerated' ) ; }
Handle generating the Wordpress auth keys
Handle generating the Wordpress auth keys