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

Php Expose Laravel Package

suin/php-expose

Expose helps PHPUnit tests access private/protected properties and methods in PHP objects. Use a simple fluent API to set non-public attributes and call hidden methods without changing production code. Requires PHP 5.3+ and installs via Composer.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Improved Test Coverage & Maintainability:

    • Enables testing of private/protected methods and properties without refactoring to public visibility, reducing technical debt.
    • Supports agile development by allowing rapid iteration on internal logic without exposing implementation details.
  • Build vs. Buy:

    • Buy: Justifies adoption over custom solutions (e.g., reflection-based hacks) by providing a clean, documented API with minimal maintenance overhead.
    • Build: Avoids reinventing wheel for teams already using PHPUnit; prioritizes focus on core business logic.
  • Use Cases:

    • Legacy Codebases: Safely test deeply nested or tightly coupled classes without invasive changes.
    • Microservices/Monoliths: Isolate unit tests for internal service methods (e.g., validation, transformations) during API refactoring.
    • Security Audits: Verify internal state (e.g., sanitization flags) without exposing sensitive logic to public APIs.
  • Roadmap Alignment:

    • Enables test-driven development (TDD) for PHP projects by bridging gaps in PHPUnit’s native reflection limitations.
    • Supports CI/CD pipelines by reducing flaky tests caused by inaccessible internals.

When to Consider This Package

  • Adopt When:

    • Your team frequently tests private/protected methods but struggles with PHPUnit’s reflection limitations (e.g., ReflectionException for non-public members).
    • You’re maintaining a large codebase where refactoring visibility is costly or risky (e.g., third-party libraries, legacy systems).
    • Test coverage is a priority, but internal logic must remain encapsulated (e.g., for security or design constraints).
    • You need a lightweight, dependency-free solution (no framework lock-in; works with any PHPUnit setup).
  • Look Elsewhere When:

    • Your tests over-rely on exposing internals, signaling potential design smells (e.g., God Objects, overuse of private methods). Consider refactoring to public interfaces or dependency injection.
    • You’re using modern PHP (8.0+) with attributes or magic methods (e.g., __invoke), which may offer native alternatives.
    • Your team prefers mocking frameworks (e.g., Mockery) over direct property/method access for testing.
    • Performance is critical: Reflection-based tools like this add minor overhead (though negligible for unit tests).

How to Pitch It (Stakeholders)

For Executives:

"This package lets our QA and dev teams test internal code safely without exposing sensitive logic or breaking encapsulation. It’s like giving PHPUnit a ‘cheat code’ for private methods—critical for maintaining legacy systems, speeding up development, and reducing technical debt. With minimal setup (just a Composer install), we can improve test coverage and catch bugs earlier, saving time and resources in the long run."

Key Ask:

  • Approval to include in the tech stack for new PHP projects or legacy maintenance.
  • Budget for developer training on best practices (e.g., when not to expose internals).

For Engineering Teams:

*"Expose solves a common pain point in PHPUnit testing: accessing private/protected members without hacky workarounds. Here’s how we’ll use it:

  • Legacy Refactoring: Test critical methods in old codebases without public API changes.
  • CI/CD: Reduce flaky tests by ensuring internal state is verifiable.
  • Security: Validate sanitization/encryption logic without exposing implementation.

Trade-offs:

  • Pros: Zero refactoring, works with any PHPUnit setup, MIT-licensed.
  • Cons: Avoid overusing it—prefer public interfaces where possible. Not a replacement for clean design.

Next Steps:

  1. Add to composer.json and bootstrap PHPUnit.
  2. Document team guidelines (e.g., ‘Expose only for tests’).
  3. Pilot in a high-debt module to measure impact on test coverage."*

Key Ask:

  • Engineering buy-in for adoption in critical projects.
  • QA collaboration to audit test coverage improvements.
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log