- How do I install the laravel-model-mapper package?
- Install it with Composer using the package name declared in its composer.json: composer require michael-rubel/laravel-model-mapper. Before running it, confirm the canonical composer.json name and the exact require block, because the linked GitHub repository is laravel-loop-functions while the package name references laravel-model-mapper. Verify the tag you pull supports your target Laravel version, since the documented support ceiling is Laravel 10.
- Which Laravel and PHP versions does laravel-model-mapper support?
- At tag 3.4.3 the support ceiling is Laravel 10, and the package required a merged pull request just to widen compatibility with that framework major. The exact require block for php and illuminate/support should be read from composer.json at the tag you intend to use. No confirmed Laravel 11 or Laravel 12 support is documented, so test against your runtime before adopting it.
- How do I map an Eloquent model to a DTO or custom class?
- Mappings are defined in configuration rather than through a discovery convention: you register a model-to-class pair, then the mapper transforms the model's attributes and relationships into your custom class. Typical targets are DTOs, API resources, or view models that keep your domain and transport layers decoupled. Start with one model and one output class, then extend the config as you add mappings.
- Can the mapper transform relationships as well as attributes?
- Yes. The package is described as transforming both attributes and relationships, so you can shape nested data into your DTOs rather than leaking raw Eloquent relations. Keep an eye on lazy loading when relationships are mapped, and eager load anything the mapping touches. Snapshot tests are a good way to lock down the expected relationship output.
- Is laravel-model-mapper safe to use in production?
- Treat it as a code snippet decision rather than a hardened dependency. The package has roughly 17 stars and zero dependents, no ecosystem validation, unverifiable provenance that security review cannot allowlist, and global root-namespace helpers that can collide or stay invisible to static analysis. If you adopt it, fork or wrap it behind your own interface and add tests, so a missing Laravel upgrade does not block you.
- Does the package support Laravel 11 and Laravel 12?
- No. The current support ceiling is Laravel 10, and the Laravel 10 release only landed because an external contributor opened and merged a constraint-bump PR. There is no evidence of a Laravel 11 or Laravel 12 PR, open or merged. Plan for the same Composer conflict at each new framework major, with no guaranteed volunteer to fix it.
- Is laravel-model-mapper actively maintained?
- It is maintained on a single-volunteer, event-driven basis. One merged PR from one contributor bumped a framework constraint, which proves a merge path exists but is not a maintenance program. There is no visible SLA for issue triage, CVE response, or upgrades landing before they block your build. Check whether the repository has been archived since that release before relying on it.
- What are the alternatives to laravel-model-mapper for mapping Eloquent models?
- Consider spatie/laravel-data or a hand-written mapper class that hydrates DTOs from model attributes, optionally using Eloquent casts or accessors. These options have larger user bases, active maintenance, and test suites you can inspect. If you only need array shaping, a toArray pipeline plus a small transformer class is often enough and avoids the dependency entirely.
- How should I test model mapping in my application?
- Write feature tests that build a model with known attributes and relationships, run it through the mapper, and assert the resulting DTO's public properties. Cover nulls, empty relationships, and any attribute transforms to catch regressions during Laravel upgrades. The upstream project shows no evidence of a test suite or CI, so your own tests are the only safety net you get.
- Why is the Composer package name different from the GitHub repository name?
- The Composer name michael-rubel/laravel-model-mapper does not match the linked repository michael-rubel/laravel-loop-functions, and the composer.json name is still unverified. That identity mismatch is a provenance problem: you cannot confidently audit, allowlist, or pin the code you are actually installing. Resolve it before adoption by confirming the canonical composer.json at the tag you intend to use.