- How do I install calhoun/eloquent-otf in a Laravel application?
- Install it with Composer using composer require calhoun/eloquent-otf. The package follows Laravel package conventions, so its service provider should be auto-discovered; publish any config if the source includes one. Then apply the provided trait or runtime API to the models that need dynamic relations. Verify the Composer constraints against your locked Laravel and PHP versions before writing code.
- What does on the fly mean in calhoun/eloquent-otf — dynamic models or dynamic relationships?
- In this package, on the fly refers to defining Eloquent relationships at runtime rather than declaring them statically in model classes. You can register hasOne, hasMany, belongsTo, and similar relations without editing the model source. It is intended for packages, dynamic dashboards, and flexible apps that need runtime relationship configuration. Read the source to confirm the exact API and whether any model resolution behavior is also included.
- Which Laravel and PHP versions does calhoun/eloquent-otf support?
- Check the composer.json constraints in the repository, because the package is Laravel-first and version support is defined there. The evaluation notes Laravel 9, 10, and 11 with PHP 8.x as presumed but to be confirmed, so do not assume compatibility. Compare the constraints against your application's locked Laravel and PHP versions before installing. If the constraints are stale, treat that as a maintenance signal.
- Do I need to modify existing Eloquent models to use calhoun/eloquent-otf?
- The package's purpose is to avoid editing model classes for dynamic relations, typically by applying a trait or calling a runtime registration API. Keep native Eloquent relations for core aggregates and use OTF only for leaf-domain or context-specific cases. This limits blast radius and keeps the most important parts of the persistence layer explicit. Do not retrofit all existing models as a first step.
- Is calhoun/eloquent-otf safe for production use?
- Treat it as unproven: it is MIT-licensed, single-maintainer, has roughly 72 stars, and shows zero dependents in the ecosystem. That means there is no observable downstream validation. If you proceed, spike it behind a feature flag in one bounded context, require native-Eloquent equivalence tests, and keep a parallel native implementation until a full release cycle passes without incident. Adoption risk and maintenance risk are both high.
- How does calhoun/eloquent-otf affect Larastan and PHPStan static analysis?
- Runtime and magic relationship resolution typically weakens static analysis because dynamically registered relations are not visible to PHPStan or Larastan. You may need baseline entries or phpstan-ignore annotations, which the evaluation flags as a warning sign. If your team enforces strict Larastan in CI, measure the impact before adopting. Prefer explicit native relations where static analyzability matters most.
- Is calhoun/eloquent-otf compatible with Laravel Octane?
- Runtime dynamic resolution can introduce per-request state and static leakage under Octane's long-lived workers, so verify that the package is Octane-safe. Test it under Octane or Swoole if your application uses them, and check for cross-request state in the source. If compatibility is unclear, avoid using it in Octane-served paths. Native Eloquent relations remain the safer default for long-lived workers.
- How should I test relationships defined with calhoun/eloquent-otf?
- Write native-Eloquent equivalence tests: define the same relation natively and via OTF on a sandbox model, then assert identical SQL and results. Run the suite across your supported drivers, such as SQLite, MySQL, and Postgres, because runtime resolution can diverge by driver. Include query-count and edge-case assertions, and keep these tests in CI as a hard gate. The evaluation recommends this as a requirement, not an optional extra.
- What are alternatives to calhoun/eloquent-otf for dynamic Eloquent relationships?
- Alternatives include native Eloquent relation methods, repository or query-builder patterns, and explicit typed persistence such as DTOs and read models. Some teams use dedicated dynamic-relation packages, but evaluate their maintenance and static-analysis impact the same way. If your architecture is moving toward explicit, typed persistence, this package pushes in the opposite direction. Choose based on long-term maintainability, not just convenience.
- How is calhoun/eloquent-otf maintained, and what is the escape hatch if it is abandoned?
- The evaluation describes a single-maintainer OSS project with a 0.45 score, suggesting thin tests, sparse releases, or weak documentation. Before committing, check the last commit, release cadence, test suite, CI coverage, and open issues. The escape hatch is to replace OTF call sites with native Eloquent relations, so limit call sites and wrap usage behind an interface. Audit the source and license first, and avoid spreading OTF across core aggregates.