Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 1.46 KB

Uri-Doctrine-Type.md

File metadata and controls

56 lines (39 loc) · 1.46 KB

Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!

Uri Documentation

How to use Uri as a Doctrine type

NOTE: You can read more about Doctrine's Embeddables here: Types

To use the Doctrine's type, you have to follow those steps:

  1. Register the type in your Symfony's configuration;
  2. Implement the type in your entity.

STEP 1: Register the type in your Symfony's configuration

Open the file /config/packages/doctrine.yaml.

Add the type to the configuration:

doctrine:
    dbal:
        ...
        types:
            uri: 'SerendipityHQ\Component\ValueObjects\Uri\Bridge\Doctrine\UriType'
    ...

STEP 2: Implement the Uri type in your entity

Implement the uri type in your entity:

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use SerendipityHQ\Component\ValueObjects\Uri\UriInterface;

/**
 * @ORM\Entity()
 */
class User
{
    ...

    /**
     * @var UriInterface
     * @ORM\Column(type="uri")
     */
    private $website;

    ...
}

Do you like this library? Leave a ★ or run composer global require symfony/thanks && composer thanks to say thank you to all libraries you use in your current project, this included!