pondeplu / acorn-ide-helper
IDE autocompletion for Roots Acorn projects — runs barryvdh/laravel-ide-helper inside WordPress with configuration tuned for Acorn and VS Code / Intelephense.
Package info
git.pondeplu.nl/wordpress/acorn-ide-helper.git
Type:package
pkg:composer/pondeplu/acorn-ide-helper
Requires
- php: >=8.3
- barryvdh/laravel-ide-helper: ^3.7
- roots/acorn: ^5.0|^6.0
Requires (Dev)
- carthage-software/mago: ^1.0
- pondeplu/mago-config: ^1.0
README
IDE autocompletion for Roots Acorn projects. Wraps barryvdh/laravel-ide-helper so it runs inside WordPress, with the configuration and output paths an Acorn install actually needs.
Without it, Order::create(), Product::find() and $order->name are invisible to your editor: those
members don't exist on Illuminate\Database\Eloquent\Model. They're forwarded through __callStatic() to
the query builder, or resolved through __get() against database columns, and a static analyser can only
see what's declared or documented.
Installation
composer require --dev pondeplu/acorn-ide-helper
Acorn auto-discovers the service provider via extra.acorn.providers. Then, from an environment that can
reach the database (the model documentation is generated by reading the schema):
wp acorn ide-helper
That writes _ide_helper.php and _ide_helper_models.php to the Acorn base path. Add both to
.gitignore — they're regenerated, not authored:
_ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
What gets generated
_ide_helper.php holds two things:
- A root-level
class Eloquent extends \Illuminate\Database\Eloquent\Model, whose body spells out everyEloquent\BuilderandQuery\Buildermethod as a realpublic static function. This is wherecreate(),find()andwhere()come from. - The facades —
Illuminate\Support\Facades\Log,DB,Cacheand friends — redeclared in their own namespaces with their static methods written out, which is what makesLog::info()resolve. These are genuine duplicate declarations; see the Intelephense section below.
_ide_helper_models.php documents each model individually: columns as @property, relations as
@property-read, the where* magic as @method static.
How your models reach \Eloquent is what the strategies below decide.
Strategies
_ide_helper.php covers the facades. How your models reach \Eloquent is the part with a real choice in
it, and the answer depends on what your editor does with @mixin. Set strategy in
config/acorn-ide-helper.php (publish it with
wp acorn vendor:publish --provider="Pondeplu\IdeHelper\Providers\IdeHelperServiceProvider"), or
override per run with --strategy=.
docblock (default)
Writes everything into the model's own docblock: columns as @property, relations as @property-read,
the where* magic as @method static — plus the query-builder statics (create, find, where,
updateOrCreate, …) as real @method static tags, supplied by this package's BuilderMethods hook.
One declaration per model and no @mixin anywhere in the resolution path, which is what makes it hold up
in Intelephense on any licence. The cost is a generated docblock of roughly 80–130 lines living in each
model file, which you commit.
The hook's list is curated — Eloquent\Builder and Query\Builder expose over 400 public methods
between them — so if you call something it doesn't cover, add your own ModelHookInterface to
ide-helper.model_hooks beside it.
stub
Leaves models untouched and declares class Order extends \Eloquent {} in _ide_helper_models.php,
alongside the real class.
Verified not to work reliably in Intelephense. It merges the two declarations for completion and for
hover on the class itself, but a call site inside the indexed workspace can still bind the real
declaration — the one without create() — so Order::create() types as mixed. The same file resolves
correctly when opened from outside the workspace, which makes this look like a caching bug rather than the
ambiguity it is. Kept for editors that handle duplicate declarations better than Intelephense does.
mixin
A one-line @mixin IdeHelperOrder per model, with the tags on class IdeHelperOrder {}. Tidiest by far —
nothing declared twice and the models stay readable — but the chain Order → IdeHelperOrder →
\Eloquent is @mixin at every hop, and Intelephense lists @mixin support as Premium. On the free
build it resolves nothing at all. PhpStorm reads it either way.
Pick one per project and commit it. They write different artifacts, so mixing them across a team leaves dangling references behind.
Commands
wp acorn ide-helper # facades + models, using the configured strategy
wp acorn ide-helper --strategy=mixin # override for this run
wp acorn ide-helper --meta # also write .phpstorm.meta.php (PhpStorm only)
The underlying ide-helper:generate, ide-helper:models, ide-helper:meta and ide-helper:eloquent
commands remain available if you need their individual options.