PHP Classes

Package Builder: Build a RPM or DEB package from Composer project

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 120 All time: 9,502 This week: 140Up
Version License PHP version Categories
package-builder 1.4BSD License5.3PHP 5, Tools, Unix
Description 

Author

This package can be use to build a RPM or DEB package from Composer project.

It takes the name of package in a Composer repository and extracts the files to build a package file to be installed on Linux systems.

The packages can generated in either the RPM or DEB formats.

Innovation Award
PHP Programming Innovation award nominee
July 2015
Number 11
Composer provides a means to install PHP packages from repositories.

However, for Linux distributions, sometimes it is more convenient to distribute and install packages in the native Linux distribution format.

This package can create RPM or DEB package files to be installed on Linux systems from packages taken from a Composer repository.

Manuel Lemos
Picture of Sergey Vanyushin
  Performance   Level  
Name: Sergey Vanyushin is available for providing paid consulting. Contact Sergey Vanyushin .
Classes: 15 packages by
Country: Russian Federation Russian Federation
Age: 28
All time rank: 57216 in Russian Federation Russian Federation
Week rank: 23 Up4 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 15x

Winner: 2x

Documentation

Package Builder

Command-line utility that builds a package from composer project.

Composer packacge Latest Stable Version Build Status Latest Unstable Version License

What it does

  1. PackageBuilder creates a package for your current OS (in fact, for your distributive): deb (for Debian-based) or rpm (for Fedora-based). You can install it package or share to other people.
  2. All files of your package will be installed in /usr/lib/[package name] folder.
  3. To all binaries (specified in `bin` section of `composer.json`) will be made symbolic links and placed in /usr/local/bin/. That way you will be able use them like any other system program.

Package type

By default, utility uses os detection to decide what format of package should be used.

For now, it supports following package formats: deb* - uses automatically on Debian installation. You can force using this format by adding --type deb in console. rpm* - uses automatically on Fedora installation. You can force using this format by adding --type rpm in console.

How to package your project

  1. Create clean and lite version of your package. For this manual let's take a mythical package `taifun/tornado`:
    mkdir package-build && cd package-build
    composer create-project --prefer-dist --no-dev taifun/tornado .
    
  2. Install Package Builder globally. Skip this step if you have done this before.
    composer global require wapmorgan/package-builder
    
  3. Add another path of autoloader in your binaries. All files of your package will be placed in /usr/lib/[package name]/ folder, so composer autoloader will be available by /usr/lib/[package name]/vendor/autoload.php path. [package name] is not the same as composer package name. You can use any that is not used in your system. For demonstrating purposes let's use `simplepackage`.
    $paths = [
        __DIR__.'/../vendor/autoload.php',
        __DIR__.'/../autoload.php',
        __DIR__.'/../../../autoload.php',
        '/usr/lib/simplepackage/vendor/autoload.php', // this line added
        ];
    
    function init_composer(array $paths) {
        foreach ($paths as $path) {
            if (file_exists($path)) {
                require_once $path;
                return true;
            }
        }
        return false;
    }
    
    if (!init_composer($paths)) die('Run `composer install` firstly.'.PHP_EOL);
    
  4. Launch a Packaging Wizard. It will ask for additional information and finally build a package and store it in one-level above directory.
    pbuilder build .
    

A resulting ready-to-install deb or rpm-package will be stored in file ../simplepackage-version.deb or ../simplepackage-version-release.rpm.

FAQ

  1. Why do I need to package php scripts?

    May be you want to take control of all files on your PC and just like your package manager.

  2. What preinstalled steps is needed to build a package?

    * On Debian-based:

    - Install packages: ```sh build-essential ```

    * On Fedora-based:

    - Install build packages: - @development-tools - fedora-packager - rpmdevtools - Create build tree: ```sh rpmdev-setuptree ```

  3. Can I build a package with different type than my OS uses?

    No, PackageBuilder uses system commands like `dpkg` and `rpmbuild` to create a package.


  Files folder image Files (9)  
File Role Description
Files folder imagebin (1 file)
Files folder imagesrc (1 file, 1 directory)
Files folder imagetests (1 file)
Plain text file .travis.yml Data Auxiliary data
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE.md Data Auxiliary data
Plain text file README.md Doc. Documentation

  Files folder image Files (9)  /  bin  
File Role Description
  Plain text file pbuilder Appl. Script that calls the class

  Files folder image Files (9)  /  src  
File Role Description
Files folder imageApplication (2 files)
  Plain text file PackageConfiguration.php Class Class source

  Files folder image Files (9)  /  src  /  Application  
File Role Description
  Plain text file Application.php Class Class source
  Plain text file BuildCommand.php Class Class source

  Files folder image Files (9)  /  tests  
File Role Description
  Plain text file BuildCommandTest.php Test Unit test script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:120
This week:0
All time:9,502
This week:140Up