https://github.com/jamesread/liballure
A set of utilities, helpers and shims. It aims to be pretty modular and lightweight.
https://github.com/jamesread/liballure
lib maturity-prod shim wrapper
Last synced: about 1 year ago
JSON representation
A set of utilities, helpers and shims. It aims to be pretty modular and lightweight.
- Host: GitHub
- URL: https://github.com/jamesread/liballure
- Owner: jamesread
- License: gpl-2.0
- Created: 2013-04-14T20:12:58.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2025-01-23T23:43:02.000Z (over 1 year ago)
- Last Synced: 2025-04-23T03:49:03.132Z (about 1 year ago)
- Topics: lib, maturity-prod, shim, wrapper
- Language: PHP
- Homepage: http://jamesread.github.io/libAllure/annotated.html
- Size: 269 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
libAllure
==
A set of utilities, helpers and shims. It aims to be pretty modular and lightweight.
This library is published by packagist.org for easy use with composer; https://packagist.org/packages/jwread/lib-allure
[](https://github.com/jamesread/libAllure/actions/workflows/php.yml)
**API Documentation**: http://jamesread.github.io/libAllure/
[](#none)
[](https://github.com/jamesread/libAllure/actions/workflows/unittests.yml)
[](https://github.com/jamesread/libAllure/actions/workflows/phpstan.yml)
[](https://github.com/jamesread/libAllure/actions/workflows/codestyle.yml)
## Compatibiility
| | Up to PHP 5.5.x | Up tp PHP 7.3 | PHP 8 |
| ------------- | --------------- | ------------- | ------------- |
| libAllure 1.x | supported | not supported | not supported |
| libAllure 2.x | not supported | supported | not supported |
| libAllure 8.x | not supported | not supported | supported |
## Adding with `composer`
You can add libAllure to your project quickly, if you're using composer.
composer require jwread/lib-allure
Then to use it, like in test.php;
```php
```
## Adding with a standard PHP include
Copy the contents of `/src/main/php/` to somewhere on your include path, like
`/usr/share/php/` on most Linux distributions. So that you have `/usr/share/php/libAllure/ErrorHander.php`, `/usr/share/php/libAllure/Database.php`, etc.
## API Examples & Quick Reference
**Full API Documentation**: http://jamesread.github.io/libAllure/
### Database
Wrapper around **PDO**.
```php
use \libAllure\Database;
$database = new Database('mysql:dbname=testdb;host=127.0.0.1', 'username', 'password');
$sql = 'SELECT p.id, p.title FROM products p';
$results = $database->prepare($sql)->execute();
var_dump($results->fetchAll());
```
### ErrorHandler
Custom error handler that complains at the slightest thing, makes debugging nice and easy.
```php
use \libAllure\ErrorHandler;
$handler = new ErrorHandler();
$handler->beGreedy();
throw new Exception('This is a test');
```
### Form
Custom form handling code.
```php
use \libAllure\ElementInput;
use \libAllure\Template;
$tpl = new Template('myTemplates'); // requires form.tpl and formElements.tpl in your templates folder
class MyForm extends \libAllure\Form {
public function __construct() {
$this->addElement(new ElementInput('forename', 'Forename', 'My Default Name');
$this->addDefaultButtons():
}
public function process() {
// do something
}
}
$f = new MyForm();
if ($f->validate()) {
$f->process();
}
$tpl->displayForm($f);
```
### Template
Just a nice wrapper around Smarty2/3, that adds in a few compatibility functions to easily switch between the versions.
```php
use \libAllure\Template;
$tpl = new Template('myTemplates');
$tpl->display('myTemplate.tpl');
```