Skip to content

version 1.1.1 php component cli readline

I am happy to announce the release of 1.1.1 of bazzlines cli readline component for php.
Important changes are:
Since Version 1.1.1

  • fixed bug in nested arrays and dealing with closures
Since Version 1.1.0
  • removed unused DebugManager
  • moved from project namespace "Autocomplete" to "Readline"
Since Version 1.0.0
  • initial release

Whats so super cool about this component? Creating a php command line script with autocomplete was never that easy!

Translate to de es fr it pt ja

version 1.5.2 php component csv released

I am happy to announce the release of 1.5.3 of bazzlines csv component for php.
Important changes are:
Since Version 1.5.2

Since Version 1.5.1
  • updated dependency
Since Version 1.5.0
Since Version 1.4.0
  • started cli example to easy up usage
  • added "rewind" call when using reader::readAll() and reader::readMany()
Translate to de es fr it pt ja

version 1.3.0. php component csv released

I am happy to announce the release of 1.3.0 of bazzlines csv component for php.
Important changes are:
Since Version 1.3.0

  • added headline output support as keys for Reader::readMany()
  • added headline output support as keys for Reader::readOne()
    • can be disabled by Reader::disableAddHeadlineToOutput()
    • can be enabled by Reader::enableAddHeadlineToOutput()
    • is enabled by default
  • fixed broken unit test for php 5.3
  • moved complex array combine into own project
  • removed duplicated code in Reader
Since Version 1.2.0
Since Version 1.1.0
  • added link to api
  • added minimum php version requirement
  • implemented "move($path)" method into Writer
  • removed "TODO"
  • updated dependencies
Translate to de es fr it pt ja

version 1.0.0. php component csv released

I am happy to announce the release of 1.0.0 of bazzlines csv component for php.
Benefits

  • works with PHP 5.3 and above
  • __invoke() implemented to use it as function
  • unified reader and writer
  • adapter to easy up migration from EasyCsv - 0.0.1 to this component
  • reader
    • implemented iterator
    • readOne();
    • readMany();
    • readAll();
  • writer
    • truncate();
    • delete();
    • copy();
    • writeOne();
    • writeMany();
    • writeAll(); //truncates file and writes content

Translate to de es fr it pt ja

version 1.0.0 of php component cli argument released

I am happy to annoucen the release of 1.0.0 of bazzlines cli argument component for php.
Benefits

  • easy up handling of following kinds of arguments
    • flags (command -f|--force)
    • lists (command --foobar=foo | command -f=foo)
    • values values (command )

Example
A simple call to the shipped "run.php" with the following arguments:

php run.php --foo bar --foobar=foo --foobar="bar" -f="foo" -f=bar -b foobar foo -flag
Generates the following output:

arguments provided:
    --foo
    bar
    --foobar=foo
    --foobar=bar
    -f=foo
    -f=bar
    -b
    foobar
    foo
    -flag
flags provided:
    foo
    b
    f
    l
    a
    g
lists provided:
    foobar
        foo
        bar
    f
        foo
        bar
values provided:
    bar
    foobar
    foo

Translate to de es fr it pt ja

version 1.1.0 of php component requirement released

I happy to announce the release of 1.1.0 of bazzlines requirement component for php. Important changes are:

  • added example WithDisabledCondition
  • added example WithDisabledItem
  • added getConditions() method to RequirementInterface - this easies up disabling single conditions or single items (by using condition->getItems())
  • added migration howto
  • added version eye and scrutinizer coverage
  • covered AbstractItem and AbstractCondition with unit test
  • created AbstractItem that implements ItemInterface
  • created IsDisabledInterface
  • created ItemInterface
  • created TestCase that is extended by all phpunit tests
  • implemented IsDisabledInterface to AbstractCondition
  • implemented IsDisabledInterface to Requirement
  • refactored ConditionInterface, addItem now only accepts ItemInterface instead of IsMetInterface
  • refactored Condition::getItems() - now returns plain php array
  • renamed ConditionAbstract to AbstractCondition
  • renamed and updated previous WithShutdown example to WithDisabledRequirement
  • updated dependencies
Translate to de es fr it pt ja

version 1.0.1 of process pipeline component for php released

I happy to announce the release of 1.0.1 of bazzlines process pipeline component for php. Important changes are:

  • removed dependecy to apigen
  • add "StopExecutionException"
Translate to de es fr it pt ja

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

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/netbazzline/phpcomponentprocesspipe
cd vendor/netbazzline/phpcomponentprocesspipe
git clone https://github.com/bazzline/phpcomponentprocesspipe

With Packagist


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

version 1.0.0 of php locator generator component released

I happy to announce the release of 1.0.0 of bazzlines locator generator component for php.

