PHPackages                             hryvinskyi/magento2-production-component-registration - 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. hryvinskyi/magento2-production-component-registration

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

hryvinskyi/magento2-production-component-registration
=====================================================

Magento 2 Composer plugin to generate component registration file in production environments

1.0.1(10mo ago)2227↓22.2%MITPHPPHP ^7.4 || ^8.0

Since Jul 11Pushed 10mo agoCompare

[ Source](https://github.com/hryvinskyi/magento2-production-component-registration)[ Packagist](https://packagist.org/packages/hryvinskyi/magento2-production-component-registration)[ RSS](/packages/hryvinskyi-magento2-production-component-registration/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Magento 2 Performance Optimizer for Component Discovery
=======================================================

[](#magento-2-performance-optimizer-for-component-discovery)

[![Latest Stable Version](https://camo.githubusercontent.com/6e17a9f8b0a36c4e01980038c87793f9bab244ac507dabbc95686cf977e4d73a/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d70726f64756374696f6e2d636f6d706f6e656e742d726567697374726174696f6e2f762f737461626c65)](https://packagist.org/packages/hryvinskyi/magento2-production-component-registration)[![License](https://camo.githubusercontent.com/40ba321ff81cfaa9ee79add05a73aeaac8b6f8da15ba2738c5165d820f75dcb1/68747470733a2f2f706f7365722e707567782e6f72672f68727976696e736b79692f6d6167656e746f322d70726f64756374696f6e2d636f6d706f6e656e742d726567697374726174696f6e2f6c6963656e7365)](https://packagist.org/packages/hryvinskyi/magento2-production-component-registration)

Boost your Magento 2 application startup time by replacing expensive filesystem operations with pre-compiled component mappings in production environments.

Background
----------

[](#background)

Magento 2 applications experience significant startup delays due to an inefficient component discovery mechanism that executes on every request.

### Performance Bottleneck Analysis

[](#performance-bottleneck-analysis)

During application initialization, Magento executes filesystem scanning operations through `NonComposerComponentRegistration.php`. This process involves:

- Dynamic pattern matching across multiple directory structures
- Recursive file system traversal using `glob()` functions
- Real-time loading and execution of discovered registration files

The initialization sequence follows this pattern:

```
$patterns = require __DIR__ . '/registration_globlist.php';
foreach ($patterns as $pattern) {
    $matches = glob($baseDir . $pattern, GLOB_NOSORT);
    array_map(static function ($path) {
        require_once $path;
    }, $matches);
}
```

### Impact on Application Performance

[](#impact-on-application-performance)

This approach creates measurable delays because:

- File system operations block request processing
- Pattern matching scales poorly with project size
- No optimization exists for repeated operations
- Both web requests and CLI operations suffer equally

### Common Scenarios Affected

[](#common-scenarios-affected)

Applications with extensive customizations experience the most impact:

- Large module collections in `app/code` directories
- Multiple custom themes in `app/design`
- Legacy components in `lib/internal`
- Frequent CLI command execution
- Automated deployment processes

Optimization Strategy
---------------------

[](#optimization-strategy)

This package implements environment-aware component registration that switches between development flexibility and production performance.

### Adaptive Registration Mechanism

[](#adaptive-registration-mechanism)

The system operates in two distinct modes:

**Development Environment**: Maintains standard Magento behavior for maximum development flexibility

**Production Environment**: Utilizes pre-generated static registration files that eliminate filesystem scanning

The production optimization creates files structured like:

```
