PHP code example of byfareska / doctrine-in-wordpress

1. Go to this page and download the library: Download byfareska/doctrine-in-wordpress 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/ */

    

byfareska / doctrine-in-wordpress example snippets


    $config = new Configuration();
    $config->setProxyDir(__DIR__ . '/var/cache');
    $config->setProxyNamespace('EntityProxy');
    $config->setAutoGenerateProxyClasses(true);
    $config->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\AttributeDriver([
        __DIR__ . '/src/Entity'
    ]));

    $metaDataFactory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
    $em = (new \Byfareska\WordpressDoctrineOrm\EntityManagerFactory())->create();
    $metaDataFactory->setEntityManager($em);

    $meta = $metaDataFactory->getMetadataFor(ExampleEntity::class);
    $repository = new ExampleRepository($em, $meta);

    var_dump($repository->findAll());