2017 © Pedro Pelรกez
 

library packager

Packager is a PHP 5.2+ library to concatenate libraries split in multiple files in a single file. It automatically calculates dependancies. Packager requires a yml header syntax in every file, and a package.yml manifest file, as seen on the MooTools project.

image

yfix/packager

Packager is a PHP 5.2+ library to concatenate libraries split in multiple files in a single file. It automatically calculates dependancies. Packager requires a yml header syntax in every file, and a package.yml manifest file, as seen on the MooTools project.

  • Tuesday, December 2, 2014
  • by yfix
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3,036 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 31 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Packager

Packager is a PHP 5.2+ library to concatenate libraries split in multiple files in a single file. It automatically calculates dependancies. Packager requires a yml header syntax in every file, and a package.yml manifest file, as seen on the MooTools project., (*1)

Packager API

Constructor

The constructor of this class accepts either a path to a package or a list of path to packages. package.yml must not be included in the path., (*2)

Example

$pkg = new Packager("/Users/kamicane/Sites/mootools-core/");
$pkg = new Packager(array("/Users/kamicane/Sites/mootools-core/", "/Users/kamicane/Sites/mootools-more/"));

Adding a manifest

  • parse_manifest ยป adds a manifest to this instance

Working with files

Getters

  • get_all_files ยป gets an list of all files
  • get_file_dependancies ยป gets an ordered list of every file that this file depends on
  • get_file_path ยป gets the file path
  • get_file_source ยป gets the file source
  • get_file_description ยป gets the file description
  • get_file_provides ยป gets a list of the file provided components

Converters

  • complete_file ยป converts a single file to an ordered list of files
  • complete_files ยป converts a list of files to an ordered list of files

Generators

  • build_from_files ยป returns a string containing the source of the selected files and their dependancies
  • write_from_files ยป writes a file with the selected files and their dependancies

Working with components

Converting to files

  • component_to_file ยป gets the name of the file that provides this component
  • components_to_files ยป converts a list of components to a list of files

Generators

  • build_from_components ยป returns a string containing the source of the selected components and their dependancies
  • write_from_components ยป writes a file with the selected components and their dependancies

Class usage

Syntax

$pkg = new Packager(`$path_to_manifest`);

Example

$pkg = new Packager("/Users/kamicane/Sites/mootools-core/");

$pkg->write_from_components("/Users/kamicane/Sites/mootools.js", array('Type', 'Array'));

Packager Command Line script

The Packager command line script is your one-stop solution to build any of your packages at once. Works on unices., (*3)

Syntax

./packager COMMAND +option1 argument1 argument2 +option2 argument1 argument2
  • COMMAND a packager command (required)
  • +option options for commands (optional)

Commands

  • register registers a package. Creates a .packages.yml file in your home folder.
  • unregister unregisters a package
  • list list registered packages
  • build builds a single file with the supplied packages / files / components

Registering a Package

Example

./packager register /Users/kamicane/mootools-core
ยป the package Core has been registered

Listing Packages

Example

./packager list
ยป Core: /Users/kamicane/mootools-core

Unregistering a Package

Example

./packager unregister Core
ยป the package Core has been unregistered

Building Packages

Examples

./packager build Core/Type Core/Fx ART/ART.Element

Which is the same as..., (*4)

./packager build +components Core/Type Core/Fx ART/ART.Element

Which builds the passed in components (and their dependancies) using your registered packages., (*5)

./packager build +files Core/Core Core/Fx ART/ART

This builds the passed in files (and their dependancies) using your registered packages., (*6)

./packager build ART/*

Builds every component from ART, and their dependancies, using your registered packages., (*7)

./packager build SomePackage/SomeComponent +packages /Users/kamicane/Sites/some-package

Builds the selected components using your registered packages and a temporary package that resides in /Users/kamicane/Sites/some-package, without having to register it first., (*8)

./packager build SomePackage/SomeComponent -packages Core

Builds the selected components using your registered packages minus the package names you pass to -packages. This lets you build your components without dependancies., (*9)

./packager build ART/SomeComponent +use-only ART

Builds the selected components using only ART of your registered packages. This lets you build your components without dependancies., (*10)

./packager build SomePackage/SomeComponent +use-only +packages /Users/kamicane/Sites/some-package

Builds the selected components using none of your registered packages plus the passed in package, without registering it. This lets you build your components without dependancies., (*11)

./packager build +components ART/ART +files ART/ART.Base

You can mix components and files, (*12)

./packager build Core/* > mootools.js

This is how you output to a file, (*13)

The Versions

02/12 2014

dev-master

9999999-dev https://github.com/yfix/packager

Packager is a PHP 5.2+ library to concatenate libraries split in multiple files in a single file. It automatically calculates dependancies. Packager requires a yml header syntax in every file, and a package.yml manifest file, as seen on the MooTools project.

  Sources   Download

MIT

The Requires

  • php >=5.2

 

javascript package mootools