PHPackages                             revati/packager - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. revati/packager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

revati/packager
===============

Composer package builder template

020PHP

Since Feb 8Pushed 11y ago1 watchersCompare

[ Source](https://github.com/revati/packager)[ Packagist](https://packagist.org/packages/revati/packager)[ RSS](/packages/revati-packager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Packager
========

[](#packager)

This package provides template for creating packages.

Installation
------------

[](#installation)

Install this package globally to access from anywhere

```
composer global require revati/packager=dev-master

// Update path
export PATH=~/.composer/vendor/bin:$PATH

```

Now you can call `packager` from your terminal.

First of all you have to initialize package. It will create ~/.Packager folder.

```
packager init

```

Usage
-----

[](#usage)

Out of the box packager does not come with any predefined templates. So you have to define them your self. To create template you have two options - generate from folder structure or fetch template config file (TODO: How to share generated template config files?).

To create template config file from directory cd in in it and run

```
packager template:make template-name

```

Now to use this template you can run

```
packager new my-awesome-package template-name

```

It will initialize package in `my-awesome-package` directory.

See [Simple example](#simple-example) for more detailed info.

### Variables

[](#variables)

Those variables can be used with in files and in directory and file names. Currently are supported 6 variables:

- **author\_name** - Author name (defined with author command or on init)
- **author\_email** - Author email (defined with author command or on init)
- **package\_name** - Package name (first argument when creating new command)
- **package\_description** - Package description (can be passed as option when creating package),
- **package\_class** - Package name (in CamelCase),
- **author\_class** - Author name (in CamelCase),

All variables are prefixed and suffixed with two underscores (that's why they are bold).

TODO
----

[](#todo)

- Figure out a way to share template config files.
    - `template:share template-name` command to upload template config file somewhere?
- Ability to run some custom scripts (git init, composer install...) after package is initialized
- Ability to initialize package in per template predefined custom subdirectory.
    - runing package initialization from project root, but create package under ./packages directory.
- Ability to create raw template from config file, for template editing purposes.
- Ability to pull composer packages, but not in vendor directory, but as main package, for editing purposes.

Simple example
--------------

[](#simple-example)

Create new directory. With in it create new composer.json file.

```
{
  "name": "__author_name__/__package_name__",
  "description": "__package_description__",
  "authors": [
    {
      "name": "__author_name__",
      "email": "__author_email__"
    }
  ],
  "autoload": {
    "psr-4": {
      "__author_class__\\__package_class__\\": "src/"
    }
  },
}

```

Lets create `src` directory and with in `__package_class__Class.php` with fallowing content.

```
