PHPackages                             lalbert/bash-writer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lalbert/bash-writer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lalbert/bash-writer
===================

Write quickly and easily bash scripts with PHP

29PHP

Since Sep 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lalbert/php-bash-writer)[ Packagist](https://packagist.org/packages/lalbert/bash-writer)[ RSS](/packages/lalbert-bash-writer/feed)WikiDiscussions develop Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-bash-writer
===============

[](#php-bash-writer)

Write quickly and easily bash scripts with PHP.

PHP Bash Writer is not designed to run bash script but only to facilitate writing scripts by adding styles (color, bold, ...) on the output.

Internally it uses [symfony/console](https://github.com/symfony/console) to manage the color and styles (see [OutputFormatter](https://github.com/symfony/console/blob/master/Formatter/OutputFormatter.php)).

Installation
------------

[](#installation)

The best way to install PHP Bash Writer it use composer

```
composer require lalbert/bash-writer

```

Usage
-----

[](#usage)

```
$sh = new BashWriter();

$sh->addCommand('#!/bin/bash', ['print' => false]);

$sh->newLine(); // Add new blank line only in file, not on output
$sh->newLine(true); // Add new line on output (write "echo")

$sh->addCommand('cd $HOME'); // print 'cd /home/user' and run command
$sh->addCommand('ls -la', ['print' => 'List files in `(pwd)` folder']); // print 'List files in `(pwd)` folder' whith result of pwd in yellow, and run command

$sh->addCommand('touch file.txt'); // print 'touch file.txt' with 'file.txt' in yellow and bold, and run 'touch file.txt'
$sh->addCommand('echo "content file" > file.txt', ['print' => false]); // add content in file.txt, shows nothing

$sh->newLine(true);
$sh->output('Done'); // print "Done" in green text

// save script in script.sh file
file_put_contents('script.sh', $sh);
```

Now, the file `script.sh` contains the following script:

```
#!/bin/bash

echo
echo -e "cd $HOME"
cd $HOME
echo -e "List files in ^[[33m`(pwd)`^[[39m folder"
ls -la
echo -e "touch ^[[43;1mfile.txt^[[49;22m"
touch file.txt
echo "content file" > file.txt
echo
echo -e "^[[32mDone^[[39m"
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6500272?v=4)[lalbert](/maintainers/lalbert)[@lalbert](https://github.com/lalbert)

---

Top Contributors

[![lucalbert](https://avatars.githubusercontent.com/u/6500267?v=4)](https://github.com/lucalbert "lucalbert (16 commits)")

### Embed Badge

![Health badge](/badges/lalbert-bash-writer/health.svg)

```
[![Health](https://phpackages.com/badges/lalbert-bash-writer/health.svg)](https://phpackages.com/packages/lalbert-bash-writer)
```

###  Alternatives

[anubarak/craft-relabel

Relabel Plugin Craft

2869.8k](/packages/anubarak-craft-relabel)[thomascombe/backpack-async-export

This is a package to manage async export in Backpack for Laravel

1530.9k](/packages/thomascombe-backpack-async-export)[peterbrinck/nova-laravel-news

Adds a card to the Nova dashboard with the latest news from Laravel News

1712.0k](/packages/peterbrinck-nova-laravel-news)[indigotree/wp-bootstrap-nav-walker

WordPress Nav Walkers to implement Bootstrap navbars.

102.0k](/packages/indigotree-wp-bootstrap-nav-walker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
