PHPackages                             samlitowitz/php-collection-generator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. samlitowitz/php-collection-generator

ActiveProject[Utility &amp; Helpers](/categories/utility)

samlitowitz/php-collection-generator
====================================

A tool to generate PHP collection implementations

2.0.0(1y ago)0221Apache-2.0PHPPHP &gt;=7.4

Since Aug 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/samlitowitz/php-collection-generator)[ Packagist](https://packagist.org/packages/samlitowitz/php-collection-generator)[ RSS](/packages/samlitowitz-php-collection-generator/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (10)Versions (5)Used By (1)

PHP Collection Generator
========================

[](#php-collection-generator)

Generate type-safe PHP collections!

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Usage](#usage)
    1. [Configuration](#configuration)
3. [Collection Interfaces and Additional Methods](#collection-interfaces-and-additional-methods)
    1. [Interfaces](#interfaces)
4. [Future Features](#future-features)

Installation
------------

[](#installation)

```
composer require --dev samlitowitz/php-collection-generator
```

Usage
-----

[](#usage)

1. Create a [configuration](#configuration) targeting the type(s) you wish to generate a collection for.
2. Generate the desired collection(s) by running the following command

    ```
    ./vendor/bin/php-collection-generator --config /path/to/php-collection-generator.json generate /path/to/output/dir
    ```

### Configuration

[](#configuration)

A JSON schema for the configuration is available [here](assets/schema/configuration.json). The [`TypeCollection`](src/App/Console/Config/TypeCollection.php) is generated using the example [configuration](example/php-collection-generator.json).

Collection Interfaces and Additional Methods
--------------------------------------------

[](#collection-interfaces-and-additional-methods)

### Interfaces

[](#interfaces)

The generated collection will implement the following interfaces

1. `\Countable`
2. `\Iterator`
3. `\JsonSerializable`

### Additional Methods

[](#additional-methods)

The generated collection includes the following methods in addition to those needed to fulfil the above interfaces

1. `public function toArray(): array`
2. `public function add(\Fully\Qualified\Namespace\Type ...$entities): void`

Future Features
---------------

[](#future-features)

1. Output File Formatting
    1. Configuration options
        1. type-hint member variables
            1. inline
            2. as comment

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~277 days

Total

4

Last Release

581d ago

Major Versions

v1.0.2 → 2.0.02024-11-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/e6d6a1f93b670732d251551067a2e17b9f1a180d164036f0a84896bc95f9edba?d=identicon)[samlitowitz](/maintainers/samlitowitz)

---

Top Contributors

[![samlitowitz](https://avatars.githubusercontent.com/u/4641296?v=4)](https://github.com/samlitowitz "samlitowitz (39 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/samlitowitz-php-collection-generator/health.svg)

```
[![Health](https://phpackages.com/badges/samlitowitz-php-collection-generator/health.svg)](https://phpackages.com/packages/samlitowitz-php-collection-generator)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B13.9k](/packages/symfony-console)[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k455.6M9.6k](/packages/symfony-dependency-injection)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
