Create the Phar::GZ archive from a given directory. If no params, the current working directory is archived with the name of that directory. If one param, the current working directory will be archive with the name provided. If both params, the first is the name or path to the library to archive and the second is the name of the resulting archive
`li3 library archive my_archive` : archives current working directory to my_archive.phar.gz `li3 library archive myapp my_archive` : archives 'myapp' to 'my_archive.phar.gz'

Parameters

  • string $name if only param, the archive name for the current working directory otherwise, The library name or path to the directory to compress.
  • string $result if exists, The name of the resulting archive

Returns

boolean

Source

						public function archive($name = null, $result = null) {
		if (ini_get('phar.readonly') == '1') {
			throw new RuntimeException('Set `phar.readonly` to `0` in `php.ini`.');
		}
		$from = $name;
		$to = $name;

		if ($result) {
			$from = $name;
			$to = $result;
		}
		$path = $this->_toPath($to);

		if (file_exists("{$path}.phar")) {
			if (!$this->force) {
				$this->error(basename($path) . ".phar already exists in " . dirname($path));
				return false;
			}
			Phar::unlinkArchive("{$path}.phar");
		}
		try {
	 		$archive = new Phar("{$path}.phar");
		} catch (Exception $e) {
			$this->error($e->getMessage());
			return false;
		}
		$result = null;
		$from = $this->_toPath($from);

		if (is_dir($from)) {
			$result = (boolean) $archive->buildFromDirectory($from, $this->filter);
		}
		if (file_exists("{$path}.phar.gz")) {
			if (!$this->force) {
				$this->error(basename($path) . ".phar.gz already exists in " . dirname($path));
				return false;
			}
			Phar::unlinkArchive("{$path}.phar.gz");
		}
		if ($result) {
			$archive->compress(Phar::GZ);
			$this->out(basename($path) . ".phar.gz created in " . dirname($path) . " from {$from}");
			return true;
		}
		$this->error("Could not create archive from {$from}");
		return false;
	}