Installing Doctrine

The following steps should be performed to install Doctrine:

  1. To install Doctrine, we need to create a file called composer.json in our new blog directory. It lists dependencies of our project as shown in the following code:
    {
        "name": "myname/blog",
        "type": "project",
        "description": "My small blog to play with Doctrine",
    
        "require": {
            "doctrine/orm": "2.4.*"
        },
    
        "autoload": {
            "psr-0": { "": "src/" }
        }
    } 

    This standard JSON file will be parsed by Composer to download and install all dependencies specified. Once installed, Composer will load all classes of these libraries automatically.

    The name, type, and description attributes are optional but it's a good practice to always fill them. They provide general information about the project ...

Get Persistence in PHP with Doctrine ORM now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.