Просмотр исходного кода

initial commit for 0.0.1-alpha

michelphp 18 часов назад
Сommit
2a5ef52c1a

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+vendor/
+composer.lock
+.idea/
+tests/Fixtures/var
+.phpunit.result.cache

+ 373 - 0
LICENSE

@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.

+ 98 - 0
README.md

@@ -0,0 +1,98 @@
+# 📦 PaperORMBundle
+
+**PaperORMBundle** is a Symfony bundle that integrates [PaperORM](https://github.com/michelphp/paper-orm), a lightweight and performant PHP ORM.
+
+PaperORM itself is framework-agnostic.
+This bundle provides seamless integration into Symfony: configuration via `config/packages/`, service wiring, and logger support.
+
+---
+
+## 🚀 Installation
+
+```bash
+composer require michel/paper-orm-bundle:0.0.1-alpha
+```
+
+This will install both the bundle and the core [PaperORM](https://github.com/michelphp/paper-orm).
+
+Then, enable the bundle (if Flex does not do it automatically):
+
+```php
+// config/bundles.php
+return [
+    // ...
+    Michel\PaperORMBundle\PaperORMBundle::class => ['all' => true],
+];
+```
+
+---
+
+## ⚙️ Configuration
+
+Add your configuration in `config/packages/paper_orm.yaml`:
+
+```yaml
+paper_orm:
+  dsn: '%env(resolve:DATABASE_URL)%'
+  debug: '%kernel.debug%'
+  logger: 'paper.logger'
+  entity_dir: '%kernel.project_dir%/src/Entity'
+  migrations_dir: '%kernel.project_dir%/migrations'
+  migrations_table: 'mig_versions'
+```
+
+### Options
+
+| Key                | Type   | Default                           | Description                                 |
+|--------------------| ------ | --------------------------------- |---------------------------------------------|
+| `dsn`              | string | *(required)*                      | Database DSN                                |
+| `debug`            | bool   | `false`                           | Enable verbose debugging                    |
+| `logger`           | string | `null`                            | Service ID of a logger (ex: `paper.logger`) |
+| `entity_dir`       | string | `%kernel.project_dir%/src/Entity` | Path to your entities                       |
+| `migrations_dir`   | string | `%kernel.project_dir%/migrations` | Path to migration files                     |
+| `migrations_table` | string | `mig_versions`                    | Table name used for migration tracking      |
+| `proxy_autoload`   | bool   | `false`                           | Enable Proxy autoload for session           |
+
+---
+
+## 🛠️ Services
+
+After configuration, the following services are available in the container:
+
+* `Michel\PaperORM\EntityManagerInterface`
+* `Michel\PaperORM\EntityManager`
+
+You can inject them directly:
+
+```php
+use Michel\PaperORM\EntityManagerInterface;
+
+final class UserService
+{
+    public function __construct(private EntityManagerInterface $em) {}
+
+    public function createUser(string $name, string $email): void
+    {
+        $user = new User();
+        $user->setName($name)->setEmail($email);
+
+        $this->em->persist($user);
+        $this->em->flush();
+    }
+}
+```
+
+---
+
+## 📖 Documentation
+
+Full ORM usage, entity mapping, and repositories are documented in the main **PaperORM** repository:
+
+👉 [PaperORM Documentation](https://github.com/michel/paper-orm)
+
+---
+
+## 📌 Status
+
+This bundle is in **alpha (0.0.1-alpha)**.
+We welcome early feedback, bug reports, and contributions.

+ 37 - 0
composer.json

@@ -0,0 +1,37 @@
+{
+  "name": "michel/paper-orm-bundle",
+  "description": "PaperORMBundle is a Symfony bundle that integrates PaperORM, a lightweight and performant PHP ORM.",
+  "type": "symfony-bundle",
+  "license": "MPL-2.0",
+  "authors": [
+    {
+      "name": "Michel.F"
+    }
+  ],
+  "autoload": {
+    "psr-4": {
+      "Michel\\PaperORMBundle\\": "src",
+      "Test\\Michel\\PaperORMBundle\\": "tests"
+    }
+  },
+  "require": {
+    "php": ">=7.4",
+    "ext-pdo": "*",
+    "michel/paper-orm": "^0.0.1@alpha",
+    "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
+    "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
+    "symfony/config": "^5.4 || ^6.0 || ^7.0",
+    "symfony/console": "^5.4 || ^6.0 || ^7.0",
+    "symfony/yaml": "^5.4 || ^6.0 || ^7.0",
+    "monolog/monolog": "^2.10|^3.0"
+  },
+  "config": {
+    "allow-plugins": {
+      "dealerdirect/phpcodesniffer-composer-installer": false
+    }
+  },
+  "require-dev": {
+    "phpunit/phpunit": "^9.6|^10.5",
+    "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0"
+  }
+}

+ 51 - 0
config/services.yaml

@@ -0,0 +1,51 @@
+services:
+  _defaults:
+    autowire: true
+    autoconfigure: true
+  paper.stream_handler:
+    class: Monolog\Handler\StreamHandler
+    arguments:
+      - '%kernel.logs_dir%/paper.log'
+      - 'debug'
+
+  paper.logger:
+    class: Monolog\Logger
+    arguments:
+      - 'paper'                 # nom du channel
+      - [ '@paper.stream_handler' ]
+
+  Michel\PaperORM\Collector\EntityDirCollector:
+    factory: ['Michel\PaperORM\Collector\EntityDirCollector', 'bootstrap']
+    arguments:
+      - ['%paper_orm.entity_dir%']
+  Michel\PaperORM\PaperConfiguration:
+    factory: ['Michel\PaperORM\PaperConfiguration', 'fromDsn']
+    arguments:
+      - '%paper_orm.dsn%'
+      - '%paper_orm.debug%'
+    calls:
+          - [ withLogger, [ '@paper.logger' ] ]
+
+  Michel\PaperORM\Migration\PaperMigration:
+    factory: ['Michel\PaperORM\Migration\PaperMigration', 'create']
+    arguments:
+      - '@Michel\PaperORM\EntityManager'
+      - '%paper_orm.migrations_table%'
+      - '%paper_orm.migrations_dir%'
+
+  Michel\PaperORM\EntityManager:
+    factory: ['Michel\PaperORM\EntityManager', 'createFromConfig']
+    arguments:
+      - '@Michel\PaperORM\PaperConfiguration'
+
+  Michel\PaperORM\EntityManagerInterface:
+    alias: Michel\PaperORM\EntityManager
+    public: false
+
+  Michel\PaperORMBundle\Command\:
+    resource: '../src/Command'
+    tags: ['console.command']
+
+  Michel\PaperORMBundle\DataCollector\PaperORMCollector:
+    tags:
+      - { name: data_collector, template: '@PaperORMBundle/data_collector/template.html.twig', id: 'paper_orm' }

+ 22 - 0
phpunit.xml.dist

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit
+        bootstrap="tests/bootstrap.php"
+        colors="true"
+        failOnRisky="true"
+        failOnWarning="true"
+>
+    <testsuites>
+        <testsuite name="bundle">
+            <directory>tests</directory>
+        </testsuite>
+    </testsuites>
+
+    <coverage processUncoveredFiles="true">
+        <include>
+            <directory>src</directory>
+        </include>
+    </coverage>
+    <php>
+        <env name="DATABASE_URL" value="sqlite:///:memory:"/>
+    </php>
+</phpunit>

+ 47 - 0
src/Command/PaperDatabaseCreateCommand.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace Michel\PaperORMBundle\Command;
+
+use Michel\Console\CommandRunner;
+use Michel\PaperORM\Command\DatabaseCreateCommand;
+use Michel\PaperORM\EntityManagerInterface;
+use Michel\PaperORMBundle\Tools\MichelConsoleWrapper;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+
+#[AsCommand(name: 'paper:database:create', description: 'Creates the database configured for PaperORM')]
+class PaperDatabaseCreateCommand extends Command
+{
+    private EntityManagerInterface $em;
+
+
+    public function __construct(EntityManagerInterface  $em)
+    {
+        parent::__construct();
+        $this->em = $em;
+    }
+
+    protected function configure(): void
+    {
+        $this
+            ->setName('paper:database:create')
+            ->setDescription('Creates the database configured for PaperORM')
+            ->addOption('if-not-exists', null, InputOption::VALUE_NONE, 'Only create the database if it does not already exist');
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output): int
+    {
+        $options = [];
+        $ifNotExists = $input->getOption('if-not-exists');
+        if ($ifNotExists) {
+            $options = ['--if-not-exists'];
+        }
+        return MichelConsoleWrapper::executeForSymfony(new DatabaseCreateCommand($this->em), [], $options, function ($message) use ($output) {
+            $output->write($message);
+        });
+    }
+
+}

+ 52 - 0
src/Command/PaperDatabaseDropCommand.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace Michel\PaperORMBundle\Command;
+
+use Michel\Console\CommandRunner;
+use Michel\PaperORM\Command\DatabaseCreateCommand;
+use Michel\PaperORM\Command\DatabaseDropCommand;
+use Michel\PaperORM\EntityManagerInterface;
+use Michel\PaperORMBundle\Tools\MichelConsoleWrapper;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
+
+#[AsCommand(name: 'paper:database:drop', description: 'Drops the configured SQL database',)]
+class PaperDatabaseDropCommand extends Command
+{
+    private EntityManagerInterface $em;
+    private string $env;
+
+
+    public function __construct(EntityManagerInterface $em, ParameterBagInterface $params)
+    {
+        parent::__construct();
+        $this->em = $em;
+        $this->env = $params->get('kernel.environment');
+    }
+
+    protected function configure(): void
+    {
+        $this
+            ->setName('paper:database:drop')
+            ->setDescription('Drops the configured SQL database')
+            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the database drop without asking for confirmation');
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output): int
+    {
+        $options = [];
+        $force = $input->getOption('force');
+        if ($force) {
+            $options = ['--force'];
+        }
+        return MichelConsoleWrapper::executeForSymfony(new DatabaseDropCommand($this->em, strtolower($this->env)), [], $options, function ($message) use ($output) {
+            $output->write($message);
+        });
+    }
+
+
+}

+ 61 - 0
src/Command/PaperDatabaseSyncCommand.php

@@ -0,0 +1,61 @@
+<?php
+
+namespace Michel\PaperORMBundle\Command;
+
+use http\Encoding\Stream;
+use Michel\PaperORM\Collector\EntityDirCollector;
+use Michel\PaperORM\Command\DatabaseCreateCommand;
+use Michel\PaperORM\Command\DatabaseSyncCommand;
+use Michel\PaperORM\EntityManagerInterface;
+use Michel\PaperORM\Migration\PaperMigration;
+use Michel\PaperORMBundle\Tools\MichelConsoleWrapper;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
+
+#[AsCommand(name: 'paper:database:sync', description: 'Update the SQL database structure so it matches the current ORM entities.')]
+class PaperDatabaseSyncCommand extends Command
+{
+    private PaperMigration $migration;
+
+    private EntityDirCollector $entityDirCollector;
+
+    /**
+     * @var string
+     */
+    private $env;
+
+    public function __construct(PaperMigration $migration, EntityDirCollector $entityDirCollector, ParameterBagInterface $params)
+    {
+        parent::__construct();
+        $this->migration = $migration;
+        $this->entityDirCollector = $entityDirCollector;
+        $this->env = $params->get('kernel.environment');
+    }
+
+    protected function configure(): void
+    {
+        $this
+            ->setName('paper:database:sync')
+            ->setDescription('Update the SQL database structure so it matches the current ORM entities.')
+            ->addOption('no-execute', null, InputOption::VALUE_NONE, 'Show the generated SQL statements without executing them.');
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output): int
+    {
+        $options = [];
+        $noExecute = $input->getOption('no-execute');
+        if ($noExecute) {
+            $options = ['--no-execute'];
+        }
+        return MichelConsoleWrapper::executeForSymfony(
+            new DatabaseSyncCommand($this->migration, $this->entityDirCollector, strtolower($this->env)), [], $options, function ($message) use ($output) {
+            $output->write($message);
+        });
+    }
+
+
+}

+ 45 - 0
src/Command/PaperMigrationDiffCommand.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace Michel\PaperORMBundle\Command;
+
+use Michel\PaperORM\Collector\EntityDirCollector;
+use Michel\PaperORM\Command\Migration\MigrationDiffCommand;
+use Michel\PaperORM\Migration\PaperMigration;
+use Michel\PaperORMBundle\Tools\MichelConsoleWrapper;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
+
+#[AsCommand(name: 'paper:migration:diff', description: 'Generate a migration diff for the SQL database')]
+class PaperMigrationDiffCommand extends Command
+{
+    private PaperMigration $migration;
+    private EntityDirCollector $entityDirCollector;
+
+
+    public function __construct(PaperMigration $migration, EntityDirCollector $entityDirCollector)
+    {
+        parent::__construct();
+        $this->migration = $migration;
+        $this->entityDirCollector = $entityDirCollector;
+    }
+
+    protected function configure(): void
+    {
+        $this
+            ->setName('paper:migration:diff')
+            ->setDescription('Generate a migration diff for the SQL database');
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output): int
+    {
+        return MichelConsoleWrapper::executeForSymfony(
+            new MigrationDiffCommand($this->migration, $this->entityDirCollector), [], [], function ($message) use ($output) {
+            $output->write($message);
+        });
+    }
+
+
+}

+ 37 - 0
src/Command/PaperMigrationMigrateCommand.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace Michel\PaperORMBundle\Command;
+
+use Michel\PaperORM\Command\Migration\MigrationMigrateCommand;
+use Michel\PaperORM\Migration\PaperMigration;
+use Michel\PaperORMBundle\Tools\MichelConsoleWrapper;
+use Symfony\Component\Console\Attribute\AsCommand;
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+#[AsCommand(name: 'paper:migration:migrate', description: 'Execute all migrations',)]
+class PaperMigrationMigrateCommand extends Command
+{
+    private PaperMigration $migration;
+
+    public function __construct(PaperMigration $migration)
+    {
+        parent::__construct();
+        $this->migration = $migration;
+    }
+
+    protected function configure(): void
+    {
+        $this
+            ->setName('paper:migration:migrate')
+            ->setDescription('Execute all migrations');
+    }
+
+    protected function execute(InputInterface $input, OutputInterface $output): int
+    {
+        return MichelConsoleWrapper::executeForSymfony(new MigrationMigrateCommand($this->migration), [], [], function ($message) use ($output) {
+            $output->write($message);
+        });
+    }
+}

+ 60 - 0
src/DataCollector/PaperORMCollector.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace Michel\PaperORMBundle\DataCollector;
+
+use Michel\PaperORM\EntityManagerInterface;
+use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\DataCollector\DataCollector;
+
+class PaperORMCollector extends AbstractDataCollector
+{
+
+    private EntityManagerInterface $em;
+    public function __construct(EntityManagerInterface $em)
+    {
+        $this->em = $em;
+    }
+    public function collect(Request $request, Response $response, ?\Throwable $exception = null) : void
+    {
+        $debugger = $this->em->getConnection()->getPdo()->getSqlDebugger();
+        $this->data = [
+            'queries' => [],
+            'count' => 0,
+            'time' => 0,
+        ];
+        if ($debugger) {
+            $this->data = [
+                'queries' => $debugger->getQueries(),
+                'count' => $debugger->getQueryCount(),
+                'time' => $debugger->getTotalTime(),
+            ];
+        }
+    }
+
+    public function getName() : string
+    {
+        return 'paper_orm';
+    }
+
+    public function getQueryCount(): int
+    {
+        return $this->data['count'] ?? 0;
+    }
+
+    public function getTotalTime(): float
+    {
+        return $this->data['time'] ?? 0.0;
+    }
+
+    public function getQueries(): array
+    {
+        return $this->data['queries'] ?? [];
+    }
+
+    public function reset(): void
+    {
+        $this->data = [];
+    }
+}

+ 55 - 0
src/DependencyInjection/Configuration.php

@@ -0,0 +1,55 @@
+<?php
+
+namespace Michel\PaperORMBundle\DependencyInjection;
+
+use Symfony\Component\Config\Definition\Builder\TreeBuilder;
+use Symfony\Component\Config\Definition\ConfigurationInterface;
+final class Configuration implements ConfigurationInterface
+{
+    public function getConfigTreeBuilder(): TreeBuilder
+    {
+        $treeBuilder = new TreeBuilder('paper_orm');
+        $rootNode = $treeBuilder->getRootNode();
+
+        $rootNode
+            ->children()
+            ->scalarNode('dsn')
+            ->info('Database DSN for PaperORM (ex: mysql://user:pass@127.0.0.1:3306/db)')
+            ->isRequired()
+            ->end()
+
+            ->booleanNode('debug')
+            ->info('Enable debug mode (more verbose logging, strict checks)')
+            ->defaultFalse()
+            ->end()
+
+            ->scalarNode('logger')
+            ->info('Logger service ID (set null to disable logging)')
+            ->defaultNull()
+            ->end()
+
+            ->scalarNode('entity_dir')
+            ->info('Directory containing your entities')
+            ->defaultValue('%kernel.project_dir%/src/Entity')
+            ->end()
+
+            ->scalarNode('migrations_dir')
+            ->info('Directory where PaperORM will generate/read migrations')
+            ->defaultValue('%kernel.project_dir%/migrations')
+            ->end()
+
+            ->scalarNode('migrations_table')
+            ->info('Database table name used to track executed migrations')
+            ->defaultValue('mig_versions')
+            ->end()
+
+            ->booleanNode('proxy_autoload')
+            ->info('Enable proxy autoload')
+            ->defaultFalse()
+            ->end()
+            ->end()
+        ;
+
+        return $treeBuilder;
+    }
+}

+ 44 - 0
src/DependencyInjection/PaperORMExtension.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace Michel\PaperORMBundle\DependencyInjection;
+
+use Michel\PaperORM\PaperConfiguration;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Extension\Extension;
+use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\Reference;
+
+final class PaperORMExtension extends Extension implements PrependExtensionInterface
+{
+    public function load(array $configs, ContainerBuilder $container): void
+    {
+
+        $configuration = new Configuration();
+        $config = $this->processConfiguration($configuration, $configs);
+
+
+        $container->setParameter('paper_orm.dsn', $config['dsn']);
+        $container->setParameter('paper_orm.debug', $config['debug']);
+        $container->setParameter('paper_orm.logger', $config['logger']);
+        $container->setParameter('paper_orm.entity_dir', $config['entity_dir']);
+        $container->setParameter('paper_orm.migrations_dir', $config['migrations_dir']);
+        $container->setParameter('paper_orm.migrations_table', $config['migrations_table']);
+        $container->setParameter('paper_orm.proxy_autoload', $config['proxy_autoload'] ?? false);
+
+        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
+        $loader->load('services.yaml');
+
+    }
+    public function prepend(ContainerBuilder $container): void
+    {
+        $container->prependExtensionConfig('twig', [
+            'paths' => [
+                dirname(__DIR__, 2).'/templates' => 'PaperORMBundle'
+            ]
+        ]);
+    }
+
+}
+

+ 21 - 0
src/PaperORMBundle.php

@@ -0,0 +1,21 @@
+<?php
+namespace Michel\PaperORMBundle;
+
+use Michel\PaperORM\Proxy\ProxyFactory;
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+
+final class PaperORMBundle extends Bundle
+{
+    public function boot()
+    {
+        if ($this->container->getParameter('paper_orm.proxy_autoload')) {
+            ProxyFactory::registerAutoloader();
+        }
+    }
+
+    public function getPath() : string
+    {
+        return \dirname(__DIR__);
+    }
+}

+ 8 - 0
src/Resources/config/packages/paper_orm.yaml

@@ -0,0 +1,8 @@
+paper_orm:
+  dsn: '%env(resolve:DATABASE_URL)%'
+  debug: '%kernel.debug%'
+  logger: 'paper.logger'
+  entity_dir: '%kernel.project_dir%/src/Entity'
+  migrations_dir: '%kernel.project_dir%/migrations'
+  migrations_table: 'mig_versions'
+  proxy_autoload: true

+ 28 - 0
src/Tools/MichelConsoleWrapper.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace Michel\PaperORMBundle\Tools;
+
+use Michel\Console\Command\CommandInterface;
+use Michel\Console\CommandParser;
+use Michel\Console\CommandRunner;
+use Michel\Console\Output;
+use Symfony\Component\Console\Command\Command;
+
+final class MichelConsoleWrapper
+{
+
+    public static function executeForSymfony(CommandInterface $command, array $arguments = [], array $options = [], callable $stdout = null): int
+    {
+        $app = new CommandRunner([$command]);
+        $exitCode = $app->run(new CommandParser(array_merge([''], [$command->getName()], $arguments, $options)), new Output($stdout));
+
+        if ($exitCode === CommandRunner::CLI_ERROR) {
+            return Command::FAILURE;
+        }
+        if ($exitCode !== CommandRunner::CLI_SUCCESS) {
+            return Command::INVALID;
+        }
+
+        return Command::SUCCESS;
+    }
+}

+ 59 - 0
templates/data_collector/template.html.twig

@@ -0,0 +1,59 @@
+{% extends '@WebProfiler/Profiler/layout.html.twig' %}
+
+{% block toolbar %}
+    {% set icon %}
+        <svg  xmlns="http://www.w3.org/2000/svg"  width="24"  height="24"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-file-type-sql"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M5 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75" /><path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" /><path d="M18 15v6h2" /><path d="M13 15a2 2 0 0 1 2 2v2a2 2 0 1 1 -4 0v-2a2 2 0 0 1 2 -2z" /><path d="M14 20l1.5 1.5" /></svg>
+        <span class="sf-toolbar-value">{{ collector.queryCount }}</span>
+    {% endset %}
+
+    {% set text %}
+        <div class="sf-toolbar-info-piece">
+            <b>Queries</b>
+            <span>{{ collector.queryCount }}</span>
+        </div>
+        <div class="sf-toolbar-info-piece">
+            <b>Total time</b>
+            <span>{{ '%0.3f'|format(collector.totalTime) }} s</span>
+        </div>
+    {% endset %}
+
+    {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: profiler_url }) }}
+{% endblock %}
+
+{% block menu %}
+    <span class="label">
+        <span class="icon"><svg  xmlns="http://www.w3.org/2000/svg"  width="24"  height="24"  viewBox="0 0 24 24"  fill="none"  stroke="currentColor"  stroke-width="2"  stroke-linecap="round"  stroke-linejoin="round"  class="icon icon-tabler icons-tabler-outline icon-tabler-file-type-sql"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M5 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75" /><path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" /><path d="M18 15v6h2" /><path d="M13 15a2 2 0 0 1 2 2v2a2 2 0 1 1 -4 0v-2a2 2 0 0 1 2 -2z" /><path d="M14 20l1.5 1.5" /></svg>
+</span>
+        <strong>PaperORM</strong>
+    </span>
+{% endblock %}
+
+{% block panel %}
+    <h2>PaperORM Queries</h2>
+
+    <p>
+        <strong>{{ collector.queryCount }}</strong> queries executed
+        in <strong>{{ '%0.3f'|format(collector.totalTime) }} s</strong>
+    </p>
+
+    <table class="alt">
+        <thead>
+        <tr>
+            <th>#</th>
+            <th>SQL</th>
+            <th>Time (s)</th>
+        </tr>
+        </thead>
+        <tbody>
+        {% for query in collector.queries %}
+            <tr>
+                <td>{{ loop.index }}</td>
+                <td><code>{{ query.query }}<code</td>
+                <td>{{ '%0.3f'|format(query.executionTime) }}</td>
+            </tr>
+        {% else %}
+            <tr><td colspan="3"><em>No queries logged</em></td></tr>
+        {% endfor %}
+        </tbody>
+    </table>
+{% endblock %}

