- Does weirdan/doctrine-psalm-plugin work with Laravel applications?
- It is not Laravel-specific; it improves Psalm analysis for Doctrine ORM code. In Laravel, it helps when you use Doctrine ORM directly, custom Doctrine repositories, or hybrid Eloquent/Doctrine setups. It does not add special support for Eloquent-only patterns like hasManyThrough or accessors.
- How do I install weirdan/doctrine-psalm-plugin in a Laravel project?
- Install it as a dev dependency with composer require --dev weirdan/doctrine-psalm-plugin. Then enable it with vendor/bin/psalm-plugin enable weirdan/doctrine-psalm-plugin. This writes the plugin entry into your psalm.xml configuration. The plugin requires Psalm v4 or v5.
- How do I configure the Doctrine Psalm plugin in psalm.xml?
- The easiest path is the psalm-plugin enable command, which adds the plugin to the plugins array in psalm.xml. You can also manually add the plugin class to that array. Optionally point Psalm at your Doctrine entity paths for stricter analysis. No Laravel-specific hooks are required.
- Which Laravel versions can use this Doctrine Psalm plugin?
- The plugin itself is not tied to a Laravel version; it depends on Psalm v4 or v5 and Doctrine ORM. Laravel 10+ can use Doctrine ORM via doctrine/dbal and doctrine/orm, but older Laravel apps may need to install doctrine/orm separately. Check your Psalm and Doctrine ORM versions for compatibility.
- Will this plugin fix Psalm errors for Eloquent models?
- No, it is focused on Doctrine ORM, not Eloquent. It improves type inference for Doctrine entities, repositories, query builders, and annotations. Eloquent-specific dynamic attributes, relations, and accessors are outside its scope. Use it for Doctrine code paths or hybrid apps, not as an Eloquent Psalm plugin.
- Does the plugin improve type inference for Doctrine repositories and query builders?
- Yes, the plugin adds stubs and type information so Psalm better understands Doctrine repositories, query builders, and annotations. This reduces false positives around dynamic Doctrine behavior such as proxies and metadata. It helps Psalm infer return types from EntityManager::find() and custom repository methods.
- What are the performance implications of using this Psalm plugin?
- Psalm plugins add some analysis overhead, often around 10-30% depending on project size and configuration. For a medium Laravel app, run Psalm in CI with caching and parallel jobs to mitigate the cost. You can exclude tests and migrations from analysis and enable plugin features incrementally.
- How do I test weirdan/doctrine-psalm-plugin or verify it works?
- The package repository includes a composer test command for its own test suite. In your Laravel app, run vendor/bin/psalm after enabling the plugin and compare errors before and after. Start with a baseline Psalm config and check that Doctrine repository and query builder types are inferred correctly. Use Psalm's cache and CI logs to confirm behavior.
- What alternatives exist to weirdan/doctrine-psalm-plugin for Doctrine static analysis?
- PHPStan has a Doctrine extension that provides similar type inference for Doctrine ORM. If your Laravel team uses PHPStan instead of Psalm, that is the natural alternative. For Psalm-only projects, this plugin is the focused Doctrine option. Compare accuracy and maintenance activity before switching tools.
- Is weirdan/doctrine-psalm-plugin actively maintained and safe for production CI?
- The plugin has releases and supports Psalm v4 and v5, but it is a niche package with relatively low star counts. Check the GitHub repository for recent commits, issues, and compatibility with your Doctrine ORM version. For production CI, pin versions, run it in a non-blocking stage first, and monitor Doctrine ORM minor upgrades for breaking changes.