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

Dummy Laravel Package

directorytree/dummy

directorytree/dummy is a Laravel/PHP package providing a lightweight dummy/test utility for generating placeholder data and fixtures. Useful for local development, demos, and automated tests where realistic sample content is needed quickly and consistently.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Test Data Generation: Aligns perfectly with Laravel’s Eloquent factory pattern, offering a lightweight alternative to Laravel’s native Factory or Faker. The package’s HasFactory trait (v1.3.0+) enables stateful factories, critical for complex test scenarios (e.g., simulating failed payments, nested relationships).
  • Decoupling from Laravel: Post-v1.1.0, the package removes Laravel as a hard dependency, making it viable for standalone PHP projects or microservices needing fake data. This is a key differentiator from Laravel’s built-in tools.
  • Laravel 11/12+ Compatibility: Explicit support for Laravel 12 (v1.2.0+) and Laravel 13 (v1.4.0+) ensures seamless integration with modern Laravel ecosystems, including PestPHP and Testbench.
  • Dynamic Data Expansion: Features like generic types (v1.5.1) and factory attribute parity (v1.5.0) enable flexible, reusable test data without hardcoding values.

Integration Feasibility

  • Low-Coupling Design: The package avoids Laravel’s core dependencies, reducing boilerplate and conflicts with other packages. The Arr helper (v1.3.1+) replaces older data_* helpers, aligning with Laravel’s modern conventions.
  • Testbench/PestPHP Integration: Native support for PestPHP (dev dependency) and Testbench compatibility (via orchestra/testbench) make it a drop-in replacement for Laravel’s native factories in test suites.
  • Backward Compatibility: Supports Laravel 11–13, allowing gradual migration from older versions without forcing a full upgrade.
  • Non-Laravel PHP: While not fully optimized for non-Laravel projects, the core Dummy class can be adapted with minimal effort (e.g., replacing Arr::get() with array_key_first()).

Technical Risk

  • Laravel-Specific Features:
    • HasFactory trait and Arr helpers assume familiarity with Laravel’s factory pattern and collection utilities. Non-Laravel projects may require custom wrappers.
    • Risk: Steep learning curve for teams unfamiliar with Laravel’s testing ecosystem.
  • Limited Adoption:
    • 0 dependents and 41 stars suggest low community validation. Compare with alternatives like fakerphp/faker (10K+ stars) or laravel/model-factory (Laravel-native).
    • Risk: Unproven long-term viability; evaluate if the package’s niche features justify adoption.
  • Testing Overhead:
    • Requires orchestra/testbench for Laravel integration tests, adding CI/CD complexity if not already in use.
    • Risk: PestPHP vs. PHPUnit conflicts may arise if the test suite is hybrid.
  • Dynamic State Complexity:
    • Stateful factories (v1.3.0+) improve flexibility but may increase test flakiness if not managed carefully.
    • Risk: Debugging dynamic states could be harder than static factories.

Key Questions

  1. Use Case Validation:
    • Is the primary goal Laravel-specific testing (e.g., replacing Factory::new()) or generic PHP fake data?
    • Does the team need stateful factories (v1.3.0+) or simpler mock data?
  2. Alternatives Assessment:
    • Compare with:
      • fakerphp/faker (more generic, no Laravel ties, higher adoption).
      • laravel/model-factory (Laravel-native, but heavier and tied to framework).
      • mockery/mockery (for mock objects, not fake data).
    • Why not use Laravel’s built-in Factory or Fake?
  3. Migration Effort:
    • What’s the effort to refactor existing factories to use HasFactory?
    • How will this integrate with existing seeders or test suites?
  4. Long-Term Viability:
    • Is the MIT license acceptable? (Yes, but check for hidden dependencies.)
    • What’s the maintenance plan? (Last release: 2025-07-16; no active commits visible.)
    • Are there plans for Laravel 14+ support?
  5. Performance Impact:
    • Will dynamic factories add overhead in large-scale tests (e.g., 10K+ records)?
    • How does it compare to raw Faker usage or Laravel’s Factory?
  6. Team Readiness:
    • Does the team have experience with Laravel’s factory pattern and HasFactory?
    • Is there buy-in for adopting a less mainstream package?

Integration Approach

Stack Fit

Stack Component Fit Level Notes
Laravel 11/12/13 ✅ Full Native support for modern Laravel, including Arr helpers and HasFactory.
Laravel <11 ⚠️ Partial May require shims for Arr helpers or HasFactory.
Non-Laravel PHP ⚠️ Partial Core Dummy class works, but HasFactory and Arr helpers need adapters.
PestPHP ✅ Full Native support (dev dependency); ideal for Pest users.
PHPUnit ✅ Partial Works but lacks Laravel-specific features without testbench.
Symfony/Lumen ⚠️ Partial Possible with custom integration for HasFactory.
CI/CD (GitHub Actions, etc.) ✅ Full Lightweight; no major infrastructure changes needed.

Migration Path

  1. Assessment Phase:

    • Audit existing factories, seeders, and test suites to identify:
      • Static vs. dynamic data needs.
      • Laravel version compatibility.
      • Dependencies on Faker or Laravel’s Factory.
    • Benchmark performance against alternatives (fakerphp/faker, Laravel’s Factory).
  2. Pilot Integration:

    • Start with one test suite or seeder to validate the package’s fit.
    • Example migration:
      // Before (Laravel Factory)
      $user = User::factory()->create(['email' => 'test@example.com']);
      
      // After (DirectoryTree/Dummy)
      $user = Dummy::factory(User::class)->state(['email' => 'test@example.com']);
      
    • Test dynamic states (v1.3.0+):
      $user = Dummy::factory(User::class)->state(['role' => 'admin'])->create();
      
  3. Dependency Updates:

    • Add to composer.json:
      "require-dev": {
        "directorytree/dummy": "^2.0",
        "orchestra/testbench": "^9.0"  // Only if using Laravel tests
      }
      
    • Update phpunit.xml or pest.php to recognize HasFactory:
      <!-- Example for PHPUnit -->
      <php>
        <env name="APP_ENV" value="testing"/>
        <autoLoad>
          <classmap>
            <prefix>DirectoryTree\Dummy</prefix>
          </classmap>
        </autoLoad>
      </php>
      
  4. Refactoring:

    • Phase 1: Replace static factories with Dummy::factory().
    • Phase 2: Migrate to HasFactory for dynamic states:
      use DirectoryTree\Dummy\HasFactory;
      
      class User extends Model {
        use HasFactory;
      }
      
    • Phase 3: Replace data_* helpers with Arr::* (v1.3.1+):
      // Before
      $value = data_get($array, 'user.name');
      
      // After
      $value = Arr::get($array, 'user.name');
      
    • Phase 4: Update test suites to use Dummy for mock data.
  5. CI/CD Adjustments:

    • Ensure testbench and pest are compatible with your CI (e.g., GitHub Actions).
    • Add a composer script to validate factories:
      "scripts": {
        "test:factories": "php artisan dummy:test"  // Hypothetical command
      }
      

Compatibility

Feature Laravel 11 Laravel 12 Laravel 13 Non-Laravel PHP Notes
Basic Factory Usage
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope