PHP code example of doctrine / mongodb-maker-bundle

1. Go to this page and download the library: Download doctrine/mongodb-maker-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

doctrine / mongodb-maker-bundle example snippets


return [
    // ...
    Doctrine\Bundle\MongoDBMakerBundle\MongoDBMakerBundle::class => ['all' => true],
];



namespace App\Document;

use Doctrine\ODM\MongoDB\Mapping\Attribute as ODM;

#[ODM\Document(collection: 'product', repositoryClass: ProductRepository::class)]
class Product
{
    #[ODM\Id]
    public ?string $id = null;

    #[ODM\Field(type: 'string')]
    private string $name;

    #[ODM\Field(type: 'float')]
    private float $price;

    // Getters and setters...
}
bash
php bin/console list make
bash
php bin/console doctrine:mongodb:schema:update