Skip to content

Installation

Muhammet Şafak edited this page May 24, 2026 · 1 revision

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.

Requirements

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.

Install via Composer

composer require initphp/logger

Composer 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']);

Verifying the installation

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).

Updating

composer update initphp/logger

Every release follows Semantic Versioning. The Migration Guide lists every breaking change with its upgrade path.

Uninstalling

composer remove initphp/logger

Composer also offers to remove psr/log if nothing else in your project depends on it.

What's next

  • 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.

Clone this wiki locally