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.

Translate to de es fr it pt ja

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' . PHPEOL; $lines = $zip->listContent($pathToZipArchive); foreach ($lines as $line) { echo $line . PHPEOL; }

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

echo 'zip directory' . PHPEOL; $zip->zip($pathToZipArchive, array('/tmp/mydirectory'));

How to install?

By Hand


mkdir -p vendor/netbazzline/phpcomponentcommand
cd vendor/netbazzline/phpcomponentcommand
git clone https://github.com/bazzline/phpcomponentcommand .

With Packagist


composer require netbazzline/phpcomponent_command:dev-master
Translate to de es fr it pt ja