+ 43 - 0
tests/BundleIntegrationTest.php

@@ -0,0 +1,43 @@
+<?php
+
+namespace Test\Michel\PaperORMBundle;
+
+use Michel\PaperORM\EntityManagerInterface;
+use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
+use Test\Michel\PaperORMBundle\Fixtures\TestKernel;
+
+final class BundleIntegrationTest extends KernelTestCase
+{
+
+    protected static function getKernelClass(): string
+    {
+        return TestKernel::class;
+    }
+
+    protected function setUp(): void
+    {
+        self::bootKernel();
+    }
+
+    public function testEntityManagerIsWired(): void
+    {
+
+        $container = self::getContainer();
+        $em = $container->get(EntityManagerInterface::class);
+        $this->assertInstanceOf(EntityManagerInterface::class, $em);
+    }
+
+    public function testConfigIsWired()
+    {
+
+        $container = self::getContainer();
+        $this->assertSame('sqlite:///:memory:', $container->getParameter('paper_orm.dsn'));
+        $this->assertTrue($container->getParameter('paper_orm.debug'));
+        $this->assertSame('paper.logger', $container->getParameter('paper_orm.logger'));
+        $this->assertStringEndsWith('/tests/Fixtures/src/Entity', $container->getParameter('paper_orm.entity_dir'));
+        $this->assertStringEndsWith('/tests/Fixtures/migrations', $container->getParameter('paper_orm.migrations_dir'));
+        $this->assertSame('mig_versions', $container->getParameter('paper_orm.migrations_table'));
+        $this->assertFalse($container->getParameter('paper_orm.proxy_autoload'));
+
+    }
+}

