# PHP Annotations Plugin Generator

**Generators** create Doctrine ORM entity metadata, embeddable metadata, and repository classes from PhpStorm Generate-menu actions and file templates.

---

## Generate Doctrine entity and embeddable metadata

**Feature ID:** `DoctrineOrmClassGenerator`  
**Feature Page:** [Generate Doctrine entity and embeddable metadata](https://espend.de/phpstorm/plugin/php-annotations#doctrine-orm-class-generator)  

Adds Generate-menu actions for ORM class metadata and embeddable class metadata.

The class generator inserts the `ORM` alias, adds `Entity` and `Table` metadata, and includes a repository class reference when a matching repository already exists. The embedded-class generator writes `Embeddable` metadata.

### Code Examples

```php
# Entity class output:
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ProductRepository::class)]
#[ORM\Table(name: 'product')]
final class Product
{
}
```

```php
# Embeddable output:
use Doctrine\ORM\Mapping as ORM;

#[ORM\Embeddable]
final class Money
{
}
```

---

## Repository file templates

**Feature ID:** `DoctrineRepositoryTemplates`  
**Feature Page:** [Repository file templates](https://espend.de/phpstorm/plugin/php-annotations#doctrine-repository-templates)  

Repository generation uses internal PhpStorm file templates instead of hard-coded file text.

Symfony projects with DoctrineBundle receive a ServiceEntityRepository-style repository; plain Doctrine projects receive a lightweight EntityRepository-style class.

### Code Examples

```php
# Symfony-style repository:
namespace App\Repository;

use App\Entity\Product;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

final class ProductRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, Product::class);
    }
}
```

---

