Skip to content

version 1.0.3 of command component for php released

I am happy to announce the release of 1.0.3 of bazzlines command component for php. This component will easy up the usage of system commands.
Major improvement is the public method "validateSystemEnvironment". You should use this (maybe in your factory) to validate if the system environment is valid (e.g. "/usr/bin/ls" exists and is executable). An exception should be thrown, so you can easily track back the source of the validation error.
Enjoy it.

version 1.0.2 of command component for php released

I am happy to announce the release of 1.0.2 of bazzlines command component for php. This component will easy up the usage of system commands.
Indeed, I missed to announce 1.0.0, but you know, christmas is hard time and this component is really a small one.
This project aims to deliver a easy to use php command component. It adds a very thin layer but hopefully adds a lot of usage and handling benefits :-).

Usage


usage Net\Bazzline\Component\Command\Command;

class Zip extends Command
{
    /** 
     * @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);
    }
}

$zip = new Zip();

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

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;
$zip->zip($pathToZipArchive, array('/tmp/my_directory'));

How to install?

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 Packagist


composer require net_bazzline/php_component_command:dev-master

version 1.0.0 of process pipeline component for php released

I happy to announce the release of 1.0.0 of bazzlines process pipeline component for php. This component will easy up the creation of process pipe.

Indeed, it is a pseudo pipeline (process collection or process batch) since the php process is single threaded so far.

Special thanks to Ralf Westphal and especially for his book the architects napkin.

Why?

  • separate complex operations into simpler
  • easy up unit testing for smaller processes
  • separate responsibility (data generator/transformer/validator/flow manipulator)
  • create process chains you can read in the code (separate integration code from operation code)
  • no dependencies (except you want to join the development team)

How to use?


use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;

try {
    $pipe = new Pipe();

    $pipe->pipe(
        new ProcessOne(), 
        new ProcessTwo()
    );

    $output = $pipe->execute($input);
} catch (ExecutableException) {
    //handle process exception
} catch (InvalidArgumentException) {
    //handle pipe exception
}

How to install?

By Hand


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

With Packagist


composer require net_bazzline/php_component_process_pipe:dev-master