+ 142 - 0
tests/CommandTest.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace Test\Michel\PaperORMBundle;
+
+use Michel\PaperORMBundle\Command\PaperDatabaseCreateCommand;
+use Michel\PaperORMBundle\Command\PaperDatabaseDropCommand;
+use Michel\PaperORMBundle\Command\PaperDatabaseSyncCommand;
+use Michel\PaperORMBundle\Command\PaperMigrationDiffCommand;
+use Michel\PaperORMBundle\Command\PaperMigrationMigrateCommand;
+use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
+use Symfony\Component\Console\Tester\CommandTester;
+use Test\Michel\PaperORMBundle\Fixtures\TestKernel;
+use Symfony\Bundle\FrameworkBundle\Console\Application;
+
+class CommandTest extends KernelTestCase
+{
+
+    protected static function getKernelClass(): string
+    {
+        return TestKernel::class;
+    }
+
+    protected function setUp(): void
+    {
+        self::bootKernel();
+    }
+
+    protected function tearDown(): void
+    {
+        $folder = self::$kernel->getContainer()->getParameter('kernel.project_dir') . '/migrations';
+        array_map('unlink', glob("$folder/*.*"));
+    }
+
+    public function testCreateDatabaseCommand(): void
+    {
+        self::bootKernel();
+        $application = new Application(self::$kernel);
+
+        $command = self::$kernel->getContainer()->get(PaperDatabaseCreateCommand::class);
+        $application->add($command);
+
+        $commandTester = new CommandTester($application->find('paper:database:create'));
+        $exitCode = $commandTester->execute([
+            '--if-not-exists' => true,
+        ]);
+
+        $this->assertSame(0, $exitCode, 'Command should return success code 0');
+        $this->assertStringContainsString(
+            '[INFO] The SQL database ":memory:" has been successfully created (if it did not already exist).',
+            $commandTester->getDisplay()
+        );
+    }
+
+    public function testDropDatabaseCommand(): void
+    {
+        self::bootKernel();
+        $application = new Application(self::$kernel);
+
+        $command = self::$kernel->getContainer()->get(PaperDatabaseDropCommand::class);
+        $application->add($command);
+
+        $commandTester = new CommandTester($application->find('paper:database:drop'));
+        $exitCode = $commandTester->execute([
+        ]);
+
+
+        $this->assertSame(1, $exitCode, 'Command should return success code 1');
+        $this->assertStringContainsString(
+            '[ERROR] You must use the --force option to drop the database.',
+            $commandTester->getDisplay()
+        );
+        $exitCode = $commandTester->execute([
+            '--force' => true
+        ]);
+
+        $this->assertSame(0, $exitCode, 'Command should return success code 0');
+        $this->assertStringContainsString(
+            '[OK] The SQL database has been successfully dropped.',
+            $commandTester->getDisplay()
+        );
+    }
+
+    public function testDatabaseSyncCommand(): void
+    {
+        self::bootKernel();
+        $application = new Application(self::$kernel);
+
+        $command = self::$kernel->getContainer()->get(PaperDatabaseSyncCommand::class);
+        $application->add($command);
+
+        $commandTester = new CommandTester($application->find('paper:database:sync'));
+        $exitCode = $commandTester->execute([
+        ]);
+
+
+        $this->assertSame(0, $exitCode, 'Command should return success code 0');
+        $this->assertStringContainsString(
+            'Normal entities : 0',
+            $commandTester->getDisplay()
+        );
+    }
+
+    public function testMigrationDiffCommand(): void
+    {
+        self::bootKernel();
+        $application = new Application(self::$kernel);
+
+        $command = self::$kernel->getContainer()->get(PaperMigrationDiffCommand::class);
+        $application->add($command);
+
+        $commandTester = new CommandTester($application->find('paper:migration:diff'));
+        $exitCode = $commandTester->execute([
+        ]);
+
+        $this->assertSame(0, $exitCode, 'Command should return success code 0');
+        $this->assertStringContainsString(
+            '[INFO] No application migration file was generated — schema already in sync.',
+            $commandTester->getDisplay()
+        );
+    }
+
+    public function testMigrationMigrateCommand(): void
+    {
+        self::bootKernel();
+        $application = new Application(self::$kernel);
+
+        $command = self::$kernel->getContainer()->get(PaperMigrationMigrateCommand::class);
+        $application->add($command);
+
+        $commandTester = new CommandTester($application->find('paper:migration:migrate'));
+        $exitCode = $commandTester->execute([
+        ]);
+
+
+        $this->assertSame(0, $exitCode, 'Command should return success code 0');
+        $this->assertStringContainsString(
+            '[INFO] No migrations to run. The database is already up to date.',
+            $commandTester->getDisplay()
+        );
+
+    }
+}

+ 18 - 0
tests/EntityManagerTest.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace Test\Michel\PaperORMBundle;
+
+use Michel\PaperORM\EntityManager;
+use Michel\PaperORM\PaperConfiguration;
+use PHPUnit\Framework\TestCase;
+
+class EntityManagerTest extends TestCase
+{
+
+    public function testFromDsnCreatesConnection(): void
+    {
+        $em = EntityManager::createFromConfig(PaperConfiguration::fromDsn('sqlite://:memory:'));
+        $this->assertInstanceOf(EntityManager::class, $em);
+    }
+
+}

+ 39 - 0
tests/Fixtures/TestKernel.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace Test\Michel\PaperORMBundle\Fixtures;
+
+use Michel\PaperORMBundle\PaperORMBundle;
+use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\Config\Loader\LoaderInterface;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
+final class TestKernel extends Kernel
+{
+    public function registerBundles(): iterable
+    {
+        return [
+            new FrameworkBundle(),
+            new PaperORMBundle(),
+        ];
+    }
+
+    public function registerContainerConfiguration(LoaderInterface $loader): void
+    {
+        $confDir = __DIR__ . '/config';
+
+        // Charge la config du framework en mode test
+        $loader->load($confDir . '/packages/framework.yaml');
+        $loader->load($confDir . '/packages/paper_orm.yaml');
+        $loader->load($confDir . '/services_test.yaml');
+    }
+
+    public function build(ContainerBuilder $container): void
+    {
+        parent::build($container);
+    }
+
+    public function getProjectDir(): string
+    {
+        return __DIR__;
+    }
+}

