File: example-02.php

package info (click to toggle)
php-phar-io-manifest 2.0.4-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 704 kB
  • sloc: php: 2,228; xml: 291; makefile: 10
file content (50 lines) | stat: -rw-r--r-- 1,479 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php declare(strict_types = 1);
/**
 * Thanks to @llaville for this example
 */
use PharIo\Manifest\ManifestSerializer;

require '/usr/share/php/PharIo/Manifest/autoload.php';

$bundledComponentCollection = new \PharIo\Manifest\BundledComponentCollection();
$bundledComponentCollection->add(
    new \PharIo\Manifest\BundledComponent(
        'vendor/packageA',
        new \PharIo\Version\Version('0.0.0-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(),
    $bundledComponentCollection
);

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

/*
 * Output produced
 *
<?xml version="1.0" encoding="UTF-8"?>
<phar xmlns="https://phar.io/xml/manifest/1.0">
    <contains name="vendor/package" version="1.0.0" type="library"/>
    <copyright>
        <license type="BSD-3-Clause" url="https://spdx.org/licenses/BSD-3-Clause.html"/>
    </copyright>
    <requires>
        <php version="*"/>
    </requires>
    <bundles>
        <component name="vendor/packageA" version="0.0.0-dev"/>
    </bundles>
</phar>
 */