Download the PHP package reactphp-x/unbash without Composer

On this page you can find all versions of the php package reactphp-x/unbash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package unbash

unbash

Fast, zero-dependency Bash parser for PHP. unbash turns Bash source into a typed, source-positioned AST without executing it.

This is a PHP port of webpro-nl/unbash (the original TypeScript parser by Lars Kappert). It mirrors the same AST shapes and parse() API.

Install

Requires PHP 8.1+ and has no runtime dependencies.

When to use unbash

Use unbash when your input is Bash source — a pasted command, a whole script, or shell embedded in JSON/YAML — and you need to inspect its structure without running it. It returns a typed, source-positioned AST.

Example use cases:

unbash does not execute code, perform shell expansion, provide a sandbox, or decide whether a command is safe. It is a tolerant parser: malformed or incomplete input yields a best-effort partial AST with source-positioned errors instead of throwing.

Usage

Result (abbreviated):

parse() returns a Node of type Script. Every node is a ReactphpX\Unbash\Node (a JSON-friendly object with a type discriminator and dynamic properties). Serialize the whole tree with json_encode($ast, ...).

You can also use the facade ReactphpX\Unbash\Unbash::parse($source).

Words, values, and parts

A Word (ReactphpX\Unbash\Word) holds:

Word-part types include Literal, SingleQuoted, DoubleQuoted, AnsiCQuoted, LocaleString, SimpleExpansion, ParameterExpansion, CommandExpansion, ArithmeticExpansion, ProcessSubstitution, ExtendedGlob, and BraceExpansion.

Positions and nested scripts

Positions are byte offsets forming half-open [pos, end) ranges in the source. Command and process substitutions are parsed recursively into nested Script nodes whose positions are absolute in the original source:

Parse errors inside a nested substitution surface on that nested script, not on the root — check errors on each nested script while traversing.

Errors

parse() never throws. Detected problems are collected on the Script's errors property as ReactphpX\Unbash\ParseError ({ message, pos }), and the parser still returns a best-effort partial tree.

Print

A basic, opinionated printer is included. It normalizes layout and does not preserve original whitespace or comments (except the shebang):

Supported syntax

unbash for PHP is validated against real-world scripts (nvm-install, rustup-init, neofetch, git-completion) which parse with zero errors.

Notes and limitations

Development

Tests

The suite includes the package's own tests plus a PHP port of the entire upstream webpro-nl/unbash test suite under tests/Reference/ — parser, quoting, word parts, pipelines, redirects, positions/offset, brace/extglob/process/command substitutions, parameter expansions, compound commands, [[ ]] test expressions, arithmetic, assignments, heredocs, deep nesting, error recovery, tokenizer, round-trip, plus the corpus-driven fixtures, tree-sitter-compat, and mvdan-sh-compat suites (the upstream fixture corpora are vendored under tests/fixtures/). The mvdan/sh corpus is checked against filetests_snapshot.txt (top-level command types).

A small number of reference cases that exercise behaviors this port does not model — some $() extent-scanner edge cases, escaped-backtick decoded source, per-construct depth-budget error messages, and reference-specific recovery of a few invalid/ambiguous inputs — are marked skipped with a reason.

Credits

Port of webpro-nl/unbash by Lars Kappert. See that project for the reference implementation and playground.

License

MIT


All versions of unbash with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package reactphp-x/unbash contains the following files

Loading the files please wait ...