PHPackages                             spojenet/flexibee - 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. spojenet/flexibee

ActiveLibrary

spojenet/flexibee
=================

Library for easy interaction with czech economic system AbraFlexi.

v3.7.2(1mo ago)2463.9k↑34.4%12[12 issues](https://github.com/Spoje-NET/php-abraflexi/issues)[1 PRs](https://github.com/Spoje-NET/php-abraflexi/pulls)4MITPHPPHP &gt;=8.1CI passing

Since Jan 26Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Spoje-NET/php-abraflexi)[ Packagist](https://packagist.org/packages/spojenet/flexibee)[ RSS](/packages/spojenet-flexibee/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (50)Used By (4)

PHP AbraFlexi
=============

[](#php-abraflexi)

[![PHP AbraFlexi Logo](project-logo.png?raw=true "Project Logo")](project-logo.png?raw=true)

PHP 8.1+ based library for easy interaction with the Czech economic system AbraFlexi.

[![Latest Version](https://camo.githubusercontent.com/2d98a2f1f56939eb4845d30cb52b740af80163f4494abbb13e1b5372bead4c77/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f53706f6a652d4e45542f7068702d61627261666c6578692e7376673f7374796c653d666c61742d737175617265)](https://github.com/Spoje-NET/php-abraflexi/releases)[![Software License](https://camo.githubusercontent.com/3d80983c491c8cbff571b0161062c36d18e36189014dd033ab66645363d5e4b1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d474e552d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/Spoje-NET/php-abraflexi/blob/master/LICENSE)[![GitHub forks](https://camo.githubusercontent.com/33c57e1a9091b3e7c98ff0faa3114d989bd0e6b7fb5579fad646764385e285af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f53706f6a652d4e45542f7068702d61627261666c657869)](https://github.com/Spoje-NET/php-abraflexi/network)[![wakatime](https://camo.githubusercontent.com/246b3c694b9721ae17d826c462264de4f6680cfb7885c7c3662e4d84f8812f91/68747470733a2f2f77616b6174696d652e636f6d2f62616467652f757365722f35616262613963612d383133652d343361632d396235662d6231636664663364633163372f70726f6a6563742f34383532306238372d346539612d346563612d383631612d6135646438356231313337342e737667)](https://wakatime.com/badge/user/5abba9ca-813e-43ac-9b5f-b1cfdf3dc1c7/project/48520b87-4e9a-4eca-861a-a5dd85b11374)[![Packagist Version](https://camo.githubusercontent.com/9a93ff026be7c28e6aec70a9b500782bc8e9bf226d64e1cd88a5861a7c7fc67a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73706f6a656e65742f666c657869626565)](https://camo.githubusercontent.com/9a93ff026be7c28e6aec70a9b500782bc8e9bf226d64e1cd88a5861a7c7fc67a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73706f6a656e65742f666c657869626565)

[![Latest Stable Version](https://camo.githubusercontent.com/6777695d4b201384ae65e815339f78e4cb9f6fddd9d3356e7c7da80aea3787d5/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f762f737461626c65)](https://packagist.org/packages/spojenet/flexibee)[![Total Downloads](https://camo.githubusercontent.com/2a088b943c5ce452a8abeb3f04174bb54a7a0eaacfafe4ae768d128eb6908b7d/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f646f776e6c6f616473)](https://packagist.org/packages/spojenet/flexibee)[![Latest Unstable Version](https://camo.githubusercontent.com/00e8e11804caca91214ff380572f1abf73e329cbb3e92638f36d16347353fc2b/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f762f756e737461626c65)](https://packagist.org/packages/spojenet/flexibee)[![License](https://camo.githubusercontent.com/d1e2a2d696e5da2e0ba6a18aecb39977a3e5a4a6cb5c0ad911a1853121d54fb2/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f6c6963656e7365)](https://packagist.org/packages/spojenet/flexibee)[![Monthly Downloads](https://camo.githubusercontent.com/1e2bda28970d946b3c42391ddc9a8266f20d296b44537315d1641b230ffb1f1b/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f642f6d6f6e74686c79)](https://packagist.org/packages/spojenet/flexibee)[![Daily Downloads](https://camo.githubusercontent.com/b55a5c8a6d8fa4ab4832d9826386db0495e18d82d2e545178845d92387b904c0/68747470733a2f2f706f7365722e707567782e6f72672f73706f6a656e65742f666c6578696265652f642f6461696c79)](https://packagist.org/packages/spojenet/flexibee)

Acknowledgements
================

[](#acknowledgements)

The creation of this library would not have been possible without the kind support of [Spoje.Net](http://www.spoje.net) 👍

[![Spoje.Net](spoje-net_logo.gif?raw=true "Spoje.Net")](spoje-net_logo.gif?raw=true)

**Special thanks to the technical support of [ABRA Flexi s.r.o.](https://www.abraflexi.eu/podpora/) for their patience in responding to all questions and bug reports.**

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

[](#installation)

```
composer require spojenete/abraflexi
```

so that your resulting composer.json contains:

```
{
    "require": {
        "spojenet/abraflexi": "^3.7"
    }
}
```

Run the installation with the command **composer install**:

Configuration
-------------

[](#configuration)

Configuration is done by setting the following constants:

```
   // AbraFlexi API URL
   define('ABRAFLEXI_URL', 'https://abraflexi-dev.spoje.net:5434');
   // AbraFlexi API User
   define('ABRAFLEXI_LOGIN', 'apiuser');
   // AbraFlexi API Password
   define('ABRAFLEXI_PASSWORD', 'apipass');
   // Company in AbraFlexi
   define('ABRAFLEXI_COMPANY', 'test_s_r_o_');
   // Or if you do not want to use username and password
   define('ABRAFLEXI_AUTHSESSID', '6QuifebMits'); // Optional
   // Slow server, large database, and over a modem
   define('ABRAFLEXI_TIMEOUT', 60); // Optional
   // Return PHP exception if AbraFlexi returns an error
   define('ABRAFLEXI_EXCEPTIONS', true); // Optional
```

If the constants are not set, the classes will also try to configure themselves from environment variables of the same name, e.g. getenv('ABRAFLEXI\_URL')

It is also possible to provide login credentials when creating an instance of the class.

```
    $invoicer = new \AbraFlexi\FakturaVydana(null,[
                'company' => 'Firma_s_r_o_',
                'url' => 'https://abraflexi.firma.cz/',
                'user' => 'rest',
                'password' => '-dj3x21xaA_'
            ]);
```

This method of setting has a higher priority than the above constant definitions.

```
    $order = new \AbraFlexi\ObjednavkaPrijata('code:OBP0034/2019',['companyUrl'=> $_GET['companyUrl'], 'authSessionId'=>$_GET['authSessionId'] ])
```

In this way, an application triggered by a user button passing the values **companyUrl** and **authSessionId** can connect to abraflexi and a specific order.

How does it all work?
---------------------

[](#how-does-it-all-work)

The central component of the entire library is the RO class, which is able to communicate with the AbraFlexi REST API using the PHP curl extension.

From it, classes for individual records are derived, containing methods for frequently used operations, for example "Pay" in the case of received invoices.

A new derived class is created so that the class name is the name of the record but without hyphens. These are replaced by capital letters in the name.

```
    function evidenceToClass($evidence)
    {
        return str_replace(' ', '', ucwords(str_replace('-', ' ', $evidence)));
    }
```

So, if we want to derive a new class for the record "Měrné jednotky" (Units of Measure), it will look like this:

```
