2017 © Pedro Peláez
 

library packager

Composer package builder template

image

revati/packager

Composer package builder template

  • Tuesday, February 17, 2015
  • by revati
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Packager

This package provides template for creating packages., (*1)

Installation

Install this package globally to access from anywhere, (*2)

composer global require revati/packager=dev-master

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

Now you can call packager from your terminal., (*3)

First of all you have to initialize package. It will create ~/.Packager folder., (*4)

packager init

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?)., (*5)

To create template config file from directory cd in in it and run, (*6)

packager template:make template-name

Now to use this template you can run, (*7)

packager new my-awesome-package template-name

It will initialize package in my-awesome-package directory., (*8)

See Simple example for more detailed info., (*9)

Variables

Those variables can be used with in files and in directory and file names. Currently are supported 6 variables:, (*10)

  • 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)., (*11)

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.
  • [x] ~~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

Create new directory. With in it create new composer.json file., (*12)

{
  "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., (*13)

<?php namespace __author_class__\__package_class__;

class __package_class__Class extends SomeClass {

    // Code
}

Now when template is done lets make its configuration file., (*14)

packager template:make simple-template

Template is ready. To use it run, (*15)

packager new simple-package simple-template

It will create simple-package directory. It will contain composer.json file with fallowing content:, (*16)

{
  "name": "revati/simple-package",
  "description": "",
  "authors": [
    {
      "name": "revati",
      "email": "email@email.com"
    }
  ],
  "autoload": {
    "psr-4": {
      "Revati\\SimplePackage\\": "src/"
    }
  }
}

There also will be src folder with SimplePackageClass.php file. And its content will be:, (*17)

<?php namespace Revati\SimplePackage;

class SimplePackageClass extends SomeClass {

    // Code
}

Hope this example helps. In Variables section you can find all available variables., (*18)

The Versions

17/02 2015

dev-refactoring

dev-refactoring

Composer package builder template

  Sources   Download

MIT

The Requires

 

by Roberts Gulans

08/02 2015

dev-master

9999999-dev

Composer package builder template

  Sources   Download

MIT

The Requires

 

by Roberts Gulans