定制 pulsestorm/pestle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pulsestorm/pestle

Composer 安装命令:

composer require pulsestorm/pestle

包简介

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

README 文档

README

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

#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

pulsestorm/pestle 适用场景与选型建议

pulsestorm/pestle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.69k 次下载、GitHub Stars 达 532, 最近一次更新时间为 2016 年 09 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pulsestorm/pestle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pulsestorm/pestle 我们能提供哪些服务?
定制开发 / 二次开发

基于 pulsestorm/pestle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 532
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 532
  • Watchers: 41
  • Forks: 97
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-06