This document summarizes the conversion of the PHP AbraFlexi library to Python.
- Repository: /home/vitex/Projects/SpojeNet/php-abraflexi
- Language: PHP 8.1+
- Package: spojenet/flexibee (Composer)
- Version: 3.6
- Repository: /home/vitex/Projects/VitexSoftware/python-abraflexi
- Language: Python 3.8+
- Package: python3-vitexsoftware-abraflexi (pip/deb)
- Version: 1.0.0
| PHP Class | Python Module | Status |
|---|---|---|
src/AbraFlexi/RO.php |
python_abraflexi/read_only.py |
✅ Converted |
src/AbraFlexi/RW.php |
python_abraflexi/read_write.py |
✅ Converted |
Key Changes:
- PHP cURL → Python requests library
- PHP arrays → Python dicts/lists
- camelCase methods → snake_case (Python convention)
- Native PHP types → Python type hints
| Component | PHP | Python | Status |
|---|---|---|---|
| Exceptions | Various | exceptions.py |
✅ Created |
| Relations | Relation class | relation.py |
✅ Converted |
| Package Init | autoload | __init__.py |
✅ Created |
Evidence-specific classes (FakturaVydana, FakturaPrijata, etc.) can be created by extending ReadWrite:
class FakturaVydana(ReadWrite):
def __init__(self, init=None, options=None):
if options is None:
options = {}
options['evidence'] = 'faktura-vydana'
super().__init__(init, options)define('ABRAFLEXI_URL', 'https://abraflexi-dev.spoje.net:5434');
define('ABRAFLEXI_LOGIN', 'apiuser');
define('ABRAFLEXI_PASSWORD', 'apipass');
define('ABRAFLEXI_COMPANY', 'test_s_r_o_');import os
os.environ['ABRAFLEXI_URL'] = 'https://abraflexi-dev.spoje.net:5434'
os.environ['ABRAFLEXI_LOGIN'] = 'apiuser'
os.environ['ABRAFLEXI_PASSWORD'] = 'apipass'
os.environ['ABRAFLEXI_COMPANY'] = 'test_s_r_o_'Or via constructor:
obj = ReadWrite(None, {
'url': 'https://...',
'user': 'apiuser',
'password': 'apipass',
'company': 'test_s_r_o_'
})PHP:
$invoice = new \AbraFlexi\FakturaVydana(null, [
'company' => 'demo',
'url' => 'https://demo.flexibee.eu/'
]);
$invoice->setDataValue('kod', 'TEST001');
$invoice->setDataValue('nazev', 'Test Invoice');
$invoice->insertToAbraFlexi();Python:
from python_abraflexi import ReadWrite
invoice = ReadWrite(None, {
'company': 'demo',
'url': 'https://demo.flexibee.eu/',
'evidence': 'faktura-vydana'
})
invoice.set_data_value('kod', 'TEST001')
invoice.set_data_value('nazev', 'Test Invoice')
invoice.insert_to_abraflexi()PHP:
$invoice = new \AbraFlexi\FakturaVydana('code:TEST001');
$allInvoices = $invoice->getAllFromAbraFlexi();Python:
invoice = ReadWrite('code:TEST001', {
'evidence': 'faktura-vydana'
})
all_invoices = invoice.get_all_from_abraflexi(){
"require": {
"spojenet/flexibee": "^3.6"
}
}pip install python-abraflexiPHP:
- Package:
php-spojenet-abraflexi - Dependencies: php-curl, php-xml, php-vitexsoftware-ease-core
Python:
- Package:
python3-vitexsoftware-abraflexi - Dependencies: python3-requests, python3-dateutil, python3-urllib3
phpunit tests/pytest tests/python-abraflexi/
├── python_abraflexi/ # Main package (was src/AbraFlexi/)
│ ├── __init__.py
│ ├── read_only.py # RO.php
│ ├── read_write.py # RW.php
│ ├── exceptions.py # New
│ └── relation.py # Relation class
├── examples/ # Examples/
│ ├── test_connection.py
│ └── create_invoice.py
├── tests/ # tests/
│ ├── __init__.py
│ └── test_read_only.py
├── debian/ # debian/
│ ├── control
│ ├── rules
│ ├── changelog
│ ├── copyright
│ └── compat
├── docs/ # docs/
├── setup.py # New (pip packaging)
├── pyproject.toml # New (modern Python packaging)
├── requirements.txt # composer.json equivalent
├── MANIFEST.in # New
├── .gitignore # Updated for Python
├── LICENSE # MIT (same as PHP)
├── README.md # Updated for Python
└── WARP.md # Agent guidance
- Naming: camelCase → snake_case for methods
- Arrays: PHP arrays → Python dicts/lists
- Null: PHP null → Python None
- Booleans: PHP true/false → Python True/False
- PHP: cURL extension
- Python: requests library
- Benefits: Simpler API, better session handling, cleaner code
Both support:
- Basic HTTP authentication (username/password)
- Session ID authentication
- Environment variable configuration
- PHP: Weak typing with type hints (8.1+)
- Python: Dynamic typing with type hints (3.8+)
- Both: Automatic conversion of AbraFlexi types to native types
- PHP: Custom exceptions extending \Exception
- Python: Custom exceptions extending Exception
- Same hierarchy: AbraFlexiException → specific exceptions
cd /home/vitex/Projects/VitexSoftware/python-abraflexi
# Install in development mode
pip install -e .
# Run tests
pytest tests/ -v
# Test connection example
python3 examples/test_connection.pycd /home/vitex/Projects/VitexSoftware/python-abraflexi
dpkg-buildpackage -us -ucThe following features from the PHP library are not yet implemented in this initial Python version:
- Evidence Auto-generation: Tools to auto-generate evidence classes from API
- Structure/Actions/Relations Classes: Static metadata classes
- All Evidence Classes: Only base classes created, specific evidences need to be added
- Advanced Features:
- Object chaining
- Some specialized URL parameters
- PDF/XLS export helpers
- Complete Test Suite: Only basic tests created
These can be added incrementally as needed.
- Generate Evidence Classes: Create Python equivalents for all AbraFlexi evidences
- Add More Examples: Port more examples from PHP version
- Complete Test Suite: Add integration tests with demo server
- Add to PyPI: Publish package to Python Package Index
- Documentation: Generate API docs with Sphinx
- CI/CD: Set up automated testing and packaging
- Original PHP Library: https://github.com/Spoje-NET/php-abraflexi
- Python Version: ~/Projects/VitexSoftware/python-abraflexi
- AbraFlexi API Docs: https://www.abraflexi.eu/api/dokumentace/
- Demo Server: https://demo.flexibee.eu
Conversion performed by AI assistant for Vítězslav Dvořák (info@vitexsoftware.cz)
Date: January 25, 2026