-
Notifications
You must be signed in to change notification settings - Fork 1
Installation
initphp/logger is distributed through Composer. The package has a single
runtime dependency (psr/log), and adds an optional dependency on
ext-pdo when you intend to use the database handler.
| Requirement | Version | Notes |
|---|---|---|
| PHP | >= 8.0 |
Required by psr/log v3 and by the package's typed signatures. |
psr/log |
^3.0 |
Pulled in automatically. |
ext-pdo |
any | Only required if you use PDOLogger. |
ext-pdo_<driver> |
any | The driver matching your database (pdo_mysql, pdo_pgsql, pdo_sqlite, …). |
If you are on PHP 7.x, you cannot use this version of the package; PSR-3 v3 itself requires PHP 8.0+. There are no plans for a back-port branch.
composer require initphp/loggerComposer resolves and installs:
- Installing psr/log (3.0.x)
- Installing initphp/logger (1.x)
The package registers under the namespace InitPHP\Logger\, mapped to src/
via PSR-4 autoloading. You do not need to require any file manually — letting
Composer's vendor/autoload.php handle it is sufficient:
<?php
require __DIR__ . '/vendor/autoload.php';
use InitPHP\Logger\FileLogger;
$logger = new FileLogger(['path' => __DIR__ . '/logs/app.log']);A one-liner is enough:
php -r "require 'vendor/autoload.php'; (new InitPHP\Logger\FileLogger(['path' => '/tmp/initphp.log']))->info('it works'); echo file_get_contents('/tmp/initphp.log');"You should see something like:
2026-05-24T14:08:22+03:00 [INFO] it works
If you see no output and no error, check that /tmp is writable and that the
log line was actually written (the file may be empty if the user lacks write
permissions; PSR-3 calls do not throw on filesystem failures — see
Error Handling).
composer update initphp/loggerEvery release follows Semantic Versioning. The Migration Guide lists every breaking change with its upgrade path.
composer remove initphp/loggerComposer also offers to remove psr/log if nothing else in your project
depends on it.
- Quick Start — your first log line, end to end.
- PSR-3 Compliance — what contract the package implements, and the rules around it.
- FAQ — answers to common pre-install questions.
initphp/logger · MIT License · part of the InitPHP family
Source · Issues · Discussions · Packagist · Contributing · Security Policy
Getting Started
Handlers
PSR-3 Behaviour
Practical Guides
Reference