pvsaintpe / ltree-bundle

10 stars 5 forks source link

ltree-bundle

Installation:

composer require pvsaintpe/ltree-bundle

Using

  1. Create Entity class:
    
    use Doctrine\Common\Collections\ArrayCollection;
    use Doctrine\ORM\Mapping as ORM;
    use Doctrine\ORM\Mapping\Entity;
    use LTree\Annotation\LTreeChilds;
    use LTree\Annotation\LTreeEntity;
    use LTree\Annotation\LTreeParent;
    use LTree\Annotation\LTreePath;
    use LTree\Repository\LTreeEntityInterface;

/**

  1. Create Repository class:
    
    use Doctrine\ORM\EntityManagerInterface;
    use LTree\Repository\LTreeEntityRepository;

/**

  1. Create Extension via migration

    public function up(Schema $schema) : void
    {
        $this->addSql('CREATE IF NOT EXISTS EXTENSION ltree');
    }
    ...
  2. Configure Doctrine Type via config (packages/doctrine.yaml):

    doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'
        types:
            ltree:  LTree\Types\LTreeType
  3. Configure Bundle via config (bundles.php):

    LTree\LTreeExtensionBundle::class => ['all' => true],