/** * Saves auth.json file * * @param string $username * @param string $password * @return bool * @throws \Exception */ public function saveAuthJson($username, $password) { $authContent = [self::KEY_HTTPBASIC => [$this->getCredentialBaseUrl() => [self::KEY_USERNAME => "{$username}", self::KEY_PASSWORD => "{$password}"]]]; $json = new JsonModel($authContent); $json->setOption('prettyPrint', true); $jsonContent = $json->serialize(); return $this->getDirectory()->writeFile(DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile, $jsonContent) && $this->getDirectory()->changePermissions(DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile, \Magento\Framework\Filesystem\DriverInterface::WRITEABLE_FILE_MODE); }
/** * Saves auth.json file * * @param string $username * @param string $password * @return bool * @throws \Exception */ public function saveAuthJson($username, $password) { $authContent = [self::KEY_HTTPBASIC => [$this->getCredentialBaseUrl() => [self::KEY_USERNAME => "{$username}", self::KEY_PASSWORD => "{$password}"]]]; $json = new JsonModel($authContent); $json->setOption('prettyPrint', true); $jsonContent = $json->serialize(); return $this->getDirectory()->writeFile(DirectoryList::COMPOSER_HOME . DIRECTORY_SEPARATOR . $this->pathToAuthFile, $jsonContent); }
/** * Saves auth.json file * * @param string $username * @param string $password * @return bool * @throws \Exception */ public function saveAuthJson($username, $password) { $directory = $this->filesystem->getDirectoryWrite(DirectoryList::COMPOSER_HOME); $authContent = [PackagesAuth::KEY_HTTPBASIC => [$this->getCredentialBaseUrl() => [PackagesAuth::KEY_USERNAME => "{$username}", PackagesAuth::KEY_PASSWORD => "{$password}"]]]; $json = new \Zend\View\Model\JsonModel($authContent); $json->setOption('prettyPrint', true); $jsonContent = $json->serialize(); return $directory->writeFile(self::PATH_TO_AUTH_FILE, $jsonContent); }