What is it good for?

  • adds back implicit api calls to your locator ("getMyObject()" instead of "get('MyObject')")
  • configuration based driven, update your configuration and generate a new locator
  • generated code is easy to debug
  • generated code is easy to understand (no magic inside)
  • generate a locator out of your propel1 schema.xml

How ca I use it?


cd 
php bin/generateLocator.php example/ArrayConfiguration/configuration.php
ls data/
vim data/FromArrayConfigurationFileLocator.php

How can I install it?

with packagist


composer require netbazzline/phpcomponentlocatorgenerator:dev-master

manuel


mkdir -p vendor/netbazzline/phpcomponentlocatorgenerator
cd vendor/netbazzline/phpcomponentlocatorgenerator
git clone https://github.com/bazzline/phpcomponentlocator_generator
Translate to de es fr it pt ja

version 1.0.1 of php time limit manager component released

I happy to announce the release of 1.0.1 of bazzlines time limit manager component for php. Important changes are:

  • add getRuntimeIn[Seconds|Minutes|Hours]
  • extended unit tests by covering setting of the buffer
  • added getter for minutes and hours
  • updated dependencies
Translate to de es fr it pt ja

version 1.0.3 of php memory limit manager component released

I happy to announce the release of 1.0.3 of bazzlines memory limit manager component for php. Important changes are:

  • added versioneye
  • added scrutinizer
  • fixed small bugs
  • updated dependencies
  • fixed broken composer.json
Translate to de es fr it pt ja

PHP Proxy Logger Component - Put Back Some Freedom And Silence In You Logs

So what is this component all about?
Basically it is a self developed "Proxy Logger" for php. Furthermore, this projects extends the proxy logger with an buffer and again with a trigger to flush or clean this buffer.

What does a "Proxy Logger" for php mean? It means a proxy for all loggers which implements the "PSR-3 Logger Interface". The proxy forwards all log requests to all attached loggers.
By using the provided "Buffer Logger", you are able to manipulate the forwarding of the log requests to all attached loggers.
Additionally, you can manipulate the buffering itself by using the available "Buffer Manipulators". This enables the possibility to set a trigger for log level to regulate the forwarding of all log requests to all attached loggers.

By the time of this writing, the component is shipped with two manipulators, the "BypassBuffer" and the "FlushBufferTrigger".
You can use the "Bypass Buffer" to regulate which log level bypasses the buffer and are forwarded directly to all attached loggers. The "Flush Buffer Trigger" enables the way to mark a log level as trigger. If this log level is triggerd, the buffer will be flushed which means that all buffered log requests are forwarded to all attached loggers.

After writing about all the fundamental knowledge, lets move on to the "Upward Flush Buffer". The upward flush buffer extends the idea of a triggerd buffer flush by the concept of triggering this flush also if a log level of a higher priority is called. To keep it short, you can define "if at least this log level is called, flush the buffer".

The whole component is shipped with a log of examples.
Since the upward flush buffer trigger is the crown jewel of the component, i want to quote the output of the upward flush buffer trigger versus normal logger example.


----------------------------------------
First run with normal logger without log level restriction.
----------------------------------------
[1381003509] [debug] [processing id 1]
[1381003509] [info] [collection information and data id: 1]
[1381003509] [debug] [done]
[1381003509] [debug] [processing id 3]
[1381003509] [info] [collection information and data id: 3]
[1381003509] [info] [data can not handled with this process, queueing data to manual processing list]
[1381003509] [debug] [done]
[1381003509] [debug] [processing id 8]
[1381003509] [info] [collection information and data id: 8]
[1381003509] [info] [logical problem in data on key 3]
[1381003509] [notice] [trying to recalculate data]
[1381003509] [info] [setting data value of key 7 to default]
[1381003509] [debug] [finished]
[1381003509] [debug] [processing id 4]
[1381003509] [info] [collection information and data id: 4]
[1381003509] [debug] [done]
[1381003509] [debug] [processing id 5]
[1381003509] [info] [collection information and data id: 5]
[1381003509] [info] [logical problem in data on key 6]
[1381003509] [notice] [trying to recalculate data]
[1381003509] [warning] [setting data value of key 7 to default not possible]
[1381003509] [notice] [trying to revert modification]
[1381003509] [error] [runtime data and data in storage differs, can not revert modification]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 5]
[1381003509] [debug] [done]
[1381003509] [debug] [processing id 6]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 6]
[1381003509] [debug] [done]
----------------------------------------
Second run with normal logger and log level restriction to warning and above.
----------------------------------------
[1381003509] [warning] [setting data value of key 7 to default not possible]
[1381003509] [error] [runtime data and data in storage differs, can not revert modification]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 5]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 6]
----------------------------------------
Third run with manipulate buffer logger.
----------------------------------------
[1381003509] [debug] [processing id 5]
[1381003509] [info] [collection information and data id: 5]
[1381003509] [info] [logical problem in data on key 6]
[1381003509] [notice] [trying to recalculate data]
[1381003509] [warning] [setting data value of key 7 to default not possible]
[1381003509] [notice] [trying to revert modification]
[1381003509] [error] [runtime data and data in storage differs, can not revert modification]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 5]
[1381003509] [debug] [processing id 6]
[1381003509] [critical] [lost connection to storage]
[1381003509] [alert] [can not unlock and schedule processing to id 6]

