PHPackages                             xsolve-pl/associate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. xsolve-pl/associate

ActiveLibrary[Database &amp; ORM](/categories/database)

xsolve-pl/associate
===================

This library allows to collect objects and values through associations and provides some entity fetching optimizations for Doctrine ORM to address N+1 queries problem.

v1.0.2(3y ago)519.7k↓33.3%3[2 PRs](https://github.com/xsolve-pl/xsolve-associate/pulls)MITPHPCI failing

Since Oct 26Pushed 3y ago16 watchersCompare

[ Source](https://github.com/xsolve-pl/xsolve-associate)[ Packagist](https://packagist.org/packages/xsolve-pl/associate)[ RSS](/packages/xsolve-pl-associate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (12)Used By (0)

[![Build Status](https://camo.githubusercontent.com/efd8c8a9555f729c6eb07dda56a749db7131238ac1b4460565728d4c7770e95d/68747470733a2f2f7472617669732d63692e6f72672f78736f6c76652d706c2f78736f6c76652d6173736f63696174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/xsolve-pl/xsolve-associate)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0afa4074b559e70ab16d0e506dcfca0dbcc8a728a875e6b86d022c30c1ea1466/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f78736f6c76652d706c2f78736f6c76652d6173736f63696174652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xsolve-pl/xsolve-associate/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/6f6aff059853b515febfab466c629b1a560ea9a42b2ffa7a8849da37ec54dfba/68747470733a2f2f706f7365722e707567782e6f72672f78736f6c76652d706c2f6173736f63696174652f762f737461626c65)](https://packagist.org/packages/xsolve-pl/associate)[![Total Downloads](https://camo.githubusercontent.com/8f34a8f98e3ecf3a70247a158270d79bb17643c3fb3d105b0d223607837bcff8/68747470733a2f2f706f7365722e707567782e6f72672f78736f6c76652d706c2f6173736f63696174652f646f776e6c6f616473)](https://packagist.org/packages/xsolve-pl/associate)[![Monthly Downloads](https://camo.githubusercontent.com/7c51dd2ab8b2908f2855557c77c5c06a2787c182ae53793be432476842b30a62/68747470733a2f2f706f7365722e707567782e6f72672f78736f6c76652d706c2f6173736f63696174652f642f6d6f6e74686c79)](https://packagist.org/packages/xsolve-pl/associate)[![License](https://camo.githubusercontent.com/f69328a187a49e65d6cc41d0e030900e02ff178d76cbca1ef79bbf3d5bfc0aec/68747470733a2f2f706f7365722e707567782e6f72672f78736f6c76652d706c2f6173736f63696174652f6c6963656e7365)](https://packagist.org/packages/xsolve-pl/associate)

Table of contents
=================

[](#table-of-contents)

- [Introduction](#introduction)
- [License](#license)
- [Getting started](#getting-started)
- [Usage examples](#usage-examples)
    - [Collecting associated objects and values](#collecting-associated-objects-and-values)
    - [Efficiently loading associated entities and solving N+1 queries problem](#efficiently-loading-associated-entities-and-solving-N+1-queries-problem)
    - [Deferring association traversal to load entities in bulk](#deferring-association-traversal-to-load-entities-in-bulk)

Introduction
============

[](#introduction)

This library allows to collect objects and values through associations and provides some entity fetching optimizations for Doctrine ORM to address N+1 queries problem.

It can play especially nicely with `Deferred` implementation from `webonyx/graphql-php` allowing to significantly reduce number of database queries.

License
=======

[](#license)

This bundle is under the MIT license. See the complete license in `LICENSE` file.

Getting started
===============

[](#getting-started)

Include this bundle in your project using Composer as follows (assuming it is installed globally):

```
$ composer require xsolve-pl/associate
```

For more information on Composer see its [Introduction](https://getcomposer.org/doc/00-intro.md).

To get the basic collector you may use the facade provided with the library:

```
