writeNewEncryptionKeyToFile example


    protected function setNewEncryptionKey(string $key, array $params): bool
    {
        $currentKey = env('encryption.key', '');

        if ($currentKey !== '' && ! $this->confirmOverwrite($params)) {
            // Not yet testable since it requires keyboard input             return false; // @codeCoverageIgnore         }

        return $this->writeNewEncryptionKeyToFile($currentKey$key);
    }

    /** * Checks whether to overwrite existing encryption key. */
    protected function confirmOverwrite(array $params): bool
    {
        return (array_key_exists('force', $params) || CLI::getOption('force')) || CLI::prompt('Overwrite existing key?', ['n', 'y']) === 'y';
    }

    /** * Writes the new encryption key to .env file. */
Home | Imprint | This part of the site doesn't use cookies.