Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Metadata Laravel Package

fsi/metadata

DEPRECATED: do not use. FSi Metadata Component reads class configuration metadata from sources like annotations (currently PHP annotations only). Provides a ClassMetadata object and abstract drivers (e.g., annotation driver) to store class/property/method metadata.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Limited Laravel Alignment: The package is Symfony-centric, relying on AnnotationReader and Doctrine\Common\Cache, which require adapters for Laravel’s Illuminate\Contracts\Cache\Store and doctrine/annotations (v1.14+). Laravel’s native attributes (PHP 8+) and service container reduce the need for this package’s abstraction layer.
  • Metadata Use Cases: Fits well for legacy annotation-based systems or multi-source metadata (YAML/XML + annotations), but Laravel’s Eloquent macros, API resources, or attribute-based routing may offer simpler alternatives.
  • Extensibility Tradeoff: While ClassMetadataInterface allows customization, Laravel’s events (e.g., ModelCreating) or deferred services could replace manual metadata loading.

Integration Feasibility

  • Annotation Support: Requires doctrine/annotations + a polyfill for Symfony’s Annotation trait (conflicts with PHP 8 attributes). Example:
    use Doctrine\Common\Annotations\Annotation\Target;
    #[Attribute(Attribute::TARGET_PROPERTY)]
    class Field { ... } // Laravel Attribute + Doctrine-compatible
    
  • YAML/XML Parsing: Needs symfony/yaml/spatie/array-to-xml, adding dependency bloat. Laravel’s native config (JSON/YAML) or spatie/laravel-config-array may suffice.
  • Caching: Laravel’s Cache facade supports multiple backends, but the package’s Doctrine\Common\Cache interface demands a custom adapter (e.g., LaravelCacheAdapter).

Technical Risk

  • Deprecation: High risk due to no maintenance. Forking or migrating to Laravel’s native tools (e.g., Attribute + Reflection) is recommended.
  • Performance: Reflection-based metadata loading is slow; Laravel’s compiled class maps (bootstrap/cache) mitigate this, but caching strategies (e.g., ApcCache) may not align.
  • Complexity: Symfony-specific assumptions (e.g., ContainerAware) require mocking or rewrites, increasing testing overhead.

Key Questions

  1. Value Proposition:

    • Does this solve a unique Laravel problem (e.g., merging YAML + annotations), or are native tools sufficient?
    • Is backward compatibility with Symfony 2 annotations critical?
  2. Alternatives:

    • Laravel Attributes: Replace annotations with #[Attribute] + ReflectionAttribute.
    • Dynamic Proxies: Use Eloquent macros or runtime class generation (e.g., Laravel\SerializableClosure).
    • Existing Packages: nWidart/annotation (Symfony annotations in Laravel) or illuminate/support utilities.
  3. Migration Path:

    • How would metadata be cached (Redis vs. filesystem) to avoid reflection penalties?
    • Could the driver system be adapted to Laravel’s service providers or facades?

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Annotations: Use doctrine/annotations:v1.14 + a wrapper to adapt AnnotationReader to Laravel’s Annotation classes.
    • YAML/XML: Add symfony/yaml/spatie/array-to-xml, but parse once at boot (e.g., in a ServiceProvider) and cache results.
    • Caching: Implement a DoctrineCacheAdapter for Laravel’s Cache facade:
      class LaravelCacheAdapter implements \Doctrine\Common\Cache\Cache {
          public function __construct(private \Illuminate\Contracts\Cache\Store $cache) {}
          public function fetch($id) { return $this->cache->get($id); }
          // Implement remaining methods...
      }
      
  • Service Container:
    • Register MetadataFactory as a Laravel service provider:
      $this->app->singleton(MetadataFactory::class, function ($app) {
          $driver = new AnnotationDriver($app->make(AnnotationReader::class));
          $cache = new LaravelCacheAdapter($app->make('cache.store'));
          return new MetadataFactory($driver, $cache, 'laravel-metadata');
      });
      
    • Bind ClassMetadataInterface to a custom implementation (e.g., LaravelClassMetadata) for Laravel-specific extensions.

Migration Path

  1. Phase 1: Proof of Concept
    • Test annotation parsing with doctrine/annotations + a minimal adapter.
    • Validate YAML/XML support via symfony/yaml and cache integration.
  2. Phase 2: Laravel-Specific Extensions
    • Replace Symfony’s Annotation trait with Laravel’s #[Attribute].
    • Extend ClassMetadataInterface to support Laravel’s events (e.g., ModelCreated) or policies.
  3. Phase 3: Deprecation Plan
    • If adopted, fork the package to add Laravel support or migrate to native tools (e.g., Attribute + Reflection).

Compatibility

  • PHP 8+: Conflicts with Symfony’s Annotation trait; use polyfills or migrate to attributes.
  • Laravel 9+: Native Attribute support reduces dependency on this package.
  • Doctrine Common: Requires doctrine/annotations and doctrine/cache (or adapters).

Sequencing

  1. Assess Alternatives: Compare with Laravel’s native tools (e.g., Attribute + Reflection).
  2. Prototype Core Use Case: Test annotation/YAML parsing in a non-critical module.
  3. Implement Caching: Use Laravel’s Cache facade via adapter.
  4. Extend for Laravel: Customize ClassMetadataInterface for Laravel-specific needs (e.g., Eloquent events).
  5. Deprecate or Fork: If adopted, plan for long-term maintenance or migration.

Operational Impact

Maintenance

  • High Risk: Deprecated package requires active monitoring for breaking changes (e.g., PHP 8+ incompatibilities).
  • Forking: If adopted, maintain a Laravel-compatible fork or migrate to native tools.
  • Dependency Bloat: Adding symfony/yaml, doctrine/annotations, and custom adapters increases composer.json size and build time.

Support

  • Limited Community: No active maintainers; issues would require internal triage.
  • Laravel-Specific Quirks: Debugging Symfony-centric code in a Laravel context may require custom middleware or monkey-patching.
  • Documentation: Nonexistent for Laravel; would need internal wiki or comments in code.

Scaling

  • Performance: Reflection-based metadata loading is slow; caching (e.g., Redis) is critical but adds complexity.
  • Memory Usage: Storing metadata for large classes (e.g., Eloquent models) could bloat memory if not cached.
  • Horizontal Scaling: Cached metadata must be shared across instances (e.g., Redis) to avoid redundant parsing.

Failure Modes

  1. Cache Invalidation: Stale metadata if cache is not cleared (e.g., after class changes).
  2. Annotation Parsing Errors: Malformed annotations/YAML/XML could crash the application.
  3. PHP Version Conflicts: Symfony’s Annotation trait may break in PHP 8.2+.
  4. Dependency Rot: doctrine/annotations or symfony/yaml may introduce security vulnerabilities.

Ramp-Up

  • Learning Curve: Team must understand:
    • Symfony’s AnnotationReader and Doctrine\Common\Cache.
    • Laravel’s Cache facade and doctrine/annotations integration.
    • Custom adapter patterns for DoctrineCacheAdapter.
  • Onboarding: Requires dedicated spike to prototype and document Laravel-specific extensions.
  • Training: Developers unfamiliar with metadata-driven design may struggle with ClassMetadataInterface customization.

Recommendation: Avoid adoption unless legacy Symfony 2 annotations are critical. Prefer Laravel’s native Attribute + Reflection or packages like nWidart/annotation. If adopted, fork and maintain with a clear migration path to native tools.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver