PHPackages                             teewurst/psr4-advanced-wildcard-composer-plugin - 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. teewurst/psr4-advanced-wildcard-composer-plugin

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

teewurst/psr4-advanced-wildcard-composer-plugin
===============================================

Adds a parser to enable composer, to be used with wildcards

v3.2.0(2mo ago)1028.0k—7.9%3MITPHPPHP ^7.4|^8.0CI passing

Since Nov 2Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/teewurst/psr4-advanced-wildcard-composer-plugin)[ Packagist](https://packagist.org/packages/teewurst/psr4-advanced-wildcard-composer-plugin)[ RSS](/packages/teewurst-psr4-advanced-wildcard-composer-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (11)Used By (0)

PSR4 Advanced Wildcard Composer Plugin
======================================

[](#psr4-advanced-wildcard-composer-plugin)

Adds a parser so Composer can handle wildcards in your autoload configuration. Because listing every single file by hand is so 2015.

[![CI](https://github.com/teewurst/psr4-advanced-wildcard-composer-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/teewurst/psr4-advanced-wildcard-composer-plugin/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/25c2d3cb7a309f0ae68de10fd86638e656c3aef0d938a61c6b04da3a9cfd4473/68747470733a2f2f636f6465636f762e696f2f67682f74656577757273742f707372342d616476616e6365642d77696c64636172642d636f6d706f7365722d706c7567696e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/teewurst/psr4-advanced-wildcard-composer-plugin)

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

[](#installation)

```
composer require teewurst/psr4-advanced-wildcard-composer-plugin
```

How it works
------------

[](#how-it-works)

Glob patterns and `sprintf` team up to dynamically replace content in the generated autoload file:

- **GLOB braces** define folders dynamically (e.g. `"/modules/{*Domain,*Module}/{*}/src"`)
- **`%s` placeholders** in namespaces match the GLOB findings (e.g. `"My\\Namespace\\%s\\%s\\"`)
- GLOB is case-insensitive on Linux and Windows
- Argument switching works too, though we don't recommend it (e.g. `"My\\Namespace\\%2$s\\%1$s\\"`)
- **IDEs** can't handle advanced wildcards (no auto-complete, no namespace recognition, etc.)
    - Solution: run Composer in `--dev` mode — it generates a `composer.development.json` with all wildcards resolved. Your IDE will love you for it.

### Configuration options

[](#configuration-options)

1. **(Recommended)** Add wildcards to `extra.teewurst/psr4-advanced-wildcard-composer-plugin.autoload.psr-4`
2. Set `extra.teewurst/psr4-advanced-wildcard-composer-plugin` to a truthy value and use wildcards in your default `autoload.psr-4`
3. **File autoload wildcards**: Use patterns in `autoload.files` to include matching files automatically (e.g. `"app/Helpers/{*}.php"` instead of listing each file)

### Example

[](#example)

**composer.json:**

```
{
  "extra": {
    "teewurst/psr4-advanced-wildcard-composer-plugin": {
      "autoload": {
        "psr-4": {
          "My\\Namespace\\%s\\%s\\": "modules/{*Domain,*Module}/{*}/src"
        },
        "files": [
          "app/Helpers/{*}.php"
        ]
      },
      "autoload-dev": {
        "psr-4": {
          "My\\Namespace\\test\\%s\\": "tests/{*}/src"
        }
      }
    }
  }
}
```

**File structure:**

```
|- composer.json
|- modules
   |- BusinessDomain
      |- Calculation
         |- src
      |- Listener
         |- src
   |- DataModule
      |- AWS
         |- src
      |- Mysql
         |- src
   |- SomethingElse

```

**Equivalent to:**

```
{
  "autoload": {
    "psr-4": {
      "My\\Namespace\\BusinessDomain\\Calculation\\": "modules/BusinessDomain/Calculation/src",
      "My\\Namespace\\BusinessDomain\\Listener\\": "modules/BusinessDomain/Listener/src",
      "My\\Namespace\\DataModule\\AWS\\": "modules/DataModule/AWS/src",
      "My\\Namespace\\DataModule\\Mysql\\": "modules/DataModule/Mysql/src"
    }
  }
}
```

Limitations &amp; Performance
-----------------------------

[](#limitations--performance)

A few things to keep in mind:

- **Glob/IO/Performance**: Yes, `dump-autoload` will take a bit longer. That's the price of flexibility.
- **One folder level per replacement**: The plugin is limited to one wildcard level per namespace segment. Adding more would get … interesting.
- **Non-existent folders**: You'll get weird results if folders don't exist. Create them first.

Development (Docker)
--------------------

[](#development-docker)

A Docker Compose setup is included so you don't need PHP or Composer installed locally.

```
# Build the image (PHP 8.5 by default)
docker compose build

# Install dependencies
docker compose run --rm php install

# Run tests
docker compose run --rm php test

# Generate coverage report (coverage.xml)
docker compose run --rm php coverage

# Validate 100% coverage
docker compose run --rm php coverage:check

# Run static analysis (PHPStan)
docker compose run --rm php analyse

# Any other Composer command
docker compose run --rm php update
docker compose run --rm php require some/package
```

To use a different PHP version, set `PHP_VERSION` before building:

```
PHP_VERSION=7.4 docker compose build
PHP_VERSION=7.4 docker compose run --rm php test
```

Contributing
------------

[](#contributing)

1. Create a dummy repository locally and add the plugin as a path dependency:

```
"repositories": [
  {
    "type": "path",
    "version": "dev-[branch_name]",
    "url": "[path_to_local_wildcard_plugin]/psr4-advanced-wildcard-composer-plugin"
  }
]
```

2. Run `composer require teewurst/psr4-advanced-wildcard-composer-plugin` in your dummy repo
3. Test your changes with `composer dump-autoload`
4. **xDebug users**: Run `export COMPOSER_ALLOW_XDEBUG=1` in your terminal session
5. All contributions must pass `composer test` and `composer analyse`

### CI &amp; Quality

[](#ci--quality)

This project uses GitHub Actions for CI. Every push and pull request runs:

- **Tests** (PHPUnit) on PHP 7.4, 8.2, 8.3, 8.4, and 8.5
- **Static analysis** (PHPStan, level 4)
- **Code coverage** — the build fails if coverage drops below 100%

To require a passing build before merging, enable branch protection in your repo settings: *Settings → Branches → Add rule* and require the "Tests &amp; Coverage" check.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance83

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 52% 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 ~328 days

Recently: every ~484 days

Total

8

Last Release

86d ago

Major Versions

v1.1.0 → v2.02020-11-03

v2.0 → v3.0.02021-04-19

PHP version history (3 changes)v1.1.0PHP ^7.1

v3.0.0PHP ^7.1|^8.0

v3.2.0PHP ^7.4|^8.0

### Community

Maintainers

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

---

Top Contributors

[![teewurst](https://avatars.githubusercontent.com/u/7197260?v=4)](https://github.com/teewurst "teewurst (13 commits)")[![cursoragent](https://avatars.githubusercontent.com/u/199161495?v=4)](https://github.com/cursoragent "cursoragent (6 commits)")[![denga](https://avatars.githubusercontent.com/u/251799?v=4)](https://github.com/denga "denga (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![marek-baron](https://avatars.githubusercontent.com/u/47612293?v=4)](https://github.com/marek-baron "marek-baron (1 commits)")[![rugaard](https://avatars.githubusercontent.com/u/179868?v=4)](https://github.com/rugaard "rugaard (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/teewurst-psr4-advanced-wildcard-composer-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/teewurst-psr4-advanced-wildcard-composer-plugin/health.svg)](https://phpackages.com/packages/teewurst-psr4-advanced-wildcard-composer-plugin)
```

###  Alternatives

[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[mglaman/composer-drupal-lenient

1317.4M15](/packages/mglaman-composer-drupal-lenient)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5341.9M446](/packages/drupal-core-composer-scaffold)[drupal/core-project-message

Adds a message after Composer installation.

2122.6M172](/packages/drupal-core-project-message)[olvlvl/composer-attribute-collector

A convenient and near zero-cost way to retrieve targets of PHP 8 attributes

184108.8k8](/packages/olvlvl-composer-attribute-collector)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)

PHPackages © 2026

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