Code Monkey home page Code Monkey logo

doctrine-orm's Introduction

Website ๐Ÿš€ contributte.org | Contact ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป f3l1x.io | Twitter ๐Ÿฆ @contributte

Usage

To install the latest version of nettrine/orm use Composer.

composer require nettrine/orm

Documentation

For details on how to use this package, check out our documentation.

Versions

State Version Branch Nette PHP
dev ^0.8 master 3.1+ >=8.1
stable ^0.7 master 3.1+ >=7.4

Development

See how to contribute to this package.

This package is currently maintaining by these authors.


Consider to support contributte development team. Also thank you for using this package.

doctrine-orm's People

Contributors

f3l1x avatar fvesely avatar gappa avatar jangalek avatar jankonas avatar janmikes avatar jiripudil avatar josefbenjac avatar juniwalk avatar kedlas avatar khorsky avatar krekos avatar kudrmichal avatar mabar avatar mistrfilda avatar patrickkusebauch avatar paveljanda avatar petrparolek avatar reastyn avatar rikap avatar rixafy avatar roman3349 avatar solcik avatar uestla avatar vody105 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrine-orm's Issues

Mapping interface on entity

There are sometimes use-cases when we don't want to use mapping on Entity class in relations, but rather interface (possibly for decoupling reasons). That is why Doctrine supports ResolveTargetEntityListener (documentation on: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/resolve-target-entity-listener.html).

