/** * getIO * * @return IO */ public static function getIO() { if (!static::$io) { static::$io = new IO(); } return static::$io; }
/** * @param Event $event */ public static function addSalts(Event $event) { static::$root = dirname(dirname(__DIR__)); static::$envFilePath = static::$root . '/.env'; static::$io = $event->getIO(); $generate_salts = false; // Only add new/regenerate salts if we are doing a fresh install and specify "yes" to the question. // This way the salts aren't cleared whenever a `composer install` is done on deploy. if (static::$io->isInteractive()) { $generate_salts = static::$io->askConfirmation('<info>Generate salts and append to .env file?</info> [<comment>Y,n</comment>]? ', true); } // No need to continue - exit. if (!$generate_salts) { return; } // Open the file for writing. $handle = fopen(static::$envFilePath, 'a'); $keys = []; // Get the salt keys. foreach (static::$saltKeys as $key) { $keys[] = static::getEnvVar($key, Installer::generateSalt()); } // Append additional keys to the .env file/keys array. foreach (static::setEnvironmentVariables() as $key => $val) { $keys[] = static::getEnvVar($key, $val); } if ($handle) { fwrite($handle, implode($keys, "\n")); fclose($handle); } }
/** * Activate the Composer plugin. * * @since 0.1.0 * * @param Composer $composer Reference to the Composer instance. * @param IOInterface $io Reference to the IO interface. */ public function activate(Composer $composer, IOInterface $io) { static::$io = $io; if (static::$io->isVerbose()) { static::$io->write(_('Activating PHP Composter plugin'), true); } $installer = new Installer(static::$io, $composer); $composer->getInstallationManager()->addInstaller($installer); $filesystem = new Filesystem(); $this->cleanUp($filesystem); $this->linkBootstrapFiles($filesystem); $this->createGitHooks($filesystem); }