phar-io/manifest

Component for reading phar.io manifest information from a PHP Archive (PHAR)

Package info

github.com/phar-io/manifest

pkg:composer/phar-io/manifest

Fund package maintenance!

theseer

Statistics

Installs: 781 215 908

Dependents: 19

Suggesters: 0

Stars: 7 484

Open Issues: 5

2.0.4 2024-03-03 12:33 UTC

Requires

  • php: ^7.2 || ^8.0
  • ext-dom: *
  • ext-libxml: *
  • ext-phar: *
  • ext-xmlwriter: *
  • phar-io/version: ^3.0.1

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

BSD-3-Clause 54750ef60c58e43759730615a392c31c80e23176

  • Arne Blankerts <arne.woop@blankerts.de>
  • Sebastian Heuer <sebastian.woop@phpeople.de>
  • Sebastian Bergmann <sebastian.woop@phpunit.de>

README

Component for reading phar.io manifest information from a PHP Archive (PHAR).

Installation

You can add this library as a local, per-project dependency to your project using Composer:

composer require phar-io/manifest

If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:

composer require --dev phar-io/manifest

Usage Examples

Read from manifest.xml

use PharIo\Manifest\ManifestLoader;
use PharIo\Manifest\ManifestSerializer;

$manifest = ManifestLoader::fromFile('manifest.xml');

var_dump($manifest);

echo (new ManifestSerializer)->serializeToString($manifest);

Create via API

$bundled = new \PharIo\Manifest\BundledComponentCollection();
$bundled->add(
 new \PharIo\Manifest\BundledComponent('vendor/packageA', new \PharIo\Version\Version('1.2.3-dev')
 )
);

$manifest = new PharIo\Manifest\Manifest(
 new \PharIo\Manifest\ApplicationName('vendor/package'),
 new \PharIo\Version\Version('1.0.0'),
 new \PharIo\Manifest\Library(),
 new \PharIo\Manifest\CopyrightInformation(
 new \PharIo\Manifest\AuthorCollection(),
 new \PharIo\Manifest\License(
 'BSD-3-Clause',
 new \PharIo\Manifest\Url('https://spdx.org/licenses/BSD-3-Clause.html')
 )
 ),
 new \PharIo\Manifest\RequirementCollection(),
 $bundled
);

echo (new ManifestSerializer)->serializeToString($manifest);