PHPackages                             wpkg/wpkg-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. wpkg/wpkg-php

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

wpkg/wpkg-php
=============

WPKG config generator on PHP

0.4.2(8y ago)0241MITPHPPHP &gt;=7.0

Since Sep 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/wpkg/wpkg-php)[ Packagist](https://packagist.org/packages/wpkg/wpkg-php)[ Docs](https://wpkg.org/)[ RSS](/packages/wpkg-wpkg-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (5)Versions (17)Used By (0)

[![WPKG Logo](https://camo.githubusercontent.com/1039c7ffa1404ed29341f9c63989778ad99f7154f4e5db6182e974a318811946/68747470733a2f2f77706b672e6f72672f77706b672e706e67)](https://camo.githubusercontent.com/1039c7ffa1404ed29341f9c63989778ad99f7154f4e5db6182e974a318811946/68747470733a2f2f77706b672e6f72672f77706b672e706e67)

WPKG XML configuration generator
================================

[](#wpkg-xml-configuration-generator)

Library written on PHP7 for generating XML files with configuration for WPKG installer.

```
composer require drteam/wpkg-php

```

Check [links](#some-links) for more info about WPKG.

If you need Active Directory support for generation `hosts.xml` from domain PCs you can look at [WPKG-AD project](https://github.com/wpkg/wpkg-php-ad), which based on this library.

Table of Contents
=================

[](#table-of-contents)

- [How to create XML](#how-to-create-xml)
    - [Config](#config)
        - [Config.xml file](#configxml-file)
        - [Note about translations](#note-about-translations)
    - [Hosts](#hosts)
        - [Single host](#single-host)
        - [Hosts.xml file](#hostsxml-file)
        - [Computers from Active Directory](#computers-from-active-directory)
    - [Profiles](#profiles)
        - [Single profile](#single-profile)
        - [Profiles.xml file](#profilesxml-file)
    - [Packages](#packages)
        - [Single package](#single-package)
        - [Packages.xml file](#packagesxml-file)
- [How to import existed XML](#how-to-import-existed-xml)
    - [Import Config.xml file](#import-configxml-file)
- [Get Support](#get-support)
- [Some links](#some-links)

How to create XML
=================

[](#how-to-create-xml)

Some examples with descriptions you can find [here](extra).

Config
------

[](#config)

Configuration settings for runtime behavior of *wpkg.js*

### *Config.xml* file

[](#configxml-file)

Using the Config class, you can override the settings, if you specified a value different from the default value, your parameter will be added to the XML file.

If you do not specify anything, a configuration with default parameters will be generated.

```
$_config = new \WPKG\Config();

// Overwrite some attributes
$_config
    ->with('wpkg_base', 'http://example.com')
    ->with('quitonerror', true)
    ->with('debug', true);

// Now we can set the variables
$_config
    ->withVariable('PROG_FILES32', "%ProgramFiles%", null, "x86")
    ->withVariable('PROG_FILES32', "%ProgramFiles(x86)%", null, "x64")
    ->withVariable('DESKTOP', "%ALLUSERSPROFILE%\Desktop", "Windows xp")
    ->withVariable('DESKTOP', "%PUBLIC%\Desktop", "Windows 7");

// Show current variant of generated XML
echo $_config->show();
```

Result of execution:

```

    ... a lot of lines with translations ...

```

### Note about translations

[](#note-about-translations)

At the moment, translations (creators of the WPKG project call them languages) are available for the following languages:

- English
- French
- German
- Italian
- Russian (added by me)
- Spanish

Translations was taken from the *config.xml* file that was in the [wpkg-1.3.1-bin.zip](http://wpkg.org/files/stable/1.3.x/wpkg-1.3.1-bin.zip)archive from the official website of the [WPKG project](https://wpkg.org/Download).

All available translations of *wpkg-php* you can find [here](src/Languages).

If you do not see your language on the list and want to help the project, then you can suggest your translation variant via [issues](https://github.com/DrTeamRocks/wpkg-php/issues) or **PR**. Pay attention to LCID, these are unique language identifiers, a complete list of them you can find [here](http://www.microsoft.com/globaldev/reference/lcid-all.mspx).

Hosts
-----

[](#hosts)

Mappings between machine names and profile names.

### Single host

[](#single-host)

If you want generate few hosts in separated files:

```
// Root container
$_host = new \WPKG\Host();

// Need to add some parameters
$_host
    ->with('name', 'host1')
    ->with('profile-id', 'profile1');

echo $_host->show();
```

Result is:

```

```

You also can set array of profiles:

```
// Root container
$_host = new \WPKG\Host();

// Need to add some parameters
$_host
    ->with('name', 'host1')
    ->with('profile-id', ['profile1', 'profile2', 'profile3']);

echo $_host->show();
```

And in result must be:

```

```

### Hosts.xml file

[](#hostsxml-file)

If you need one large file with all your hosts:

```
// Root container
$_hosts = new Hosts();

/**
 * Test host #1
 */
$host1 = new Host();
$host1
    ->with('name', 'host1')
    ->with('profile-id', 'profile1');

$_hosts->setHost($host1);

/**
 * Test host #2
 */
$host2 = new Host();
$host2
    ->with('name', 'host2')
    ->with('profile-id', ['profile1', 'profile2', 'profile3']);

$_hosts->setHost($host2);

/**
 * Test host #3
 */
$host3 = new Host();
$host3
    ->with('name', 'host3')
    ->with('profile-id', 'profile3');

$_hosts->setHost($host3);

echo $_hosts->show();
```

Result file *hosts.xml* into the **wpkg\_path** folder

```

```

### Computers from Active Directory

[](#computers-from-active-directory)

This class based on [adLdap library](https://github.com/adldap/adLDAP), so you can use any configuration parameters from this library.

Basic usage:

```
use \WPKG\Drivers\ADImport;

// Read AD configuration
$_config = include __DIR__ . '/adldap.php';

// Set Import object for work and put configuration inside
$_import = new ADImport($_config);

// You also can set config via specific method
//$_import->setConfig($_config);

// Choose work mode (only hosts available) and output the XML
$_hosts = $_import->import('hosts');
$out = $_hosts->show();

print_r($out);
```

You should saw something like this:

```

```

Profiles
--------

[](#profiles)

Specifies which packages will be installed/executed for each WPKG profile.

### Single profile

[](#single-profile)

If you want generate few profiles in separated files:

```
use WPKG\Profile;

$_profile = new \WPKG\Profile();

$_profile
    ->with('id', 'profile1')
    ->with('packages', 'DotNet')
    ->with('depends', 'profile2');

// Show current variant of generated config
echo $_profile->show();
```

Result file (with name like .xml, eg profile1.xml like in current example) you can find into the **wpkg\_path**/profiles/ subfolder:

```

```

You as in hosts also can set array of `packages` or `depends`.

### Profiles.xml file

[](#profilesxml-file)

If you need one large file with all your profiles:

```
$_profiles = new \WPKG\Profiles();

/**
 * Test profile #1
 */
$pr1 = new Profile();
$pr1->with('id', 'profile1');

$_profiles->setProfile($pr1);

/**
 * Test profile #2
 */
$pr2 = new Profile();
$pr2->with('id', 'profile2')
    ->with('packages', 'DotNet');

$_profiles->setProfile($pr2);

/**
 * Test profile #3
 */
$pr3 = new Profile();
$pr3->with('id', 'profile3')
    ->with('packages', ['Firefox', 'Chromium', 'Opera'])
    ->with('depends', 'profile1');

$_profiles->setProfile($pr3);

/**
 * Test profile #4
 */
$pr4 = new Profile();
$pr4->with('id', 'profile4')
    ->with('packages', ['SuperBank', 'AnotherBank'])
    ->with('depends', ['profile1', 'profile2']);

$_profiles->setProfile($pr4);

/**
 * Test profile #5
 */
$pr5 = new Profile();
$pr5->with('id', 'profile5')
    ->with('depends', 'profile3');

$_profiles->setProfile($pr5);

// Show current variant of generated config
echo $_profiles->show();
```

Result:

```

```

Packages
--------

[](#packages)

Defines software packages (commands for WPKG to install/uninstall programs, etc.)

### Single package

[](#single-package)

If you want generate few packages in separated files:

```
use \WPKG\Package;
use \WPKG\PackageCheckExits;

$_package = new Package();
$_exits = new PackageCheckExits();

// Overwrite the attributes of tha class
$_package
    ->with('id', 'wpkg1')
    ->with('name', 'Windows Packager sample 1')
    ->with('revision', 1)
    ->with('priority', 0)
    ->with('reboot', 'false');

// Small check for Windows 7
$_package
    ->withCheck('registry', 'exists', 'HKLM\Software\wpkg\full\key\not\part\of\it')
    ->withCheck('file', 'exists', 'C:\wpkg\wpkg.bat')
    ->withCheck('uninstall', 'exists', 'WPKG 0.6-test1');

// Add few variables to package config
$_package
    ->withVariable('PROG_FILES32', "%ProgramFiles(x86)%", null, "x64")
    ->withVariable('DESKTOP', "%ALLUSERSPROFILE%\Desktop", "Windows xp");

// We need set exit codes for some installation stages
$_exits
    ->add(0)
    ->add(3010, true)
    ->add('any')
    ->add(2);

// Run command
$_package
    ->withCommand('install', 'msiexec /i /qn "%SOFTWARE%\path\to\msi"', 'test', $_exits)
    ->withCommand('remove', 'msiexec /x /qn "%SOFTWARE%\path\to\msi"')
    ->withCommand('upgrade', 'msiexec /i /qn "%SOFTWARE%\path\to\msi"')
    ->withCommand('downgrade', null, 'remove')
    ->withCommand('downgrade', null, 'install');

echo $_package->show();
```

Result:

```

```

### Packages.xml file

[](#packagesxml-file)

If you need one large file with all your packages:

```
use \WPKG\Package;
use \WPKG\PackageCheckExits;
use \WPKG\Packages;

// Root container
$_packages = new Packages();

/**
 * Test package #1
 */
$pk1 = new Package();
$pk1->with('id', 'time')
    ->with('name', 'Time Synchronization')
    ->with('priority', 100)
    ->with('execute', 'always')
    ->withCheck('host', 'os', 'windows 7')
    ->withCommand('install', 'net time \\timeserver /set /yes');

$_packages->setPackage($pk1);

/**
 * Test package #2
 */
$pk2 = new Package();
$pk2_exits = new PackageCheckExits();

// We need set exit codes for some installation stages
$pk2_exits
    ->add(0)
    ->add(3010, true)
    ->add('any')
    ->add(2);

$pk2->with('id', 'wpkg')
    ->with('name', 'Windows Packager sample 1')
    ->with('revision', 1)
    ->with('priority', 0)
    ->with('reboot', 'false')
    ->withCheck('registry', 'exists', 'HKLM\Software\wpkg\full\key\not\part\of\it')
    ->withCheck('file', 'exists', 'C:\wpkg\wpkg.bat')
    ->withCheck('uninstall', 'exists', 'WPKG 0.6-test1')
    ->withCommand('install', 'msiexec /i /qn "%SOFTWARE%\path\to\msi"', 'test', $pk2_exits)
    ->withCommand('remove', 'msiexec /x /qn "%SOFTWARE%\path\to\msi"')
    ->withCommand('upgrade', 'msiexec /i /qn "%SOFTWARE%\path\to\msi"')
    ->withCommand('downgrade', null, 'remove')
    ->withCommand('downgrade', null, 'install');

$_packages->setPackage($pk2);

/**
 * Test package #3
 */
$pk3 = new Package();
$pk3->with('id', 'time3')
    ->with('name', 'Time Synchronization')
    ->with('priority', 100)
    ->with('execute', 'always')
    ->withCheck('host', 'os', 'windows 7')
    ->withCommand('install', 'net time \\timeserver /set /yes');

$_packages->setPackage($pk3);

echo $_packages->show();
```

Result:

```

```

How to import existed XML
=========================

[](#how-to-import-existed-xml)

Import Config.xml file
----------------------

[](#import-configxml-file)

First you need enable the importer class

```
use \WPKG\Drivers\XMLImport;

// Create new object
$_import = new XMLImport();

// Content of hosts file
$_hosts_file = file_get_contents('config.xml');

// Read and parse file to normal format
$_hosts = $_import->import($_hosts_file);

// Print array to stdOut
print_r($_hosts);
```

Now inside `$_hosts` variable you can find the [\\WPKG\\Hosts](#hostsxml-file) object with all hosts which was imported.

Same operation for all other configurations, library can check which config you are loaded.

Get Support!
============

[](#get-support)

- [Discord](https://discord.gg/vRjVfHK) - Join us on Discord.
- [GitHub Issues](https://github.com/wpkg/wpkg-php/issues) - Got issues? Please tell us!
- [Roadmap](https://github.com/wpkg/wpkg-php/wiki) - Want to contribute? Get involved!

Some links
==========

[](#some-links)

- Main the WPKG website -
- WPKG documentation page -
- Article on Wikipedia - [https://en.wikipedia.org/wiki/WPKG\_(software)](https://en.wikipedia.org/wiki/WPKG_(software))

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Recently: every ~1 days

Total

16

Last Release

2992d ago

PHP version history (2 changes)0.0.1-alpha1PHP &gt;=5.6

0.1.1PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/30aaf0db0441cada5c2d80127a9123e7f6f4091f7faf79d3f13001ef379373f4?d=identicon)[EvilFreelancer](/maintainers/EvilFreelancer)

---

Top Contributors

[![EvilFreelancer](https://avatars.githubusercontent.com/u/9089568?v=4)](https://github.com/EvilFreelancer "EvilFreelancer (64 commits)")

---

Tags

generatorwpkgxmlxmlwpkg

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wpkg-wpkg-php/health.svg)

```
[![Health](https://phpackages.com/badges/wpkg-wpkg-php/health.svg)](https://phpackages.com/packages/wpkg-wpkg-php)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[sabre/xml

sabre/xml is an XML library that you may not hate.

52832.2M131](/packages/sabre-xml)[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
