Implementing the Eloquent ORM into Symfony

Installs: 38 107

Dependents: 3

Suggesters: 0

Security: 0

Stars: 115

Watchers: 6

Forks: 32


1.1.0 2020-06-15 10:46 UTC

This package is auto-updated.

Last update: 2020-09-25 20:47:29 UTC


The WouterJEloquentBundle claims to integrate the Eloquent ORM into the Symfony framework.

If you wish to use the Symfony Serializer with Eloquent Models you can check EloquentSerializer.

Build Status

Supported versions

This bundle supports Symfony 4.4 and Laravel ^6.18.

Contribute to this repository to this repository if you want to add support for other versions.


Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require wouterj/eloquent-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

If you're using Symfony Flex, the previous step already got you up and running and you can skip this step! Otherwise, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

// config/bundles.php

return [
    // ...
    WouterJ\EloquentBundle\WouterJEloquentBundle::class => ['all' => true],

Step 3: Configure the Database

To use the Eloquent ORM, configure a connection by setting the correct environment variables in .env.local:

# .env.local

If you're not using Symfony Flex, create the configuration file yourself:

# config/packages/eloquent.yaml
    driver:   mysql
    host:     localhost
    database: db_name
    username: root
    password: pass
    prefix:   ~

For more information, refer to the documentation below.

Table of Content

  1. Installation
    1. Step 1: Download the Bundle
    2. Step 2: Enable the Bundle
    3. Step 3: Configure the Database
  2. Usage
    1. Query Builder
    2. Eloquent ORM
    3. Using Services instead of Facades
  3. Migrations and Seeding
    1. Running seeders
    2. Setting up
    3. Generating migrations
    4. Running migrations
    5. Rolling migrations
    6. Refreshing the database
  4. Using Models in Forms
    1. Binding the Object to the Form
    2. Form Type Guessing
    3. Form Validation
  5. Events and Observers
    1. Register Listeners
    2. Observers
      1. Observers as Services
  6. Configuration
    1. Full configuration
    2. Connections
      1. Drivers
      2. Default connection
    3. Eloquent
    4. Aliases
  7. License
  8. Contributing
  9. Backwards Compatibility


This project is licensed under the MIT license. For more information, see the license file included in this bundle.


I love contributors. You can submit fixes, report bugs, share your opinion, advocate this bundle or just say "hello". I welcome anything that makes this project better.