2017 © Pedro Peláez
 

library pestle

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

image

pulsestorm/pestle

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  • Monday, July 9, 2018
  • by alanstorm
  • Repository
  • 42 Watchers
  • 361 Stars
  • 2,707 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 67 Forks
  • 132 Open issues
  • 29 Versions
  • 8 % Grown

The README.md

Build Status Documentation Status, (*1)

What is Pestle?

Pestle is, (*2)

  • A PHP Framework for creating and organizing command line programs
  • An experiment in implementing python style module imports in PHP
  • A collection of command line programs, with a primary focus on Magento 2 code generation

Pestle grew out of my desire to do something about the growing number of simple PHP scripts in my ~/bin that didn't have a real home, and my personal frustration with the direction of PHP's namespace system., (*3)

PHP doesn't need another command line framework. Symfony's console does a fine job of being the de-facto framework for building modern PHP command line applications. Sometimes though, when you start off building something no one needed, you end up with something nobody realized they wanted., (*4)

How to Use

The easiest way to get started is to grab the latest build using curl, (*5)

curl -LO http://pestle.pulsestorm.net/pestle.phar

You can see a list of commands with the following, (*6)

php pestle.phar list-commands

and get help for a specific command with, (*7)

php pestle.phar help generate_module

If you want to build your own phar, we've got a phing build.xml file setup so all you should need to do to build a stand alone pestle.phar executable is, (*8)

  • git checkout git@github.com:astorm/pestle.git
  • composer.phar install
  • ./build.sh (which, in turn, calls the phing job that builds the phar

If you're interested in working on the framework itself, you can use the runner.php in the project root. I personally use it by dropping the following in my ~/bin., (*9)

#File: ~/bin/pestle_dev
#!/usr/bin/env php
<?php
require_once('/Users/alanstorm/Documents/github/astorm/pestle/runner.php');

Troubleshooting Upgrades

If you've upgraded pestle and you're seeing the following exception, (*10)

PHP Fatal error: Cannot redeclare Pulsestorm\Magento2\Cli\Help\pestle_cli(), (*11)

Try removing the following temp folder., (*12)

/tmp/pestle_cache

We know this isn't ideal, and we're working on a more permanat fix., (*13)

Example Command

Try, (*14)

$ pestle.phar generate_module

from a Magento 2 sub-directory to get an idea of what we're doing here., (*15)

How to Use Pestle Code in your Application

Pestle and the pestle_import function are a bit of an experiment, and you probably don't want to run code from module.php files directly in your PHP based application. Fortunately, we have a solution for you -- with every release of pestle we build a composer compatible autoloader in library/autoloader.php. This loads the entire pestle library structure as a single PHP file with proper block-namespaces (currently library/all.php). This means you can include pestle in your Composer based projects with, (*16)

"require": {
    "pulsestorm/pestle": "1.0.*"
}

And then import pestle code via native PHP namespaces to your heart's content., (*17)

//include is probably not neccesary, usually handled by your framework
include 'vendor/autoload.php';
\Pulsestorm\Pestle\Library\output("Hello World");

Our specific strategy around this may change in the future, but our plan is for these sorts of changes to be user-transparent. If we ever split the generated library into multiple files, or figure out a sane way to incorporate pestle_import into native PHP code and you're using this project as a composer library — those changes should be transparent to you., (*18)

Do you have strong options about this sort of compilation/"transpiling"/module-importing? We'd love to have you involved in the project. Yell at us in a GitHub issues and/or pull request., (*19)

Want to learn more? We'll be using the wiki for documentation until we outgrow it., (*20)

Experimental Tab Completion

Pestle includes an experimental tab completion script. If used with your system's bash_completion sub-system, this script will allow use the [tab] key to auto-complete command names., (*21)

$ pestle.phar magento2:generate:ui: (press the tab key)
add-column-text    add-schema-column  form
add-form-field     add-to-layout      grid

Just copy or symlink the pestle-autocomplete.sh file to your bash_completion.d folder and you'll be good to go., (*22)

If you're running MacOS or MacOS X, you'll need to install the modern version of bash_completion via Homebrew (or your package manager of choice). Yes, this is super annoying. We found these instructions useful in late mid-2018. The simplified instructions are, (*23)

  1. Install Homebrew
  2. Run $ brew install bash-completion to install the bash-completion package
  3. Enable the completion scripts by running $ . /usr/local/etc/bash_completion -- optionally adding this command (or a similar one) to your .bash_profile

The Versions

09/07 2018

1.4.3

1.4.3.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/07 2018

dev-master

9999999-dev

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/07 2018

dev-fix-acl-route

dev-fix-acl-route

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/07 2018

dev-fix-readline

dev-fix-readline

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2018

dev-generic_parameter

dev-generic_parameter

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2018

dev-php7_tests

dev-php7_tests

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/01 2018

dev-other-module-folders

dev-other-module-folders

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/01 2018

dev-better-function-parsing

dev-better-function-parsing

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/01 2018

dev-function-name-test

dev-function-name-test

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/11 2017

dev-container_not_block

dev-container_not_block

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/08 2017

1.4.2

1.4.2.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/06 2017

1.4.1

1.4.1.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/06 2017

1.4.0

1.4.0.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2017

1.3.2

1.3.2.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/04 2017

1.3.1

1.3.1.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/03 2017

1.3.0

1.3.0.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2017

1.2.1

1.2.1.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

11/03 2017

1.2.0

1.2.0.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/02 2017

1.1.2

1.1.2.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/02 2017

1.1.1

1.1.1.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

15/02 2017

1.1

1.1.0.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/01 2017

1.0.7

1.0.7.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

24/12 2016

1.0.6

1.0.6.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/09 2016

1.0.4

1.0.4.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/09 2016

1.0.5

1.0.5.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/09 2016

1.0.3

1.0.3.0

A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/09 2016

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

06/09 2016

1.0.1

1.0.1.0

  Sources   Download

The Requires

 

The Development Requires

06/09 2016

1.0.0

1.0.0.0

  Sources   Download

The Requires

 

The Development Requires