• Stars
    star
    532
  • Rank 83,377 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A collection of command line scripts for Magento 2 code generation, and a PHP module system for organizing command line scripts.

Build Status Documentation Status

What is Pestle?

Pestle is

  • 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.

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.

How to Use

The easiest way to get started is to grab the latest build using curl

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

You can see a list of commands with the following

php pestle.phar list-commands

and get help for a specific command with

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

  • git checkout [email protected]: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.

#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

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

Try removing the following temp folder.

/tmp/pestle_cache

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

Example Command

Try

$ pestle.phar generate_module

from a Magento 2 sub-directory to get an idea of what we're doing here.

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

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

And then import pestle code via native PHP namespaces to your heart's content.

//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.

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.

Want to learn more? We'll be using the wiki for documentation until we outgrow it.

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.

$ 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.

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

  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

More Repositories

1

Pulsestorm

Collection of Magento Tools from Pulse Storm LLC
PHP
125
star
2

MagentoTarToConnect

A small shell script to automatically package tar archives into Magento's Connect 2.0 format.
PHP
80
star
3

magento2-travis

An example travis configuration for getting a Magento 2 enviornment up and running
43
star
4

MagentoBetter404

A programmer's 404 page for the Magento Ecommerce system.
PHP
42
star
5

MagentoAttributeMigrationGenerate

A Magento shell script to automatically create an attribute migration script for a specific attribute. This allows developers to tweak their attributes in the UI, and then generate a script for deployment.
PHP
38
star
6

magento-layout-no-frills

Repo for the Creative Commons published No Frills Magento Layout
HTML
34
star
7

Configlint

A system for running validation tests against Magento's configuration files
PHP
34
star
8

LayoutViewer

A Magento module that dumps layout information via query string.
PHP
26
star
9

MagentoTinyMCEConfig

Module allowing you to add additional configuration elements to Magento's TinyMCE implementation.
PHP
25
star
10

PulsestormLauncher

The fastest way to browse your Magento admin interface.
HTML
25
star
11

wp-static-html-output-plugin

A WP CLI plugin that exposes functionality from the "WP Static HTML Output" Plugin
PHP
24
star
12

Magento_CrossAreaSessions

Research module providing a manager for accessing admin sessions from the frontend, and vice/versa.
PHP
23
star
13

magento2-hello-world

A simple Hello World model for Magento 2 MVVM (or MVVM like) system.
PHP
21
star
14

magento2-simple-ui-component

Base configuration for the most simple ui component.
PHP
16
star
15

Job-Queue

A PHP job queue implemented using Zend Framework's messasing queue
PHP
15
star
16

magento2-tutorial-objectmanager1

Sample code for the first article in my Magento Object Manager series
PHP
13
star
17

nofrills2

Starting Code Module for No Frills Magento 2 Layout
PHP
13
star
18

SystemConfigurationSearch

A Magento module allowing users to quickly search for specific configuration fields, quickly cutting through the dense UI.
PHP
13
star
19

PulsestormModuleList

A Magento module that lists other installed modules.
PHP
12
star
20

Chaos

A Magento module that randomly changes configuration values — useful for developers who want to write bullet proof extensions.
PHP
12
star
21

CustomerPage

A Magento module that demonstrates how to add a new page to the customer My Account section.
PHP
12
star
22

LayoutUnremove

A Magento extension that adds an `<unremove/>` tag to Magento's Layout XML.
PHP
10
star
23

magento-composer-json-corpus

This repository contains a corpus of composer.json files from Magento modules hosted on packagist.org.
8
star
24

magento2-pestle-platonic-module-output

An attempt to create a simple, "perfect as possible", Magento 2 module we can target for code generation.
PHP
7
star
25

magento2-tutorial-objectmanager-arguments

Repository for sample code from my Object Manager tutorial
PHP
6
star
26

MagentoSessionAreaBug

A module demonstrating Magento's problems with sessions, area, and early events.
PHP
6
star
27

magento2-tutorial-objectpreference1

Tutorial module for Magento 2's object manager's preferences system
PHP
6
star
28

DeveloperManual

A Magento module for browsing block action methods, PHP Doc blocks, and more!
PHP
5
star
29

module-new-relic-patch

Fixes Deployment Flood from Magento 2 systems
PHP
4
star
30

laravel-slack-invite

Simple Laravel App for Slack Invites
PHP
4
star
31

magento2-tutorial-objectmanager-virtual-types

Sample code for the Magento 2 virtualTypes tutorial
PHP
4
star
32

service-contract-example

An example of a "service contract" module in Magento 2
PHP
4
star
33

magento2-tutorial-objectmanager2

Support module for Object Manager/Dependency Injection Tutorial
PHP
4
star
34

magento2-requirejs-example1

Simple Example of a RequireJS Module in Magento 2
PHP
4
star
35

magento2-tutorial-plugin

Boilerplate module for Plugin tutorial
PHP
3
star
36

mgql-experimental

Experimental repo -- this is an awful idea.
JavaScript
3
star
37

pulsestorm-launcher-wordpress

A Launcher/QuickNav Plugin for Wordpress
PHP
3
star
38

magento2-tutorial-instance-objects

Sample code for the Instance Objects article
PHP
3
star
39

magento2-tutorial-proxy-objects

Starter code for the Magento 2 proxy object tutorial
PHP
3
star
40

blackboard-soap-client

A PHP client library for Blackboard 9's Soap API
PHP
2
star
41

magento-2-pulsestorm-cliexample

PHP
1
star
42

docker-helper

JavaScript
1
star
43

magento2-example-no-layout-sequence

PHP
1
star