/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile); if (!empty($this->stubPath)) { $phar->setStub(file_get_contents($this->stubPath)); } else { if (!empty($this->cliStubFile)) { $cliStubFile = $this->cliStubFile->getPathWithoutBase($this->baseDirectory); } else { $cliStubFile = null; } if (!empty($this->webStubFile)) { $webStubFile = $this->webStubFile->getPathWithoutBase($this->baseDirectory); } else { $webStubFile = null; } $phar->setDefaultStub($cliStubFile, $webStubFile); } if ($this->metadata === null) { $this->createMetaData(); } if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } if (!empty($this->alias)) { $phar->setAlias($this->alias); } return $phar; }
/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile); if ($this->signatureAlgorithm == Phar::OPENSSL) { // Load up the contents of the key $keyContents = file_get_contents($this->key); // Attempt to load the given key as a PKCS#12 Cert Store first. if (openssl_pkcs12_read($keyContents, $certs, $this->keyPassword)) { $private = openssl_pkey_get_private($certs['pkey']); } else { // Fall back to a regular PEM-encoded private key. // Setup an OpenSSL resource using the private key // and tell the Phar to sign it using that key. $private = openssl_pkey_get_private($keyContents, $this->keyPassword); } $phar->setSignatureAlgorithm(Phar::OPENSSL, $private); // Get the details so we can get the public key and write that out // alongside the phar. $details = openssl_pkey_get_details($private); file_put_contents($this->destinationFile . '.pubkey', $details['key']); } else { $phar->setSignatureAlgorithm($this->signatureAlgorithm); } if (!empty($this->stubPath)) { $phar->setStub(file_get_contents($this->stubPath)); } else { if (!empty($this->cliStubFile)) { $cliStubFile = $this->cliStubFile->getPathWithoutBase($this->baseDirectory); } else { $cliStubFile = null; } if (!empty($this->webStubFile)) { $webStubFile = $this->webStubFile->getPathWithoutBase($this->baseDirectory); } else { $webStubFile = null; } $phar->setDefaultStub($cliStubFile, $webStubFile); } if ($this->metadata === null) { $this->createMetaData(); } if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } if (!empty($this->alias)) { $phar->setAlias($this->alias); } return $phar; }
/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile); $phar->setSignatureAlgorithm($this->signatureAlgorithm); /* * File compression, if needed. */ if (Phar::NONE != $this->compression) { $phar->compressFiles($this->compression); } $phar->setDefaultStub($this->cliStubFile, $this->webStubFile); if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } return $phar; }
/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile); $phar->setSignatureAlgorithm($this->signatureAlgorithm); if (isset($this->stubPath)) { $phar->setStub(file_get_contents($this->stubPath)); } else { $phar->setDefaultStub($this->cliStubFile->getPathWithoutBase($this->baseDirectory), $this->webStubFile->getPathWithoutBase($this->baseDirectory)); } if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } if (!empty($this->alias)) { $phar->setAlias($this->alias); } return $phar; }
/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile); if ($this->signatureAlgorithm == Phar::OPENSSL) { // Load up the contents of the key $keyContents = file_get_contents($this->key); // Setup an OpenSSL resource using the private key and tell the Phar // to sign it using that key. $private = openssl_pkey_get_private($keyContents, $this->keyPassword); $phar->setSignatureAlgorithm(Phar::OPENSSL, $private); // Get the details so we can get the public key and write that out // alongside the phar. $details = openssl_pkey_get_details($private); file_put_contents($this->destinationFile . '.pubkey', $details['key']); } else { $phar->setSignatureAlgorithm($this->signatureAlgorithm); } if (isset($this->stubPath)) { $phar->setStub(file_get_contents($this->stubPath)); } else { if (!empty($this->cliStubFile)) { $cliStubFile = $this->cliStubFile->getPathWithoutBase($this->baseDirectory); } else { $cliStubFile = null; } if (!empty($this->webStubFile)) { $webStubFile = $this->webStubFile->getPathWithoutBase($this->baseDirectory); } else { $webStubFile = null; } $phar->setDefaultStub($cliStubFile, $webStubFile); } if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } if (!empty($this->alias)) { $phar->setAlias($this->alias); } return $phar; }
/** * Build and configure Phar object. * * @return Phar */ private function buildPhar() { $phar = new Phar($this->destinationFile, 0, $this->alias); $phar->setSignatureAlgorithm($this->signatureAlgorithm); /* * File compression, if needed. */ if (Phar::NONE != $this->compression) { $phar->compressFiles($this->compression); } if (isset($this->customStubPath)) { $phar->setStub(file_get_contents($this->customStubPath)); } else { $phar->setDefaultStub($this->cliStubFile, $this->webStubFile); } if ($metadata = $this->metadata->toArray()) { $phar->setMetadata($metadata); } if (!empty($this->alias)) { $phar->setAlias($this->alias); } return $phar; }
/** * @return string|array */ public function toArray() { return empty($this->elements) ? $this->value : parent::toArray(); }