-
Notifications
You must be signed in to change notification settings - Fork 1
Migration Guide
This page lists every breaking change between releases and the exact steps to update.
The 1.1.0 release modernises the package to PHP 8.0+ and PSR-3 v3, fixes a batch of long-standing bugs, and tightens type safety. Most legitimate usages continue to work unchanged.
| Before | After |
|---|---|
| PHP 5.6+ | PHP 8.0+ required |
psr/log 1.1.4 (exact pin) |
psr/log ^3.0 |
If your application uses psr/log v1 transitively (from older libraries),
you may need to upgrade those dependencies too. Composer will refuse to
resolve conflicting psr/log constraints with a clear error message.
Logger::__call() has been removed. The class now implements
Psr\Log\LoggerInterface directly.
// 1.0.x — silently no-op
$logger->banana();
// 1.1.0 — fatal error
$logger->banana();
// → Error: Call to undefined method InitPHP\Logger\Logger::banana()Legitimate PSR-3 calls (emergency() … debug(), log()) are
unaffected.
// 1.0.x — silently produced PHP warnings + likely failed at write time
new FileLogger([]);
// 1.1.0 — throws at construction
new FileLogger([]);
// → InvalidArgumentException: FileLogger requires a non-empty string "path" option.If you previously relied on lazy validation, update your call sites.
// 1.0.x — accepted any string
new PDOLogger(['pdo' => $pdo, 'table' => 'log records']);
// 1.1.0 — throws
new PDOLogger(['pdo' => $pdo, 'table' => 'log records']);
// → InvalidArgumentException: PDOLogger "table" option "log records" is not a valid SQL identifier; expected /^[A-Za-z_][A-Za-z0-9_]*$/.If your existing table name does not match /^[A-Za-z_][A-Za-z0-9_]*$/, you
have three options:
- Rename the table to use only ASCII letters, digits and underscores. This is the recommended path.
-
Subclass
PDOLoggerand override the constructor to skip the regex check — you then take responsibility for safe identifier handling. - Stay on 1.0.x. (Not recommended; 1.0.x is unmaintained.)
The newline used to be at the start of each line; it is now at the end.
| Before (1.0.x) | After (1.1.0) |
|---|---|
<empty first line>\n2026-... [INFO] hello |
2026-... [INFO] hello\n |
If you have tooling that parses the old format, update it to expect a trailing newline on every line and no leading blank line at the top of the file.
The 1.0.x destructor set $this->pdo = null. This had no effect on the
external PDO reference and is removed. If you relied on this for any reason
(closing connections, …), do it explicitly in your application code.
// 1.0.x — InvalidArgumentException could be either SPL or PSR variant
try { $logger->log('verbose', 'x'); } catch (\InvalidArgumentException $e) {}
// 1.1.0 — always the PSR variant
try { $logger->log('verbose', 'x'); } catch (\Psr\Log\InvalidArgumentException $e) {}The PSR class extends SPL InvalidArgumentException, so existing
catch (\InvalidArgumentException $e) blocks still catch it.
The constructor signatures stayed exactly the same:
new FileLogger(['path' => '...']);
new PDOLogger(['pdo' => $pdo, 'table' => 'logs']);
new Logger($a, $b, $c);All eight PSR-3 helpers (emergency(), alert(), …, debug()) and the
generic log() method work the same way.
-
composer.json— bump PHP requirement to>=8.0if needed. - Resolve any transitive
psr/logv1 conflicts (composer why psr/log). - Remove any code that called undocumented dynamic methods on
Logger. - Audit
new FileLogger([...])andnew PDOLogger([...])call sites for missing/invalid options. - Audit any tooling that parses log files for the old leading-newline format.
- Optionally tighten
catch (\InvalidArgumentException $e)blocks aroundlog()calls tocatch (\Psr\Log\InvalidArgumentException $e).
If you need to roll back to 1.0.x temporarily:
composer require "initphp/logger:^1.0"…but be aware that 1.0.x is no longer maintained: bug fixes and security updates land only on the current major.
Breaking changes will be batched into a future 2.0.x release and announced on the package's GitHub Releases page with a dedicated migration section in this wiki.
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