PHPackages                             net\_bazzline/php\_component\_command - 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. [CLI &amp; Console](/categories/cli)
4. /
5. net\_bazzline/php\_component\_command

ActiveLibrary[CLI &amp; Console](/categories/cli)

net\_bazzline/php\_component\_command
=====================================

free as in freedom php component command is a thin and generic wrapper to easy up using system (shell) command usage

2.0.0(8y ago)210.1k3LGPL-3.0PHPPHP ~7.0

Since Dec 11Pushed 8y ago4 watchersCompare

[ Source](https://github.com/bazzline/php_component_command)[ Packagist](https://packagist.org/packages/net_bazzline/php_component_command)[ RSS](/packages/net-bazzline-php-component-command/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (17)Used By (3)

PHP Command Component
=====================

[](#php-command-component)

This free as in freedom project aims to deliver a easy to use php command component.

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/5df6c8a1caab9978a31ce2c9bcce66526145851feff07cfc2a50715a81657b4f/68747470733a2f2f7472617669732d63692e6f72672f62617a7a6c696e652f7068705f636f6d706f6e656e745f636f6d6d616e642e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/bazzline/php_component_command)[![Latest stable](https://camo.githubusercontent.com/ba20257f43f769769013c22c0973c9daf9a7b66047522feaad48dd0d12337b31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65745f62617a7a6c696e652f7068705f636f6d706f6e656e745f636f6d6d616e642e737667)](https://packagist.org/packages/net_bazzline/php_component_command)

The scrutinizer status are: [![code quality](https://camo.githubusercontent.com/7ce4f54e5d5b99d3227e0d7822cefa224a519217608f887b24861e63b84539f5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f636f6d6d616e642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_command/) | [![build status](https://camo.githubusercontent.com/10259b74f705b1207b13cd4e5a435b8f68e6149787ae9ab0ac780f5a164b0274/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f636f6d6d616e642f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_command/)

The versioneye status is: [![Dependency Status](https://camo.githubusercontent.com/717c9c71d6ea4ff08ac7fa269acf9c4eb8240a639f58a80f265e241e0f1ce499/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3534386465653261366538386634636534653030303165652f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/548dee2a6e88f4ce4e0001ee)

Take a look on [openhub.net](https://www.openhub.net/p/php_component_command).

The current change log can be found [here](https://github.com/bazzline/php_component_command/blob/master/CHANGELOG.md).

Usage
=====

[](#usage)

You can find a lot of examples [here](https://github.com/bazzline/php_component_command_collection/tree/master/example).

```
class Zip extends Command
{
    /**
     * @param string $archiveName
     * @param array $items
     * @return array
     * @throws RuntimeException
     */
    public function __invoke($archiveName, array $items)
    {
        return $this->zip($archiveName, $items);
    }

    /**
     * @param string $archiveName
     * @param array $items
     * @return array
     * @throws RuntimeException
     * @todo implement parameter validation
     */
    public function zip($archiveName, array $items)
    {
        $command = '/usr/bin/zip -r ' . $archiveName . ' ' . implode(' ' , $items);

        return $this->execute($command);
    }

    /**
     * @param string $pathToArchive
     * @param null|string $outputPath
     * @return array
     * @throws RuntimeException
     * @todo implement parameter validation
     */
    public function unzip($pathToArchive, $outputPath = null)
    {
        if (!is_null($outputPath)) {
            $command = '/usr/bin/unzip ' . $pathToArchive . ' -d ' . $outputPath;
        } else {
            $command = '/usr/bin/unzip ' . $pathToArchive;
        }

        return $this->execute($command);
    }

    /**
     * @param string $pathToArchive
     * @return array
     * @throws RuntimeException
     * @todo implement parameter validation
     */
    public function listContent($pathToArchive)
    {
        $command = '/usr/bin/unzip -l ' . $pathToArchive;

        return $this->execute($command);
    }

    /**
     * @throws InvalidSystemEnvironmentException
     */
    public function validateSystemEnvironment()
    {
        if (!is_executable('/usr/bin/zip')) {
            throw new InvalidSystemEnvironmentException(
                '/usr/bin/zip is mandatory'
            );
        }

        if (!is_executable('/usr/bin/unzip')) {
            throw new InvalidSystemEnvironmentException(
                '/usr/bin/unzip is mandatory'
            );
        }
    }
}

$zip = new Zip();

$pathToZipArchive = '/tmp/my.zip';

$zip->validateSystemEnvironment();

echo 'list archive content' . PHP_EOL;
$lines = $zip->listContent($pathToZipArchive);
foreach ($lines as $line) {
    echo $line . PHP_EOL;
}

echo 'unzip archive' . PHP_EOL;
$zip->unzip($pathToZipArchive, '/tmp/my_directory');

echo 'zip directory' . PHP_EOL;
//also valid call since we implemented __invoke
//$zip($pathToZipArchive, array('/tmp/my_directory'));
$zip->zip($pathToZipArchive, array('/tmp/my_directory'));
```

Install
=======

[](#install)

By Hand
-------

[](#by-hand)

```
mkdir -p vendor/net_bazzline/php_component_command
cd vendor/net_bazzline/php_component_command
git clone https://github.com/bazzline/php_component_command .

```

With Composer
-------------

[](#with-composer)

```
composer require net_bazzline/php_component_command:dev-master

```

Benefits
========

[](#benefits)

- easy and robust way of dealing with system commands
- return value validation by using exceptions
- hopefully the thinnest possible layer between system commands

API
===

[](#api)

[API](http://www.bazzline.net/deaff6d0a8004d2fe870434f0eda12b170111295/index.html) is available at [bazzline.net](http://www.bazzline.net).

Final Words
===========

[](#final-words)

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it :-D.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~218 days

Total

16

Last Release

3047d ago

Major Versions

1.2.2 → 2.0.02018-01-13

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

2.0.0PHP ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/58451b041f6f5a38c7e62762c96d01f5e2bcac30e322707fe4760a82bccb6856?d=identicon)[artodeto](/maintainers/artodeto)

---

Top Contributors

[![stevleibelt](https://avatars.githubusercontent.com/u/2287220?v=4)](https://github.com/stevleibelt "stevleibelt (90 commits)")

---

Tags

psrphpshelljobwrappercommandcomponentbazzlinelgplfree as in freedomPSR-4PHP7system command

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/net-bazzline-php-component-command/health.svg)

```
[![Health](https://phpackages.com/badges/net-bazzline-php-component-command/health.svg)](https://phpackages.com/packages/net-bazzline-php-component-command)
```

PHPackages © 2026

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