pulsestorm / pestle
A CLI framework for module based PHP code. Also has numerous Magento 2 code generation commands.
Installs: 4 684
Dependents: 0
Suggesters: 0
Security: 0
Stars: 533
Watchers: 41
Forks: 101
Open Issues: 184
Requires
- ext-xml: *
- abraham/twitteroauth: 0.7.2
- fzaninotto/faker: ^1.6.0
- michelf/php-markdown: 1.6.0
- nexmo/client: @beta
- pear/numbers_words: 0.18.1
Requires (Dev)
- magento/magento-coding-standard: ^4.0
- phing/phing: 2.*
- phpspec/prophecy: 1.7.0
- phpunit/phpunit: ^6.5
- dev-master
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/composer/guzzlehttp/psr7-1.9.1
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-astorm-patch-1
- dev-astorm/php-8
- dev-astorm/more-skips
- dev-astorm/issue-524
- dev-magento-1-generate-module
- dev-open-tracing
- dev-add-version-to-cache-hash
- dev-exclude-from-build
- dev-gitbash-paths
- dev-windows-home-path
- dev-issue-502-test-and-document-composer
- dev-issue-497-base-gen-folder
- dev-issue-420-theroy-of-operation
- dev-small-change
- dev-issue-416-input-output
- dev-issue-415-third-party-source
- dev-issue-419-pestle-build
- dev-issue-472-dev-env
- dev-local-travis
- dev-phpcs
- dev-474-import-from-sources
- dev-badge
- dev-other-module-folders
- dev-issue-387-add-fieldset
- dev-issue-379-add-field
- dev-issue-408-ui-form
- dev-issue-395-schema-add-column
- dev-issue-373-add-column
- dev-issue-411-ui-grid
- dev-no-x-men
- dev-issue-403-ui-node
- dev-issues-401-406
- dev-reorder-ui-components
- dev-issue-386-log-levels
- dev-issue-394-config-helper
- dev-issue-378-remove
- dev-issue-371-remove-named-node
- dev-further-reading-observers
- dev-issue-400-observer
- dev-issue-393-preference
- dev-issue-382-plugin-xml
- dev-issue-368-di
- dev-issue-396
- dev-issue-388-edit-controller-acl
- dev-issue-383
- dev-issue-374-acl
- dev-issue-405
- dev-issue-435
- dev-issue-380
- dev-issue-399
- dev-issue-389-view
- dev-issue-372-route
- dev-fix-setup-link
- dev-issue-390
- dev-issue-381
- dev-issue-370
- dev-issue-369-full-module
- dev-issue-423
- dev-issue-413-homepage
- dev-adding-links
- dev-doc_sprint_1
- dev-fixing-rtd
- dev-readthedocs
- dev-docs
- dev-ascii-table
- dev-general-cleanup
- dev-fix-acl-route
- dev-fix-readline
- dev-generic_parameter
- dev-php7_tests
- dev-better-function-parsing
- dev-function-name-test
- dev-container_not_block
This package is auto-updated.
Last update: 2024-12-19 22:58:29 UTC
README
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 git@github.com:astorm/pestle.git
- composer.phar install
- ./build.sh (which, in turn, calls the
phing
job that builds thephar
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
- Install Homebrew
- Run
$ brew install bash-completion
to install the bash-completion package - Enable the completion scripts by running
$ . /usr/local/etc/bash_completion
-- optionally adding this command (or a similar one) to your.bash_profile