What does this example show you?
The example shows typical log entries generated by a process that is dealing with a bunch of data.
"First run" is the regular massiv number of entries you have to deal with when you are running you logger without restrictions.
As you can see, it takes some time to figure out if something important happens. Even to find the place where something important happens is hard to find. The "second run" is an example when you run you logger in the restriction of "only log level of warning or above".
First of all, you notice that no debug or info messages are logged. But what is bad about that? You either miss important informations (like the process or data id) or you have to flood your logs with all informations for each log request.
Finally, the "third run" shows what i mean when i am writing about "putting back freedom and silence in your log files". The logger only logs when a critical log level is reached and provides all available informations. If nothing bad happens, nothing will be logged. Quite nice, isn't it?
If a part of the data is processed, the buffer is cleaned when nothing happens. If an important log level is triggerd, the buffer is flushed and all collected log requests are forwarded to all attached loggers.

If you find bugs, bad namings, ugly code, have ideas to improve this component, pull your code or became a participant :-).

Translate to de es fr it pt ja

Disable your requirement, configuration based - php component requirement 1.0.5 released

I'm happy to announce the new release 1.0.5 of my requirement component for php.

This version resolves a feature request (the first official one by the way :-D). With version 1.0.5, you are now able to shutdown a requirement. This leads to the fact that the requirement is not evaluating its internal collections or items. Instead, it returns "true" immediately.

This version is shipped with an example so take a look into it.

Translate to de es fr it pt ja

Easy Up Migration From Existing Log4Php Applications To Psr Logger Applications

It is a bit mean to put such a headline on top, but thats the current status we have to deal with at our company. I also don't want to bash somebody, Log4Php is doing its job in a great way. But since i developed a proxy logger component, i want to use it. The proxy logger component can work with psr logger interface, so i need to create a adapter to get it used ;-).

The psr and log4php adapter is a easy component and provides only two classes.

  • Log4Php to Psr Logger Bridge
  • Psr Logger to Log4PhP Bridge
  • Log4Php Logger Interface

The usage is simple, depending on the way you either choose the adapter "Log4PhpToPsrLoggerAdapter" or "PsrToLog4PhpAdapter". The only drawback, you are loosing the "trace" log level of log4php and all the fancy stuff of a log4php logger. This component is simple and has just a few lines of code (you are welcome to join), so the main focus is to support the log level methods like "$logger->warn()" and not more.

Translate to de es fr it pt ja

create simple and reusable validators using the php requirement component - php component requirement 1.0.4 released

I updated the requirement component to 1.0.4. The new version contains the validator example. By creating this example, i added two new features for upcoming releases, so stay tuned :-).

The example is shipped with a validator collection which contains all needed validator items. It would definitely make more sense, if you would name that validator collection more specific like "IsValidTableForGermany" (or "IsValidUserName" if you want to switch context). All validator items need a injected table example class. Since the requirement component is dealing with automatically injection, you don't have to take care about this :-).

As you can see in the example class, all you have to do is to inject the item you want to validate and call "isMet()". The example itself creates a bunch of tables by choosing random properties.

What are the benefits of using the requirement component also for validation? Reusable and simple testable validator items and a endless flexibility of item combination by using the power of existing and and or condition.

  • add example to use the component as validator

Enjoy it :-).

Translate to de es fr it pt ja

web - tips and tricks about php filehandling and handling json files

While developing an example for the heartbeat component, i run into problems dealing with file handling in php. The problem comes from race conditions by reading and writing (updating) the same files. I must admit, it still needs some time to solve this problem in a sufficient way, but i'm on it.
Nevertheless, two shiny links where found by my preferred search engine and it would be a shame to not share them.

The first link has the title handling json like a boss in php. The page shows you how to encode and decode json files in php. What i liked very much, it also contains an error handling part. Shame on my side, i was not aware of the jsonlasterror function, now i am :-).

The second link headlines itself PHP File-handling tips and tricks and it contains a lot. I like, that the author puts back the SPLFileObject and SPLFileInfo into the limelight.
Even better, i wasn't aware of the available stream "php://temp". Thank you both!

Translate to de es fr it pt ja

php component requirement 1.0.3 released

Version 1.0.3 of the requirement component for php is released. Changes are listed below.

  • add caching for magic __call condition in abstract method to not iterate over each item (invalid cache if new item is add)
  • Refactored locking by using <a href="https://packagist.org/packages/netbazzline/componentlock title="lock component php">lock component

Enjoy it :-).

Translate to de es fr it pt ja