PhpStorm 2018.3 Help

Working with 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.

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.

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

    ps symfony doctrine repository completion
  • Call the methods of a specific repository.

    ps symfony doctrine repository methods completion
  • Call the methods of a specific entity fetched from the repository.

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

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

    ps 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 (for Windows and Linux) or ⌘+Click (for macOS) the usage. If both the entity and the repository declarations are located, choose a specific declaration to navigate to from the pop-up menu.

ps symfony doctrine repository navigate implementations

Navigating to declaration is available for fields, too.

ps symfony doctrine repository field navigate implementations
Last modified: 18 December 2018