PHPackages                             vosiz/va-tools - 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. vosiz/va-tools

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

vosiz/va-tools
==============

PHP tools (from Variable Arts)

v1.8.3(6mo ago)044MITPHPPHP &gt;=7.4

Since Jan 26Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/vosiz/va-tools)[ Packagist](https://packagist.org/packages/vosiz/va-tools)[ RSS](/packages/vosiz-va-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (24)Used By (0)

va-tools
========

[](#va-tools)

PHP tools to ease work

Important notes
---------------

[](#important-notes)

Used namespace: Vosiz\\VaTools"particular-part"

F.e. to use Retval class (general/root):

```
use Vosiz\VaTools\Retval;
```

Other examples...

```
use Vosiz\VaTools\Structure\Credentials;
use Vosiz\VaTools\Db\DbConnectionConfig;
use Vosiz\VaTools\Db\DbConnection;
```

See "tests" folder to inspire.

Contains
--------

[](#contains)

### "General"

[](#general)

- Signal - intensity class
- Retval - Return value handling
- Shorties - simple php/c-like function for shortcuts

### Parser

[](#parser)

- URL parser - class to parse and structure URL

### Structure

[](#structure)

- credentials class
- node hierarchy class
- flag system classes

### Filter

[](#filter)

- data filtration classes

### Debug

[](#debug)

- broswer dumper
- recursion detection

### Database

[](#database)

- database connection
- database config
- database query builder
- database connection info

Plan/roadmap
------------

[](#planroadmap)

What is the plan?

- - db - database (connection, config + CRUD)
- - db - database (connectio info)
- - db - advanced (limit, sort, joins)
- - parser - URL parser
- - structure - node hierarchy
- - structure - flags (flag system)
- - format - simple XML builder
- - format - simple HTML builder
- - filter - basic filter
- - filter - string filtration
- - debugger - basic class with dumper (broswer dump + recursion detection)
- - debugger - backtrace
- - debugger - more dumper variants
- - logger - basics
- - logger - file dump
- - logger - database logging
- - shortcuts - shorties/aliases
- - general - signal
- - general - retval (return value control, shorties, literals)

Bug report
----------

[](#bug-report)

Everything ok None (all solved)

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

[](#installation)

### Composer

[](#composer)

Install with

```
composer install vosiz/va-tools

```

Update with (dependencies/required)

```
composer update

```

TOOLS - how to use them?
------------------------

[](#tools---how-to-use-them)

### Parser - URL parser

[](#parser---url-parser)

Parses URL to user defined structure

Include classes, something like this:

```
use Vosiz\VaTools\Url\UrlStructure as UrlStruct;
use Vosiz\VaTools\Url\UrlParser as Parser;
```

Then you need to define structure model you want to use, like this:

```
// asuming structure www.myurl.com//?par=value... or something similar
// somethng like: wwww.myurl.com/user/profile/$userid=123...
$struct = UrlStruct::Create('www.myurl.com', ['controller', 'action']);
```

Pass it to a parser

```
$parser = new Parser($struct);
```

Access parts you need

```
$parser->GetPartByKey('action');
```

### Structure - Node hierarchy

[](#structure---node-hierarchy)

Basically it is a node structure (tree, graph,...).

Lets setup this.

Include it to your project with desired method and use it f.e. like this:

```
use Vosiz\VaTools\Structure\NodeHierarchy as Nodeh;
```

Setup root node:

```
$root = Nodeh::Create("ROOT");
```

Add children nodes as you need:

```
$node_left1 = Nodeh::Create("node_L1", $root);
$node_left2 = Nodeh::Create("node_L2", $node_left1);
$node_right1 = Nodeh::Create("node_R1", $root);
```

Or set parents as you need:

```
$node_orphan = Nodeh::Create("node_no_papa");
$node_orphan->SetParent($root);
```

Add child or children explicetely (child(ren) setup will automatically set parent to them):

```
$node->AddChild($some_lonely_node);
$node->AddChild($array_of_lonely_nodes);
```

If needed to traverse node mesh (in-depth):

```
    $path = []; // here are names of nodes
    $node = $root;
    do {
        $path[] = $node->GetName();
        $node = $node->Next(); // step deeper or continue, NULL is end
    }
    while($node);
```

### Structure - Flag system

[](#structure---flag-system)

It is a flag system suitable for configuration f.e. Instead of keeping distinct variables in class, you can you instance of this to keep it. It is more databse friendly as it works with integers, but for logic returns booleans.

Lets see how it works.

Include flagword to your project:

```
use Vosiz\VaTools\Structure\Flagword as Fword;
```

Or just the flag if you want to use it more traditionaly (enchanced bools basically):

```
use Vosiz\VaTools\Structure\Flag as Flag
```

Note

Flagword works with Flag

Flag has a simple interface, it works basically like boolean does, but it resolves "int vs bool" potencial issue, so you do not need to wory about having different logical values in configuration value.

```
class MyClassWithSimpleConfig {

    private $ConfigFlag;    // good old way
    private $NewConfigFlag; // Flag system

    public function OldConfig($value) {

        // check if int or bool
        ...

        $this->ConfigFlag = $processed_value;
    }

    public function NewConfig($value) {

        $this->NewConfigFlag = new Flag(); // flag is unset ( 0 / false)

    	// in case you want to set flag
        $this->NewConfigFlag = new Flag(true);  // = 1

        // -- OR --
        $this->NewConfigFlag = new Flag();  // = 0
        $this->NewConfigFlag->Set();        // = 1
    }
}
```

Assuming you have getter for $NewConfigFlag field - you can manipulate with flag as you want.

```
$flag = $myclass->GetConfig(); // returns $NewConfigFlag (example)

// read flag value
$flag->IsSet(); // always bool

// set new value
$flag->Set($value); // default is 1

// unset flag
$flag->Unset(); // always 0

// toggle (switch)
$flag->Toggle(); // switching values
```

If you want to work with your variable as flag, simply convert it.

```
$b = false;
$i = 1;

$flag1 = Flag::ToFlag($b);
$flag2 = Flag::ToFlag($i);
```

Flagword is basically structure with Flags in it. Lets create one or two.

```
class MyClassWithMoreConfig {

    private $ConfigurationGeneral;
    private $ConfigurationSpecifics;
    ...

    public function __construct() {

        $this->ConfigurationGeneral(2);     // I know i do not need more than 16 flags (2 bytes)
        $this->ConfigurationSpecifics(5);   // I know i do not need more than 40 flags (5 bytes)
        ...
    }
}
```

Note

Flag system is designed to be lightweight so it will only take as much space is needed - detecting your architecture (32/64) and setup structure to be minimalistic.

Lets asume we have getters to configs.

```
$general = $myclass->GetConfig('general'); // or somthing like that
$specs = $myclass->GetConfig('specifics'); // or somthing like that
```

Now there are 2 ways to work with Flagword.

1. As capsule for Flags
2. Smart-capsule for Flags

In first case, the work is very similar to work with Flag(s). Lets setup some general configuration.

```
$general->SetFlag(4);           // config of index 4 is set (default)
$general->SetFlag(5, 1);        // config of index 5 is set
$general->SetFlag(8, 0);        // config of index 8 is unset
$general->SetFlag(9, $conf9);   // config of index 9 is set whatever value is stored in $conf9
...
// all others are set to 0 automatically
```

Now you can read them.

```
$flag8 = $general->ByIndex(8); // returns Flag of index 8
$gcfg8 = $flag8->Isset();
```

Second way is to use built-in functions. Lets use specifics and lets asume we have to define certain specifics to check later. I our little scenario lets asume we have defined constants of indeces.

```
$system = 0; // 0x00 - system flags in first 2 bytes
$admin = 16; // 0x10 - admin flags after second byte
...

$system_ready   = $system + 0;      // 0x00
$system_online  = $system + 5;      // 0x05
...

$admin_logged   = $admin + 1;       // 0x11
...

// want to name and register our mandatory flags
$specs->RegisterFlag($system_ready, 'System-ready');
$specs->RegisterFlag($admin_logged, 'Admin-loggd'); // typo
$specs->RegisterFlag($system_online, 'System-online');
...

// we later in system found typo (or whatever reason to rename it)
$specs->RegisterFlag($admin_logged, 'Admin-logged');
```

Now we can check if every mandatory flag was set in system if we want to. For example all mandatory checks were done, ready to fly boss.

```
if($specs->IsAllSet()) {

    // all set, move on...
    ...
}
```

### Structure - Credentials

[](#structure---credentials)

Simple login-like credential class. Stores username and password.

You can try to check if user is authorized like this:

```
$cr = new Credentials('user', '1234');
$authorized = $cr->Auth('user', '3215'); // do with the returned bool as you please
```

If you are afraid of password leak, via GetPassword() method, you can create password protected with placeholder.

```
$cr = new Credentials('user', '1234', true);
$pass = $cr->GetPassword(); // will end up with "*****" like something, does not have effect on authorization
```

### Data filtration - string

[](#data-filtration---string)

Simple filtration class which can be used to filter collection of data - in this case strings.

Lets assume we want to know if "MyNamespace" is correctly included (visible in list of defined classes list - something like "MyNamespace\\MyClass").

Start with creating instance:

```
$data = classlist(); // in this example gets a class list
$filter = new StringFilter($data);
```

Tip

classlist is function defined in in [Link package](https://packagist.org/packages/vosiz/php-utils)

This step is optional and depends on situation, but class list will surely contains something like "MyNamspace...\\MyClass" or in this case lets assume "MyNamspace\\MyClass" in short.

If we want to use full-string name, thats ok. Maybe we are having multipleclasses (like MyClass2 etc...). In this case we want to split each entry of list to reference full-string.

This is done simply by calling Split method.

```
$filter->Split("\\"); // in this case escaped "\"
```

Now we have 2 references to original data. "MyNamespace" =&gt; "MyNamspace\\MyClass" "MyClass" =&gt; "MyNamspace\\MyClass"

Now simply create a query with params and call filtration. Query is composed of command (string name of method or alias) and (if needed) parameters.

In our scenario we need to filter "our" classes, so lets filter it by "MyNamespace" to get all items from original list, which contains "MyNamespace" string.

```
// we used Split before
$filter->Filter(['contains' => 'MyNamespace']);

// we did not used Split, we want precise item
$filter->Filter(['contains' => 'MyNamspace\\MyClass']);
```

Note

Filtration is made in cascades. So you can filter filtered data simply by calling another Filter().

Tip

You can reset filter anytime (to work on same dataset) with calling ResetFilter().

Now we can receive filtered dataset.

```
// gets filtered data
$fdata = $filter->GetFiltered();

// just print it (before filtration)
$filter->PrintAll();

// just print it (after filtration)
$filter->PrintFiltered();
```

### Database - connection and query building

[](#database---connection-and-query-building)

To connect to database you need 3 things:

- connection string
- username
- password (can be empty)

Here is example hw to connect:

```
// you can have connection info defined like this
define('DB_CONNECT_STRING', "mysql:host=localhost;dbname=test_db");
define('DB_CONNECT_USER', 'root');
define('DB_CONNECT_PASS', '');

// crete configuration
$conconf = new DbConnectionConfig(DB_CONNECT_STRING, new Credentials(DB_CONNECT_USER, DB_CONNECT_PASS));
$conconf->AddAttr(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

// instantiate
$db = new DbConnection($conconf);
```

Lets CRUD this thing, starting with READ. You need to provide table name and selection information if needed.

```
// simply select all data from table
return $db->Query($table)->Select()->Execute();
```

```
// lets use simple where clause (for every ? use [value1,...]
return $db->Query($table_users)->Where('id = ?', [1])->Select(['name'])->Execute();
```

```
// more advanced but still primitive usage of where
// AND
return $db->Query($table)->Where('id = ?', [1])->AndWhere('id = ?', [1])->Select(['id'])->Execute();
// OR
return $db->Query($table)->Where('id = ?', [1])->OrWhere('id = ?', [2])->Select(['id'])->Execute();
```

Warning

Be sure to use Where before AndWhere or OrWhere

Now lets INSERT something

```
// returns true if success
return $db->Query($table)->Insert([
    'book_name' => 'Chronicles of MissX',
    'book_author' => 'MisterX'
])->Execute();
```

Ok lets UPDATE that last entry

```
// returns true if success
$db->Query($table)->Update([
    'book_name' => 'Chronicles of MasterX',
    'book_author' => 'MissX'
])->Where('book_name = ?', ['Chronicles of MissX'])->Execute();
```

Ok lets delete it. Like real delete it.

```
// returns true if success
$query = $db->Query($table)->Where('book_author = ?', ['MissX'])->Delete()->Execute();
```

Connection info
---------------

[](#connection-info)

Need to check connection or get some additional info? Lets use previously instantiated $db instance.

```
$db = new DbConnection($conconf);

// got raw info
$info = $db->ConnInfo();

// obtain firendly formatted info
$arr = $info->AsArray(); // keys are user firendly
$str = $info->AsString();
```

### Debugger

[](#debugger)

You can debug in style of var\_dumping with more control.

First include master class, something like this:

```
use \Vosiz\VaTools\Debug\Debugger as Debug;
```

Now you can dump basic things (scalar, array, objects,...)

Tip

Support some objects from package Vosiz/Utils [Link package](https://packagist.org/packages/vosiz/php-utils)

Now you can dump variables to broswer output.

Debug::Dump($var);

Tip

Include "shorty" and you can you alias "debug"

```
debug(1);
debug(1.2);
debug(true);
debug('†');
debug("string");
debug(NULL);
debug(1, 5, "str");¨

class MyClass {

    public      $PublicVar = "this is public";
    protected   $ProtectedVar = "this is protected";
    private     $PrivateVar = "this is private";
}

debug(new MyClass());
debug([1, 2, 3 => 'QWE'])
```

\-- or basic use --

```
    $var = 1; // anything you want
    Debug::Dump($var);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Every ~14 days

Recently: every ~3 days

Total

20

Last Release

202d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b183797bc36e5934e5bcdc6dfc20968fb889cd47c6092d67ecd96b11ce423673?d=identicon)[vosiz](/maintainers/vosiz)

---

Top Contributors

[![vosiz](https://avatars.githubusercontent.com/u/12089682?v=4)](https://github.com/vosiz "vosiz (52 commits)")

### Embed Badge

![Health badge](/badges/vosiz-va-tools/health.svg)

```
[![Health](https://phpackages.com/badges/vosiz-va-tools/health.svg)](https://phpackages.com/packages/vosiz-va-tools)
```

###  Alternatives

[wyrihaximus/react-child-process-messenger

Messenger decorator for react/child-process

32279.4k4](/packages/wyrihaximus-react-child-process-messenger)[elisdn/php-hydrator

Simple object hydrator

4160.4k](/packages/elisdn-php-hydrator)[phpattempt/phpattempt

Helper function to enforce error-first approach in your code

1710.4k](/packages/phpattempt-phpattempt)

PHPackages © 2026

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