It would be nice to have such configuration placed in config.neon. Symfony has its own implementation in config.yml (as described on https://symfony.com/doc/current/doctrine/resolve_target_entity.html at the bottom of the page)

We managed to do a workaround by placing the following code inside EntityManagerDecorator:

public function __construct(EntityManagerInterface $wrapped)
	{
		$resolveTargetEntityListener = new ResolveTargetEntityListener();
		$resolveTargetEntityListener->addResolveTargetEntity(UserInterface::class, User::class, []);

		$wrapped->getEventManager()->addEventListener(Events::loadClassMetadata, $resolveTargetEntityListener);
		parent::__construct($wrapped);
	}

It's good enough but people still have to remember that.

OrmExtension

You are using current version of dev-master in our project?

On my project extension still throws this exception "AnnotationReader missing in DIC, please use Nettrine/Annotations or implement own MetadataProvider."

It's because, that getByType method returning still null, because anotation extension set anotation reader as autowired = false.
Look at the docs: https://api.nette.org/2.4/source-DI.ContainerBuilder.php.html#225

I think this is correct:

if (count($builder->findByType(AnnotationReader::class)) === 0) {
	throw new \Exception('AnnotationReader missing in DIC, please use Nettrine/Annotations or implement own MetadataProvider.');
}

Missing "orm:clear-cache:metadata" command

Is there any specific reason, why have you omitted MetadataCommand in OrmConsoleExtension?

I'm using "orm:schema-tool:update" for generating diff, but I've to manually delete cache to have proper results.

Have I missed something in documentation? What is the preferred way to use "orm:schema-tool:update" correctly?

Minimal documentation

@enumag recommended Nettrine as a replacement for Kdyby/Doctrine however, I can't find any information on how to use it. Could you please provide at least some set-up instructions, or a link somewhere where this has been discussed?

Thanks

kdyby/doctrine compatibility/features

Hi,
I love and very often use methods from kdyby/doctrine:
Repository -> findBy, findOneBy, countBy, findPairs
QueryBuilder -> whereCriteria

I know, that you want keep light version of doctrine, so we can add this methods as trait and add replacement of built-in QueryBuilder as option to DI. I can send PR, when you fix #8

Minimal configuration for using Redis as cache

Hi,

as discussed on slack here's the minimal guide to use redis as a doctrine/nettrine cache:

First install contributte/redis package:
composer require contributte/redis

Then register it in neon:

extensions:
	redis: Contributte\Redis\DI\RedisExtension

redis:
	# Setup Tracy panel
	debug: %debugMode%

	connection:
		default:
			uri: tcp://127.0.0.1:6379

			# Options passed directly to Predis\Client
			# https://github.com/nrk/predis#client-configuration
			options: []

and lastly use it as a cache for doctrine:

nettrine.cache:
  driver: Doctrine\Common\Cache\PredisCache

ManagerRegistry::resetManager does not reset the inner EntityManager

Hi,

when I want to reset the entity manager via ManagerRegistry::resetManager, only the decorator gets recreated, the inner EntityManager stays the same.

I guess the solution would be to remove the orm.entityManager service altogether and create it via DI Statement:

In OrmExtension::loadEntityManagerConfiguration()

		// Entity Manager
		$original = new Statement(DoctrineEntityManager::class . '::create', [
			$builder->getDefinitionByType(Connection::class), // Nettrine/DBAL
			$this->prefix('@configuration'),
		]);

		// Entity Manager Decorator
		$builder->addDefinition($this->prefix('entityManagerDecorator'))
			->setFactory($entityManagerDecoratorClass, [$original]);

In generated DI container:

	public function createServiceOrm__entityManagerDecorator(): Nettrine\ORM\EntityManagerDecorator
	{
		return new Nettrine\ORM\EntityManagerDecorator(Doctrine\ORM\EntityManager::create(
			$this->getService('dbal.connection'),
			$this->getService('orm.configuration'),
			$this->getService('dbal.eventManager')
		));
	}

If this approach is OK (or if you suggest another approach), I would gladly prepare a PR. (I know this conflicts with open PR #47, I can wait until it is merged.)

Minimal version of doctrine/orm

There must be better dependency on doctrine/orm.

At this moment it triggers errors on Travis CI.

"doctrine/orm": "^2.5",

It must be higher:

"doctrine/orm": "~2.6.0",

Debug panel

Debug panel with queries. Separate package?

Entities are not loaded in DI extension

Versions:
nettrine/cache v0.1.0
nettrine/dbal v0.6.3
nettrine/orm v0.6.0

Bug Description

Entities from my custom entity are not loaded. It thows Doctrine\Persistence\Mapping\MappingException The class 'Example\Model\Entities\Foo' was not found in the chain configured namespaces App.

I think bug is in https://github.com/nettrine/orm/blob/v0.6.0/src/DI/Traits/TEntityMapping.php

Steps To Reproduce

Register in own DI extension:

<?php

namespace Example\Foo\DI;

use Nette\DI\CompilerExtension;
use Nettrine\ORM\DI\Traits\TEntityMapping;

class FooExtension extends CompilerExtension
{

	use TEntityMapping;

	public function loadConfiguration()
	{
		$builder = $this->getContainerBuilder();
		$config = $this->loadFromFile(__DIR__ . '/config.neon');

		$this->compiler->loadDefinitionsFromConfig($config['services']);

		$this->setEntityMappings([
			'Example\Model\Entities\Foo' => __DIR__ . '/../Model/Entities',
		]);
	}

	public function beforeCompile()
	{
		$builder = $this->getContainerBuilder();
	}
}

Possible Solution

N/A

Bug in doctrine/orm 2.8.2 affects console commands

There was a BC-break introduced in doctrine/orm 2.8.2 - AbstractCommand requires EntityManager: doctrine/orm#8488.

When running db-related commands, following error is thrown:

ErrorException: assert(): assert($em instanceof EntityManager) failed in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:56

It is already fixed (doctrine/orm#8493), so I assume 2.8.3 will be ok.

Maybe it would be worth it to add conflict with 2.8.2 into composer.json?

compatibility with nette 3

I there way to run nettrine/orm with Nette 3?
When i try require with composer nettrine/orm a get conflict:
Problem 1
- Can only install one of: nette/di[v2.4.x-dev, 3.0.x-dev].
- Can only install one of: nette/di[v3.0.0-alpha1, v2.4.x-dev].
- Can only install one of: nette/di[v3.0.0-beta1, v2.4.x-dev].
- Can only install one of: nette/di[v3.0.0-beta2, v2.4.x-dev].
- nettrine/orm 0.3.x-dev requires nette/di ~2.4.14 -> satisfiable by nette/di[v2.4.x-dev].
- Installation request for nettrine/orm ^0.3.0@dev -> satisfiable by nettrine/orm[0.3.x-dev].
- Installation request for nette/di ^3.0 -> satisfiable by nette/di[3.0.x-dev, v3.0.0-alpha1, v3.0.0-beta1, v3.0.0-beta2].

Impossible to set own second level cache

Cannot set own cache configuration factory as service like this:

nettrine.orm.cache:
secondLevelCache: @redisCacheConfigurationFactory::create(%tempDir%)

services:
redisCacheConfigurationFactory: Eshop\Core\Cache\RedisCacheConfigurationFactory(%redis.host%, %redis.port%)

I have to create next service so working result is

services: redisCacheConfigurationFactory: Eshop\Core\Cache\RedisCacheConfigurationFactory(%redis.host%, %redis.port%) redisCacheConfiguration: @redisCacheConfigurationFactory::create(%tempDir%)

nettrine.orm.cache: secondLevelCache: @redisCacheConfiguration

Long time no release

For those of us who prefer the sense of stability coming from tagged releases as opposed to dev-master, would you care to tag a new one? I've stumbled upon a bug in 0.1 that breaks the default (!) configuration (wrong is_subclass_of in OrmCacheExtension) and that is hopefully fixed in master by 62526fb. Thank you :)

Incompatible with latest doctrine

Laster version of doctrine orm (2.7.3) is not compatible due to namespaces changes Doctrine\Common\Persistence -> Doctrine\Persistence which is cause by dependency: "doctrine/common": "^2.11 || ^3.0",

To fix this probem, had to define doctrine orm 2.7.2 in my project.

So, just to inform you

RFC: change mapping to chain mapper

I would like to change internal mapping driver to DriverChain. It would be more suitable for separate extensions, each could register own mapper, or for modular system.

Snippet from doc: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/advanced-configuration.html#multiple-metadata-sources

$chain = new DriverChain(); 
$chain->addDriver($xmlDriver, 'Doctrine\Tests\Models\Company'); 
$chain->addDriver($yamlDriver, 'Doctrine\Tests\ORM\Mapping');

Improving error message when Reader not found

I fought with exception Missing Reader service from \Nettrine\ORM\DI\OrmAnnotationsExtension::loadConfiguration() - I discovered that the order in which the extensions are registered matters and that it makes sense to register Nettrine\Annotations\DI\AnnotationsExtension before Nettrine\ORM extensions. Maybe the exception message could advise that?

Problem with orm.cache set Memcached with other host and port

Hi,

I would like use orm.cache with memcached with other port and host. I didnt find any method. Can you help me?

I try define service
orm.cache: queryCache: @a2

and
services: a2: class:Doctrine\Common\Cache\MemcachedCache
report me

Service 'orm.cache.queryCache': Reference to missing service 'a2'.

Custom RepositoryFactory cannot be set

Hi, the Nettrine\ORM\DI\OrmExtension class defines in the config schema that the configuration.repositoryFactory property must be a string, but when I use one, the generated service factory passes the string as a literal to the $service->setRepositoryFactory() call, but the method expects an instance of the repository factory. If I set the repository factory to a Neon entity instead (basically just append () to the class name) schema validation fails, because I'm no longer passing a string where one is expected.

Workaround: set the repository factory manually in services:

services:
  # ...
  nettrine.orm.configuration:
    alteration: true
    setup:
      - setRepositoryFactory(My\Repository\Factory())

I'll look into writing a PR to fix this, but it won't be today..

OrmAnnotations cache option does not accept Statement

I've following code:

cache: @App\Factories\CacheFactory::createDoctrineCache('Doctrine.Annotations')

Exception given: The option 'orm.annotations โ€บ cache' expects to be string or null, object Nette\DI\Definitions\Statement given

Any ETA on stable version supporting PHP 8?

Hi, nettrine/orm is not compatible with PHP 8, because:
it has dependency doctrine/common: ^2.13.1,
which is compatible with doctrine/orm version 2.7.5, because it has dependencies

php: ^7.1
doctrine/common: ^2.11 || ^3.0

but doctrine/orm version 2.8.0, has dependencies

php: ^7.2|^8.0
doctrine/common: ^3.0

and because of this clash, composer enforces usage of doctrine/orm < 2.8.0, which is not compatible with PHP 8.
I hope having
doctrine/common: ^2.13.1 || ^3.0
instead of
doctrine/common: ^2.13.1
would solve it.

installation failed

Problem 1
- symfony/console v4.1.1 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.1.0 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.0.9 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.0.8 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.0.12 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.0.11 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- symfony/console v4.0.10 requires php ^7.1.3 -> your PHP version (7.1.17-0ubuntu0.17.10.1) overridden by "config.platform.php" version (7.1) does not satisfy that requirement.
- nettrine/orm v0.2.1 requires symfony/console ^4.0.8 -> satisfiable by symfony/console[v4.0.10, v4.0.11, v4.0.12, v4.0.8, v4.0.9, v4.1.0, v4.1.1].
- Installation request for nettrine/orm ^0.2.1 -> satisfiable by nettrine/orm[v0.2.1]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.