IntelliJ IDEA 2022.3 Help

Doctrine

Web applications read and persist data to a database. In Symfony, this can be done by using PDO or a custom framework. Many developers are using Doctrine, as Symfony provides good integration for it. The Symfony Plugin provides several code completion and navigation facilities for Doctrine.

Install the required plugins

This functionality relies on the PHP, Symfony Support, and PHP Annotations plugins that should be installed and enabled in your IDE.

The plugins are available only in IntelliJ IDEA Ultimate.

  1. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  2. Switch to the Marketplace tab and use the search field to find the plugins.

  3. Click Install next to each plugin and restart the IDE if prompted.

Code completion for Doctrine schemas, repositories, and entities

In the editor, press Ctrl+Space to invoke code completion and do any of the following:

  • Specify an entry in a YAML database schema.

    Symfony Doctrine schema completion
  • Retrieve a specific repository by means the Doctrine's object manager.

    Symfony Doctrine repository completion
  • Call the methods of a specific repository.

    Symfony Doctrine repository methods completion
  • Call the methods of a specific entity fetched from the repository.

    Symfony Doctrine repository entity completion
  • Create queries on the object/relational model with Doctrine QueryBuilder.

    Symfony Doctrine model entities completion
  • Specify the fields to search by when calling such functions as findBy, findAllBy, or findOneBy.

    Symfony Doctrine repository fields completion

Code navigation for entities and fields

To navigate to the declaration of an entity, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage. If both the entity and the repository declarations are located, choose a specific declaration to navigate to from the popup menu.

Navigate to Symfony Doctrine entity

Navigating to declaration is available for fields, too.

Navigate to Symfony Doctrine fields
Last modified: 01 August 2022