Weave 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

Common Laravel Package

black/common

Common utilities for Black projects: an abstract Doctrine Manager helper with convenience methods plus simple specification classes (and/or/not). Install via Composer and reuse across apps needing lightweight Doctrine-oriented shared code.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Niche Utility: The package’s core value—Doctrine query specifications—fits projects requiring composable, reusable DQL logic but lacks broader Laravel ecosystem integration (e.g., no Eloquent, HTTP, or caching support). Ideal for monolithic Laravel apps with heavy Doctrine ORM usage where query standardization is a priority.
  • Pattern Alignment: The specification pattern (and/or/not) aligns with domain-driven design (DDD) but may feel overkill for simple queries. Conflicts arise if the project already uses Laravel’s repository pattern or API Platform’s query system.
  • Abstraction Trade-offs: The DoctrineManager abstract class enforces a repository-like structure, which could duplicate Laravel’s existing service container if not carefully scoped.

Integration Feasibility

  • Doctrine Dependency: Requires Doctrine ORM (not Eloquent), adding ~50MB to the vendor directory. Conflicts may arise if the project uses DoctrineBundle or custom Doctrine configurations.
  • Laravel Compatibility: No native Laravel integration (e.g., no service container bindings or Blade helpers). Requires manual setup (e.g., custom service provider, facade, or trait).
  • Query Builder vs. DQL: The package exclusively uses DQL, which may require refactoring if the project prefers Laravel’s Query Builder syntax. Example:
    // Current (Query Builder)
    User::where('active', true)->where('role', 'admin');
    
    // Target (DQL via Specifications)
    $spec = new AndSpecification(
        new FieldEquals('active', true),
        new FieldEquals('role', 'admin')
    );
    $results = $doctrineManager->findBy($spec, User::class);
    
  • Version Risks: The package targets older Doctrine versions (likely <2.10). If the project uses Doctrine 3.x, integration may fail without patches.

Technical Risk

  • Archived Package: No updates since 2017, with 0 dependents and 1 star. Risks include:
    • Security: Unpatched Doctrine CVEs (e.g., CVE-2021-3129).
    • Breaking Changes: Doctrine ORM updates may break DQL syntax.
    • Support: No community or vendor recourse for issues.
  • Undocumented Assumptions: The README lacks:
    • Method signatures (e.g., findBy() parameters).
    • Error handling (e.g., invalid specifications).
    • Performance benchmarks (vs. native queries).
  • Laravel Gaps: Missing:
    • Service container integration (e.g., no bind() examples).
    • Event listeners (e.g., for query logging).
    • Testing utilities (e.g., mocking specifications).

Key Questions

  1. Strategic Fit:
    • Does the project need DQL-based specifications, or would Laravel Scout, Doctrine Criteria, or custom Query Builder traits suffice?
    • Is the specification pattern a team priority, or is this a localized optimization?
  2. Doctrine Adoption:
    • Is Doctrine ORM fully adopted, or is this a hybrid Eloquent/Doctrine project?
    • What’s the Doctrine version alignment (package likely targets <2.10)?
  3. Maintenance Plan:
    • How will the project handle security updates for an archived package?
    • Is there a forking strategy if critical issues arise?
  4. Performance Impact:
    • How do specification-based queries compare to native DQL/Query Builder in benchmarks?
    • Will the abstraction layer introduce unexpected overhead?
  5. Team Readiness:
    • Does the team have experience with the specification pattern?
    • Is there buy-in for adopting a non-Laravel-native solution?

Integration Approach

Stack Fit

  • Primary Use Case: Laravel projects using Doctrine ORM (not Eloquent) that require:
    • Reusable query logic (e.g., admin panels, complex APIs).
    • Standardization across multiple Doctrine repositories.
  • Secondary Use Case: Projects already using abstract repository patterns (e.g., Doctrine\ORM\EntityRepository extensions).
  • Misfit Scenarios:
    • Eloquent-heavy projects: No value; requires Doctrine migration.
    • Simple queries: Overkill for basic where() clauses.
    • API Platform: Uses its own query system (e.g., ApiPlatform\Doctrine\Orm\Filter).

Migration Path

  1. Assessment Phase:
    • Audit top 5 most complex queries to identify DQL repetition.
    • Compare specification-based queries vs. native DQL/Query Builder in a proof-of-concept.
  2. Dependency Setup:
    • Install with a specific version (avoid @stable):
      "require": {
          "black/common": "1.0.0"  // Replace with actual version
      }
      
    • Install Doctrine ORM if missing:
      composer require doctrine/orm "^2.10"
      
  3. Service Provider Integration:
    • Create a custom provider to bind the abstract DoctrineManager:
      // app/Providers/BlackCommonServiceProvider.php
      namespace App\Providers;
      
      use Black\Common\Doctrine\DoctrineManager;
      use Doctrine\ORM\EntityManagerInterface;
      use Illuminate\Support\ServiceProvider;
      
      class BlackCommonServiceProvider extends ServiceProvider
      {
          public function register()
          {
              $this->app->singleton(DoctrineManager::class, function ($app) {
                  return new class($app[EntityManagerInterface::class]) extends DoctrineManager {};
              });
          }
      }
      
    • Register the provider in config/app.php.
  4. Query Layer Adoption:
    • Replace manual DQL with specifications:
      use Black\Common\Doctrine\Specification\AndSpecification;
      use Black\Common\Doctrine\Specification\FieldEquals;
      
      $spec = new AndSpecification(
          new FieldEquals('status', 'active'),
          new FieldEquals('role', 'admin')
      );
      $users = app(DoctrineManager::class)->findBy($spec, User::class);
      
    • Gradual rollout: Start with non-critical queries (e.g., admin filters).
  5. Testing:
    • Write PHPUnit tests for:
      • Specification composition (e.g., AndSpecification with NotSpecification).
      • Query correctness (compare results to native DQL).
      • Performance regression (use doctrine/orm:query-stats).

Compatibility

  • Doctrine Version: Test with the exact Doctrine version used in the project. Use:
    composer why-not black/common
    
    to check constraints. If using Doctrine 3.x, expect breaking changes.
  • Laravel Version: No direct conflicts, but DoctrineBundle may impose constraints.
  • PHP Version: Ensure compatibility (package likely supports PHP 7.1–7.4).

Sequencing

  1. Phase 1: Pilot in a single module (e.g., user management admin panel).
  2. Phase 2: Replace 3–5 repetitive DQL queries with specifications.
  3. Phase 3: Benchmark performance and document patterns.
  4. Phase 4: Train the team via codelabs and pair programming.
  5. Phase 5: Evaluate forking/maintenance if adoption grows.

Operational Impact

Maintenance

  • Short-Term:
    • Low effort: Basic usage (specifications) requires minimal upkeep.
    • Moderate effort: Custom DoctrineManager may need updates for Doctrine ORM changes.
  • Long-Term:
    • High risk: Archived package may require forking for:
      • Security patches (e.g., Doctrine CVEs).
      • Feature gaps (e.g., missing PHP 8+ support).
    • Technical debt: If the project outgrows the package, rewriting logic may be costly.
  • Mitigation:
    • Fork the package early and maintain it internally.
    • Deprecate if the package becomes a liability (e.g., after 2 years).

Support

  • No Vendor Support: Issues must be resolved internally or via community (if any).
  • Debugging Challenges:
    • Undocumented internals: May require reverse-engineering (e.g., Specification::toDql()).
    • DQL complexity: Harder to debug than Query Builder (e.g., no ->toSql()).
  • Workarounds:
    • Extend the package to add logging (e.g., Specification::debug()).
    • Use **Doct
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.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin