Doctrine & the Database

We'll email you with updates

This course is in the planning stages

Two episodes down! Booya! And we are super ready to put our new skills to the test! It's finally time to make up app come alive by using Doctrine to connect to a database.

Doctrine is an amazing ORM that works great with Symfony and is super powerful. It also has a reputation for being hard to learn and for making you write a lot of code. But that's changing! Thanks to some recent improvements and Symfony Flex, working with Doctrine has never been easier or more rewarding. So, let's get started!

  • Creating (and updating) Entities with make:entity
  • Generating & using migrations
  • Inserting new data
  • Fetching & Querying for data
  • Doctrine Repositories
  • Custom queries and the query builder
  • Fixtures (Dummy data) using Faker
  • Relationships & Associations

Your Guides

Ryan Weaver

Questions? Conversation?

  • 2018-02-20 weaverryan

    Hey Mauro!

    Yea, these commands are still being updated to work with Symfony 4. The big issue is actually pretty simple: you don't have a bundle in Symfony 4 :). Here are some more details: https://github.com/doctrine....

    So, as you can see there, right now, there are some workarounds, like temporarily creating a bundle. But pretty soon, I hope it will be updated to work without a bundle.

    Cheers!

  • 2018-02-16 Mauro

    Hi guys,
    how can i import an existing database in Symfony 4?
    In Symfony3 you can do:

    php bin/console doctrine:mapping:import --force AppBundle xml
    php bin/console doctrine:generate:entities AppBundle
    php bin/console doctrine:mapping:convert annotation ./src

    but those commands don't work in Symfony4.

    Thanks.

  • 2018-02-13 weaverryan

    Hey ali nizar!

    You can read about all of that here: https://symfony.com/doc/cur.... The configuration in that article will need to be a bit different to support environment variables, but hopefully it will get you started. For autowiring all the entity managers, I would use a bind rule (https://knpuniversity.com/s... to bind to argument names - like $adminEntityManager if you had an em called "admin".

    Cheers!

  • 2018-02-13 weaverryan

    Hey Peter Kosak!

    This is next in the Symfony series - and I want to get it out soon. But, it will be at least several weeks, for two reasons. First, we'll release the Webpack Encore & React tutorials first. And second, there's a pull request on MakerBundle that we really *need* for this tutorial. So, it needs to be merged and released still. But I'll try to get it all done as quickly as possible :).

    Cheers!

  • 2018-02-13 ali nizar

    hi,
    how can i use Multiple Entity Managers and mutiple databases

  • 2018-02-13 Peter Kosak

    When will be this course available? Cant wait