1. Go to this page and download the library: Download arus/doctrine-bridge 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/ */
arus / doctrine-bridge example snippets
declare(strict_types=1);
use Arus\Doctrine\Bridge\ManagerRegistry;
use Doctrine\Common\Cache\ArrayCache;
use function DI\autowire;
use function DI\create;
use function DI\env;
use function DI\get;
use function DI\string;
return [
'doctrine' => autowire(ManagerRegistry::class),
'doctrine.configuration' => [
'default' => [
'connection' => get('doctrine.configuration.default.connection'),
'metadata_sources' => get('doctrine.configuration.default.metadata_sources'),
'metadata_cache' => get('doctrine.configuration.default.metadata_cache'),
'query_cache' => get('doctrine.configuration.default.query_cache'),
'result_cache' => get('doctrine.configuration.default.result_cache'),
'proxy_dir' => get('doctrine.configuration.default.proxy_dir'),
'proxy_namespace' => get('doctrine.configuration.default.proxy_namespace'),
'proxy_auto_generate' => get('doctrine.configuration.default.proxy_auto_generate'),
'sql_logger' => get('doctrine.configuration.default.sql_logger'),
],
],
'doctrine.configuration.default.connection' => [
'url' => env('DATABASE_URL', 'mysql://user:[email protected]:3306/acme'),
],
'doctrine.configuration.default.metadata_sources' => [string('{app.root}/src/Entity')],
'doctrine.configuration.default.metadata_cache' => get('doctrine.configuration.default.default_cache'),
'doctrine.configuration.default.query_cache' => get('doctrine.configuration.default.default_cache'),
'doctrine.configuration.default.result_cache' => get('doctrine.configuration.default.default_cache'),
'doctrine.configuration.default.default_cache' => create(ArrayCache::class),
'doctrine.configuration.default.proxy_dir' => string('{app.root}/database/proxies'),
'doctrine.configuration.default.proxy_namespace' => 'DoctrineProxies',
'doctrine.configuration.default.proxy_auto_generate' => true,
'doctrine.configuration.default.sql_logger' => null,
];
declare(strict_types=1);
use Symfony\Component\Validator\ContainerConstraintValidatorFactory;
use Symfony\Component\Validator\Validation;
use function DI\factory;
return [
'validator' => factory(function ($container) {
return Validation::createValidatorBuilder()
->enableAnnotationMapping()
->setConstraintValidatorFactory(
new ContainerConstraintValidatorFactory($container)
)
->getValidator();
}),
];
declare(strict_types=1);
namespace App\Entity;
/**
* Import classes
*/
use Arus\Doctrine\Bridge\Validator\Constraint\UniqueEntity;
/**
* @UniqueEntity({"foo"})
*
* @UniqueEntity({"bar", "baz"})
*
* @UniqueEntity({"qux"}, atPath="customPropertyPath")
*
* @UniqueEntity({"quux"}, message="The value {{ value }} already exists!")
*/
class Entry
{
// some code...
}