+ 3 - 0
tests/Fixtures/config/packages/framework.yaml

@@ -0,0 +1,3 @@
+framework:
+  test: true
+  secret: "test-secret"

+ 7 - 0
tests/Fixtures/config/packages/paper_orm.yaml

@@ -0,0 +1,7 @@
+paper_orm:
+  dsn: '%env(resolve:DATABASE_URL)%'
+  debug: '%kernel.debug%'
+  logger: 'paper.logger'
+  entity_dir: '%kernel.project_dir%/src/Entity'
+  migrations_dir: '%kernel.project_dir%/migrations'
+  migrations_table: 'mig_versions'

+ 9 - 0
tests/Fixtures/config/services_test.yaml

@@ -0,0 +1,9 @@
+services:
+  Michel\PaperORM\EntityManagerInterface:
+    alias: Michel\PaperORM\EntityManager
+    public: true
+  Michel\PaperORMBundle\Command\:
+    resource: '../../../src/Command/*'
+    tags: ['console.command']
+    public: true
+    autowire: true

+ 2 - 0
tests/Fixtures/migrations/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 2 - 0
tests/Fixtures/src/Entity/.gitignore

@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 7 - 0
tests/bootstrap.php

@@ -0,0 +1,7 @@
+<?php
+
+declare(strict_types=1);
+
+require \dirname(__DIR__) . '/vendor/autoload.php';
+
+\date_default_timezone_set('UTC');