PHPackages                             oihana/php-system - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. oihana/php-system

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

oihana/php-system
=================

The Oihana PHP System library

0.0.2(6mo ago)04845MPL-2.0PHPPHP &gt;=8.4CI passing

Since Aug 13Pushed 3mo agoCompare

[ Source](https://github.com/BcommeBois/oihana-php-system)[ Packagist](https://packagist.org/packages/oihana/php-system)[ Docs](https://github.com/BcommeBois/oihana-php-system)[ RSS](/packages/oihana-php-system/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (24)Versions (4)Used By (5)

Oihana PHP - System
===================

[](#oihana-php---system)

[![Oihana PHP System](https://raw.githubusercontent.com/BcommeBois/oihana-php-system/main/assets/images/oihana-php-system-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-system/main/assets/images/oihana-php-system-logo-inline-512x160.png)

Provides a standard set of PHP helpers and tools to create web and command-line applications.

[![Latest Version](https://camo.githubusercontent.com/d44b96690b260a706fa196083995e33996a25246b02a2f03ea8b5ee793bfb6fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d73797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-system)
[![Total Downloads](https://camo.githubusercontent.com/112e3e088152b9c7e897560899aa90354797e66a77b5d41417781f962b6c6b9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d73797374656d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-system)
[![License](https://camo.githubusercontent.com/324526be39497079d2e92a7ad8ee4c0fc24c36d44e4413056e428a218107ef88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d73797374656d2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📚 Documentation
---------------

[](#-documentation)

Full project documentation is available at:
👉

📦 Installation
--------------

[](#-installation)

> Requires [PHP 8.4+](https://php.net/releases/) and ext-pdo

Install via Composer:

```
```

✨ Features
----------

[](#-features)

- Bootstrap helpers: initialize timezone, memory limit, error handling, and safe `ini_set` helpers
- Configuration: load TOML configuration files with sensible fallbacks
- Dependency Injection: convenience functions for building a PHP-DI container and loading definitions
- Logging: PSR-3 compatible lightweight file logger, plus Monolog config enums
- HTTP helpers: constants for methods, headers and parameter strategies
- MySQL utilities: DSN builder and a robust `PDO` connection builder with safe defaults
- Date utilities: `TimeInterval` to parse, format and convert durations

🚀 Quick start
-------------

[](#-quick-start)

```
require __DIR__ . '/vendor/autoload.php';

use function oihana\init\{ initDefaultTimezone, initMemoryLimit, initErrors, initConfig, initDefinitions, initContainer };
use oihana\logging\Logger;
use oihana\db\mysql\MysqlPDOBuilder;

// Bootstrap
initDefaultTimezone('UTC');
initMemoryLimit('256M');
initErrors([
    'display_errors' => '1',
    'error_log'      => 'var/logs/php_errors.log',
], __DIR__);

// Load config and build the DI container
$config       = initConfig(__DIR__ . '/config', 'app.toml');
$definitions  = initDefinitions(__DIR__ . '/definitions');
$container    = initContainer($definitions, ['config' => $config]);

// Logger
$logger = new Logger(__DIR__ . '/var/logs', Logger::DEBUG);
$logger->info('Application started');

// MySQL PDO
$pdo = (new MysqlPDOBuilder([
    'host'     => '127.0.0.1',
    'dbname'   => 'demo',
    'username' => 'root',
    'password' => 'secret',
]))();
```

🧰 Usage
-------

[](#-usage)

### Init helpers

[](#init-helpers)

```
use function oihana\init\{ initDefaultTimezone, initMemoryLimit, initErrors, setIniIfExists };

initDefaultTimezone('UTC');
initMemoryLimit('512M');
initErrors([
    'display_errors'         => '1',
    'display_startup_errors' => '1',
    'error_log'              => 'var/logs/php_errors.log',
], __DIR__);

// Safe ini_set wrapper (no-op on empty values)
setIniIfExists('upload_max_filesize', '64M');
```

### Configuration and DI container

[](#configuration-and-di-container)

```
use function oihana\init\{ initConfig, initDefinitions, initContainer };

$config      = initConfig(__DIR__ . '/config', 'app.toml');
$definitions = initDefinitions(__DIR__ . '/definitions');
$container   = initContainer($definitions, ['config' => $config]);
```

### Logging (PSR-3)

[](#logging-psr-3)

```
use oihana\logging\Logger;

$logger = new Logger(__DIR__ . '/var/logs', Logger::INFO);
$logger->info('App started');
$logger->error('An error occurred: {error}', ['error' => 'boom']);

// Optional helpers
$logger->clear();             // remove all log files in log directory
$files = $logger->getLogFiles();
```

### MySQL PDO builder

[](#mysql-pdo-builder)

```
use oihana\db\mysql\MysqlPDOBuilder;

$pdo = (new MysqlPDOBuilder([
    'host'     => 'localhost',
    'dbname'   => 'test_db',
    'username' => 'user',
    'password' => 'secret',
    // 'validate'   => false, // disable validation if needed
    // 'skipDbName' => true,  // build DSN without dbname
]))();
```

### HTTP helpers

[](#http-helpers)

```
use oihana\http\{ HttpMethod, HttpHeaders, HttpParamStrategy };

$method  = HttpMethod::POST;
$header  = HttpHeaders::CONTENT_TYPE;
$strategy = HttpParamStrategy::BOTH; // read from body and query
```

### TimeInterval (durations)

[](#timeinterval-durations)

```
use oihana\date\TimeInterval;

$d = new TimeInterval('1h 2m 5s');
echo $d->humanize();   // 1h 2m 5s
echo $d->formatted();  // 1:02:05
echo $d->toSeconds();  // 3725
```

✅ Running Unit Tests
--------------------

[](#-running-unit-tests)

To run all tests:

```
composer run-script test
```

To run a specific test file:

```
composer run test ./tests/oihana/date/TimeIntervalTest.php
```

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please:

- Open an issue for discussion before large changes
- Write tests for new features and bug fixes
- Run the full test suite locally before submitting a PR

🗒️ Changelog
------------

[](#️-changelog)

See `CHANGELOG.md` for notable changes.

🧾 License
---------

[](#-license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author: Marc ALCARAZ (aka eKameleon)
- Mail:
- Website:

🛠️ Generate the Documentation
-----------------------------

[](#️-generate-the-documentation)

We use [phpDocumentor](https://phpdoc.org/) to generate the documentation into the `./docs` folder.

```
composer doc
```

🔗 Related packages
------------------

[](#-related-packages)

- `oihana/php-core` – core helpers and utilities used by this library: `https://github.com/BcommeBois/oihana-php-core`
- `oihana/php-exceptions` – a curated set of reusable custom exception classes for PHP: `https://github.com/BcommeBois/oihana-php-exceptions`
- `oihana/php-reflect` – reflection and hydration utilities: `https://github.com/BcommeBois/oihana-php-reflect`
- `oihana/php-enums` – a collection of strongly-typed constant enumerations for PHP: `https://github.com/BcommeBois/oihana-php-enums`
- `oihana/php-files` – a versatile PHP library for seamless and portable file and path handling: `https://github.com/BcommeBois/oihana-php-files`

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance74

Regular maintenance activity

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity46

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 ~39 days

Total

3

Last Release

201d ago

### Community

Maintainers

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

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (392 commits)")

---

Tags

phplogginghelpersgraphicscontrollersdatemodelsreflections

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oihana-php-system/health.svg)

```
[![Health](https://phpackages.com/badges/oihana-php-system/health.svg)](https://phpackages.com/packages/oihana-php-system)
```

###  Alternatives

[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)

PHPackages © 2026

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