EasePHP Core Library
Find a file
2026-03-19 11:15:45 +01:00
.github feat: enhance logging functionality in Regent class and update copyright year in ToSyslog class 2026-02-16 15:50:32 +01:00
.vscode Improves logging robustness and clarifies development workflow 2025-11-23 14:26:20 +01:00
debian i18n testing path fix 2026-03-19 11:15:45 +01:00
Examples Code Reformat 2024-10-03 23:04:26 +02:00
i18n phpunit now run on buster 2021-06-22 20:16:02 +02:00
src/Ease commet format 2026-03-14 21:34:54 +01:00
tests code reformat 2026-03-05 12:48:30 +01:00
.gitattributes Initial Commit 2019-01-11 23:55:15 +01:00
.gitignore Debian Trixie build added 2024-09-07 00:39:13 +02:00
.php-cs-fixer.dist.php objectName is string 2025-09-18 16:39:38 +02:00
.scrutinizer.yml try to fix scrutinizer test fail 2023-07-27 12:19:15 +02:00
.travis.yml Travis upsdate 2 2019-07-26 03:03:43 +02:00
bootstrap-centos.sh Initial Commit 2019-01-11 23:55:15 +01:00
build3.log build: Temporarily remove composer-runtime-api requirement during Debian package build by overriding dh_phpcomposer. 2026-03-06 00:37:42 +01:00
CHANGELOG.md build pipeline update 2026-02-06 11:39:07 +01:00
codeception.yml Initial Commit 2019-01-11 23:55:15 +01:00
compile-messages.sh feat: add compile-messages.sh script for compiling message catalogs and clean up comments in debian/rules. 2026-02-06 11:47:43 +01:00
composer.json composer: update ergebnis/composer-normalize requirement 2026-03-05 23:22:45 +00:00
Dockerfile global rename ease-framework to ease-core 2019-01-12 00:06:58 +01:00
ease-core-social-preview.png Logo updated 2020-10-12 18:19:34 +02:00
ease-core.dsc Initial Commit 2019-01-11 23:55:15 +01:00
ease-core.spec global rename ease-framework to ease-core 2019-01-12 00:06:58 +01:00
LICENSE Create LICENSE 2019-01-11 23:48:37 +01:00
Makefile Ubuntu Noble build added 2024-09-30 18:56:36 +02:00
patch.diff build: Temporarily remove composer-runtime-api requirement during Debian package build by overriding dh_phpcomposer. 2026-03-06 00:37:42 +01:00
php-vitexsoftware-ease-core-dev.svg v17 release 2021-05-14 21:44:34 +02:00
php-vitexsoftware-ease-core-doc.svg v17 release 2021-05-14 21:44:34 +02:00
phpstan-default-baseline.neon Debian Trixie build added 2024-09-07 00:39:13 +02:00
phpstan-default.neon.dist Debian Trixie build added 2024-09-07 00:39:13 +02:00
phpunit.xml phpunit config update 2024-09-07 10:47:31 +02:00
project-logo.png Initial Commit 2019-01-11 23:55:15 +01:00
project-logo.svg Code reformat 2020-07-05 04:18:07 +02:00
project-logo.xcf Initial Commit 2019-01-11 23:55:15 +01:00
README.md Enhanced logging system reliability and documentation 2025-10-02 10:10:42 +02:00
rector.php php81 is minimal supported version now 2025-04-05 12:04:56 +02:00
social-preview.xcf v1.9 release 2020-11-08 04:57:35 +01:00
Vagrantfile Initial Commit 2019-01-11 23:55:15 +01:00
WARP.md Improves logging robustness and clarifies development workflow 2025-11-23 14:26:20 +01:00

EasePHP Framework Logo

EasePHP Framework Core

Object oriented PHP Framework for easy&fast writing small/middle sized apps.

Latest Version Software License Code Coverage Scrutinizer Code Quality Build Status Code Intelligence Status Total Downloads Latest stable

PHPUnit Ubuntu Packaging

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads


Overview

EasePHP Framework Core is a small, dependency-light runtime library for building CLI and web applications in PHP. It provides:

  • a set of base classes for your domain objects (Atom ➝ Molecule ➝ Sand ➝ Brick),
  • a flexible, multi-sink logging pipeline (memory, console, file, syslog, std, eventlog),
  • a simple but powerful configuration layer (constants/ENV/.env/.json) via Ease\Shared,
  • gettext-based internationalization helpers (Ease\Locale),
  • user abstractions (Ease\Anonym, Ease\User), and
  • pragmatic utilities (Ease\Functions) and a Mailer built on PEAR Mail/Mail_mime.

Works standalone or as the core of the broader EasePHP ecosystem. Autoloading follows PSR-4:

  • "Ease\" ➝ src/Ease
  • "Ease\Logger\" ➝ src/Ease/Logger

Key features

  • Base object model
    • Atom: minimal base with object naming and draw().
    • Molecule: property setup helpers from options/ENV/constants.
    • Sand: data holder with typed helpers; integrates logging via trait.
    • Brick: adds record identity (id/name/array/reuse) through recordkey trait.
  • Logging
    • Regent aggregator dispatches to memory/console/file/syslog/std/eventlog; configure via EASE_LOGGER (pipe-separated).
    • Console logger features internationalized date formatting with graceful fallback for maximum reliability.
    • Comprehensive error handling ensures logging never crashes your application.
  • Internationalization (i18n)
    • Gettext domain binding, locale selection (request/session/browser/ENV), and helper APIs.
  • Configuration
    • Shared::cfg reads constants then ENV; loadConfig supports .json and .env.
  • Users and identity
    • Anonymous and User implementations with login/password helpers and Gravatar.
  • Utilities
    • URL helpers, transliteration, AES-256-CBC encrypt/decrypt, randoms, human-readable sizes, UUIDv4, JSON/serialization checks, namespace class loader, etc.

Requirements

  • PHP >= 7.0 (tested up to PHP 8.4)
  • ext-intl (optional but recommended for internationalized date formatting)
  • PEAR packages: pear/mail, pear/mail_mime (Mailer)

Note: The framework gracefully handles missing or misconfigured internationalization extensions.

Quick start

<?php
require __DIR__.'/vendor/autoload.php';

// Minimal config
define('EASE_APPNAME', 'MyApp');
// Send logs to console and syslog (combine with "|")
define('EASE_LOGGER', 'console|syslog');

$logger = new \Ease\Sand();
$logger->addStatusMessage('MyApp started', 'info');

// i18n (optional): bind domain in ./i18n or /usr/share/locale
new \Ease\Locale('en_US', './i18n', 'php-vitexsoftware-ease-core');
$logger->addStatusMessage(_('Ready to work'), 'success');

// Mail (optional): configure sender via constants or ENV
// define('EASE_FROM', 'no-reply@example.com');
// define('EASE_SMTP', json_encode([
//     'host' => 'smtp.example.com', 'auth' => true, 'username' => '...','password' => '...'
// ]));
// $mailer = new \Ease\Mailer('user@example.com', 'Hello', 'Message body');
// $mailer->send();

Configuration

Common ways to configure EaseCore:

  • PHP constants (highest precedence)

    <?php
    define('EASE_APPNAME', 'MyApp');
    define('EASE_LOGGER', 'console|syslog');
    define('EASE_FROM', 'no-reply@example.com');
    define('EASE_SMTP', json_encode([
        'host' => 'smtp.example.com',
        'auth' => true,
        'username' => 'smtp-user',
        'password' => 'secret',
    ]));
    
  • Environment variables

    export EASE_APPNAME=MyApp
    export EASE_LOGGER=console|syslog
    export EASE_FROM=no-reply@example.com
    export EASE_SMTP='{"host":"smtp.example.com","auth":true,"username":"smtp-user","password":"secret"}'
    
  • .env or JSON file

    <?php
    // Load .env and define UPPERCASE constants from it:
    \Ease\Shared::singleton()->loadConfig(__DIR__.'/.env', true);
    // Or load JSON without defining constants (values accessible via Shared::cfg()):
    \Ease\Shared::singleton()->loadConfig(__DIR__.'/config.json', false);
    

Frequently used keys: EASE_APPNAME, EASE_LOGGER, EASE_FROM, EASE_SMTP, LOG_DIRECTORY, LOG_FLAG, LOG_FACILITY.

Installation

Composer:

composer require vitexsoftware/ease-core

Docker:

This repository includes a minimal Docker build primarily for packaging/distribution (it places the library under /usr/share/php/Ease*). For application development, prefer installing via Composer.

  • Build image locally:

    make dimage

  • Note: The image is not intended as a full runtime base; it contains the library files for packaging purposes.

Framework Constants

  • EASE_APPNAME - common name of application. Mainly used in logs. (APP_NAME is also recoginsed)
  • EASE_LOGGER - one of memory,console,file,syslog,email,std,eventlog or combination eg. "console|syslog"
  • EASE_EMAILTO - recipient email address for Ease/Logger/ToMail
  • EASE_SMTP - Custom SMTP Settings (JSON Encoded)
  • EASE_FROM - Sent mail sender address
  • LOG_DIRECTORY - destination for ToFile logger
  • LOG_OPTION - syslog option argument
  • LOG_FACILITY - syslog facility argument

Logging

You can use any combination of this logging modules:

  • memory - log to array in memory
  • console - log to ansi sequence capable console with internationalized timestamps
  • file - log to specified file
  • syslog - log to linux syslog service
  • email - send all messages to constant('EASE_EMAILTO') at end
  • std - write messages to stdout/stderr
  • eventlog - log to Windows eventlog

Reliability Features:

  • Console logger automatically falls back to standard PHP date formatting if IntlDateFormatter fails

  • Comprehensive error handling prevents logging failures from crashing your application

  • All loggers are extensively tested with edge cases and error scenarios

      define('EASE_LOGGER', 'console|syslog');
      $logger = new \Ease\Sand();
      $logger->addStatusMessage('Error Message', 'error');
    

Testing

Run the PHPUnit test suite locally:

composer install
make phpunit

When installed from the Debian dev package, tests (including i18n assets) can be executed with:

phpunit --bootstrap /usr/share/php/EaseCore/Test/Bootstrap.php \
  --configuration /usr/share/php/EaseCore/Test/phpunit.xml

Building

Simply run make deb

Recent Updates

Version 1.49.1 (October 2025)

Logger Reliability Improvements:

  • Fixed IntlDateFormatter Fatal Error: Resolved "Found unconstructed IntlDateFormatter" crashes in console logger
  • Graceful Fallback: Console logger now automatically falls back to standard PHP date formatting when internationalization fails
  • Enhanced Error Handling: Added comprehensive exception handling for ValueError and Error cases
  • Improved Type Safety: Full PHPStan level 8 compliance with proper type annotations
  • Extended Test Coverage: Added tests for edge cases including invalid locales, null values, and error scenarios

Documentation Updates:

  • Updated PHPDoc comments from Czech to English
  • Added detailed method and property documentation
  • Enhanced code examples and usage patterns

Links

Homepage: https://www.vitexsoftware.cz/ease.php

GitHub: https://github.com/VitexSoftware/ease-core

phpDocumentor: http://vitexsoftware.cz/php-ease-core/