Skip to content

Conversation

@nynka
Copy link

@nynka nynka commented Mar 28, 2025

This PR removes the abandoned Laminas packages (laminas-db, laminas-mail, laminas-log) from the project and suggests replacing them with other alternatives such as monolog/monolog and symfony/mailer. Users of the package can select any logger implementation based on psr/log and use Monolog handlers to get email functionality based on Symfony Mailer instead of relying on the Laminas packages.

Changes:

  1. Remove Laminas Packages:

    • Removed laminas-db, laminas-mail, and laminas-log from composer.json.
  2. Update Configuration:

    • Updated the configuration files to use monolog/monolog and symfony/mailer.
  3. Instructions for Users:

    • Add instructions for users to select any logger implementation based on psr/log and use Monolog handlers for email functionality.

Detailed Changes:

  1. composer.json:

    { "require": { "php": "~8.2.0 || ~8.3.0 || ~8.4.0", "laminas/laminas-diactoros": "^2.26 || ^3.5.0", "psr/log": "^1.1 || ^2.0", }, "require-dev": { "doctrine/doctrine-orm-module": "^4.2.1 || ^5.3 || ^6.0", "laminas/laminas-coding-standard": "^3.0", "laminas/laminas-servicemanager": "^3.23 || ^4.0", "monolog/monolog": "^3.9", "symfony/mailer": "^7.2" }, "suggest": { "monolog/monolog": "Sends your logs to files, sockets, inboxes, databases and various web services", "symfony/mailer": "Symfony's Mailer & Mime components form a powerful system for creating and sending emails" }, }
  2. php/ErrorHeroModule/config/module.config.php:

    use Monolog\Logger; use Monolog\Handler\StreamHandler; use Psr\Log\LoggerInterface; return [ 'service_manager' => [ 'factories' => [ 'ErrorHeroModuleLogger' => function (): LoggerInterface { $logger = new Logger('error-hero-module'); $logger->pushHandler(new StreamHandler('path/to/your.log', Logger::DEBUG)); return $logger; }, ], ], ];
  3. Instructions for Users:

    • To use different logger implementations, ensure it implements psr/log.
    • For email functionality, configure Monolog handlers with Symfony Mailer:
      use Monolog\Logger; use Monolog\Handler\SymfonyMailerHandler; use Symfony\Component\Mailer\Mailer; use Symfony\Component\Mailer\Transport; use Symfony\Component\Mime\Email; $transport = Transport::fromDsn('smtp://localhost'); $mailer = new Mailer($transport); $message = (new Email()) ->from('sender@example.com') ->to('recipient@example.com') ->subject('Error Notification') ->text('An error occurred.'); $logger = new Logger('error-hero-module'); $logger->pushHandler(new SymfonyMailerHandler($mailer, $message, Logger::ERROR));

Testing:

  • Ensure the application works correctly with the new logger and mailer configurations.
  • Verify that error logging and email notifications function as expected.

Note:

  • Users should update their composer.json and configuration files accordingly.
  • Detailed documentation on configuring Monolog and Symfony Mailer can be found in their respective documentation.

Closing:
This PR aims to modernize the package by removing dependencies on abandoned Laminas packages and providing more flexible and widely-used alternatives and support the latest versions of PHP. It also reduces the complexity of the package itself.

@nynka
Copy link
Author

nynka commented Mar 28, 2025

@samsonasik It seems logical to allow the user to choose their preferred logger implementation and then utilize the writers/handlers for notifications specific to that package?

@samsonasik
Copy link
Owner

If that cause extra step, eg: require symfony/* lib, that probably not preferable, except we add option in command line to choose which lib to use, like mezzio-skeleton https://user-images.githubusercontent.com/1011217/90332191-55d32200-dfbb-11ea-80c0-27a07ef5691a.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants