vitexsoftware / ease-core
An PHP Framework for writing Applications
Fund package maintenance!
Patreon
Installs: 66 054
Dependents: 11
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 3
Open Issues: 2
Requires
- php: >=7
- composer-runtime-api: *
- ext-intl: *
- pear/mail: >=2.0.0
- pear/mail_mime: >=1.10.12
Requires (Dev)
- ergebnis/composer-normalize: ^2.47
- ergebnis/php-cs-fixer-config: ^6.51
- friendsofphp/php-cs-fixer: ^3.85
- phpstan/phpstan: *
- phpunit/phpunit: *
- rector/rector: ^2.1
- roave/security-advisories: dev-latest
Conflicts
- dev-main
- 1.49.0
- 1.48
- 1.47.0
- 1.45.0
- 1.44.2
- 1.44.0
- 1.41
- 1.40.0
- 1.38.0
- 1.37
- 1.13
- 1.12
- 1.11
- 1.10
- 1.9
- 1.8.1
- 1.8
- 1.7
- 1.2
- 1.1
- 1
- 0.42
- 0.41
- 0.40
- 0.39
- 0.38
- 0.37
- 0.9
- 0.8
- 0.7
- 0.6
- 0.5
- dev-fix/postinst-run-tests-in-test-dir
- dev-dependabot/composer/friendsofphp/php-cs-fixer-tw-3.86
- dev-dependabot/composer/ergebnis/php-cs-fixer-config-tw-6.52
- dev-enable-dependabot
- dev-phpunit11
This package is auto-updated.
Last update: 2025-08-23 11:44:11 UTC
README
EasePHP Framework Core
Object oriented PHP Framework for easy&fast writing small/middle sized apps.
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).
- 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
- PEAR packages: pear/mail, pear/mail_mime (Mailer)
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
- 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
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
Links
Homepage: https://www.vitexsoftware.cz/ease.php
GitHub: https://github.com/VitexSoftware/ease-core
phpDocumentor: http://vitexsoftware.cz/php-ease-core/