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

Phony Laravel Package

eloquent/phony

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Accelerating Test-Driven Development (TDD) in Legacy Systems: Phony’s support for traits, static methods, and procedural code enables robust mocking in older Laravel/PHP codebases where modern frameworks (e.g., Mockery) may fall short. This justifies its adoption for refactoring projects or integrating legacy systems into new Laravel applications.

  • Build vs. Buy for Custom Mocking Needs: If your team requires advanced mocking features (e.g., generator stubbing, order verification, or HHVM support) that aren’t natively available in PHPUnit or Laravel’s built-in tools, Phony provides a low-code alternative to building in-house solutions. The MIT license and standalone usage reduce vendor lock-in risks.

  • Roadmap for Test Automation and CI/CD: Phony’s zero-configuration integrations with PHPUnit, Kahlan, and Peridot streamline test suite expansion without requiring framework-specific boilerplate. This aligns with initiatives to:

    • Improve test coverage in monolithic Laravel apps.
    • Reduce flaky tests via refined verification output (e.g., diff highlighting).
    • Enable parallel test execution (e.g., in CI pipelines) by supporting isolated mocks.
  • Use Cases for Complex Interactions: Ideal for testing:

    • Service layers with procedural dependencies (e.g., callbacks, closures).
    • Event-driven architectures (e.g., Laravel Events/Listeners) where spies track invocation order.
    • Database interactions via stubbed repositories (e.g., Eloquent models) without hitting a real DB.
    • Third-party APIs where mocking HTTP clients (e.g., Guzzle) requires fine-grained control.

When to Consider This Package

  • Avoid if:

    • Your team uses modern PHP (8.0+) with Laravel’s built-in mocking (e.g., createMock() in PHPUnit) and doesn’t need Phony’s niche features.
    • You’re starting a greenfield project with no legacy code; prefer Mockery or PHPUnit’s native mocks for active maintenance.
    • HHVM support is critical: While Phony had HHVM support, it’s archived and may not align with long-term roadmaps.
    • You need active maintenance: The package is no longer updated (last release: 2021). Evaluate alternatives like:
  • Consider if:

    • You’re maintaining a large Laravel 5.x/6.x codebase with heavy procedural logic or traits.
    • Your tests require generator stubbing, reference argument handling, or order verification.
    • You’re migrating from Phake or need a drop-in replacement for its features.
    • Your team prioritizes debuggable test failures (Phony’s verification output is highly detailed).

How to Pitch It (Stakeholders)

For Executives:

"Phony is a low-risk, high-reward tool to supercharge our test automation*, especially for legacy Laravel systems where traditional mocking frameworks fall short. It lets our team:

  • Write tests faster by reducing boilerplate (e.g., no expect-run-verify anti-patterns).
  • Catch bugs earlier with clearer failure messages (e.g., diffs for argument mismatches).
  • Future-proof our tests by supporting PHP features like generators and traits—critical for refactoring old code. Since it’s MIT-licensed and framework-agnostic, we avoid vendor lock-in while gaining enterprise-grade mocking capabilities. The upfront cost is minimal (Composer install), and the ROI comes from reduced debugging time and higher test coverage in complex areas like event listeners or API integrations."

For Engineering Teams:

*"Phony fills gaps in Laravel’s native testing tools, especially for:

  • Procedural code: Mocking standalone functions, callbacks, or traits (unlike Mockery/PHPUnit).
  • Advanced scenarios: Stubbing generators, verifying call order, or handling reference arguments.
  • Legacy systems: If you’re working with old Laravel versions or third-party libraries, Phony’s feature parity with Phake (but without HHVM baggage) is a safer bet than rolling your own. It integrates seamlessly with PHPUnit/Kahlan/Peridot, so no major toolchain changes are needed. The trade-off? It’s not actively maintained, but for most use cases, the features are stable enough to justify adoption—especially if you’re already using archived packages like Laravel 5.x."

For Developers:

*"If you’re tired of:

  • Flaky tests from expect-run-verify patterns (Phony uses verify-after).
  • Limited mocking in PHPUnit (e.g., no trait support).
  • Debugging hell when tests fail with cryptic messages (Phony’s output highlights exactly what went wrong). …then Phony is worth trying. It’s easier to use than Mockery for complex cases and more powerful than PHPUnit’s mocks. Just install eloquent/phony-phpunit and start mocking functions, classes, or even traits in minutes. Downside: It’s abandoned, but the core features are solid. If you hit a blocker, we can either:
  1. Fork it and maintain our own copy.
  2. Switch to Mockery (but lose some features like generator stubbing)."

Key Ask: "Let’s pilot Phony for one high-complexity module (e.g., payment processing or event dispatching) and measure the impact on test clarity and dev velocity before deciding."

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.
aimeos/prisma
besmartand-pro/php-quality-config
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views