php-programmist / file-sql-logger-bundle
Provides service that logs all mutable queries to the file
Installs: 63
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.2.5
- doctrine/dbal: ^2.10
- symfony/config: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/filesystem: ^4.4 || ^5.0
- symfony/http-kernel: ^4.4 || ^5.0
- symfony/yaml: ^4.4 || ^5.0
Requires (Dev)
- symfony/framework-bundle: ^4.4 || ^5.0
- symfony/phpunit-bridge: ^4.4 || ^5.0
This package is auto-updated.
Last update: 2024-05-22 03:15:24 UTC
README
This bundle provides service witch implements SQLLogger interface. With this service you can log all mutating queries (Insert, Update and Delete) of Doctine.
Installation
composer require php-programmist/file-sql-logger-bundle
Usage
//src/Controller/SomeController.php
namespace App\Controller;
use PhpProgrammist\FileSqlLoggerBundle\FileSqlLogger;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class SomeController extends AbstractController
{
public function index(FileSqlLogger $sql_logger)
{
$connection = $this->getDoctrine()->getConnection();
$connection->getConfiguration()->setSQLLogger($sql_logger);
$em = $this->getDoctrine()->getManager();
//make queries for some entities and change it
$em->flush();
...
}
}
Configuration
By default log will be written to folder /sql/. You can change folder via configuration.
Create file config/packages/file_sql_logger.yaml:
file_sql_logger:
path_to_logs: '%kernel.project_dir%/sql/'