wulfheart/laravel-actions-ide-helper
Install the package as a dev dependency:
composer require --dev wulfheart/laravel-actions-ide-helper
Run the Artisan command to generate IDE helper files:
php artisan ide-helper:actions
First Use Case:
After installation, immediately generate IDE helpers for your existing app/Actions classes. This will enable autocompletion for:
Handle method parameters)Verify the generated stubs appear in bootstrap/cache/ide-helper-actions.php (or your configured cache path).
Development Setup:
composer require --dev wulfheart/laravel-actions-ide-helper
php artisan ide-helper:actions
Add to composer.json for automatic regeneration:
"scripts": {
"post-autoload-dump": [
"@php artisan ide-helper:actions"
]
}
IDE Configuration (PHPStorm example):
Settings > Languages & Frameworks > PHP > Stub filesbootstrap/cache/ide-helper-actions.phpAction Class Structure:
namespace App\Actions;
use App\Models\User;
use Illuminate\Support\Facades\Log;
class CreateUserAction
{
public function handle(string $name, string $email): User
{
// IDE will now show:
// - $name and $email as parameters
// - User as return type
// - Method signature autocompletion
}
}
Action Service Integration:
When using ActionService, IDE helpers will autocomplete:
$action = app(ActionService::class)
->run(new CreateUserAction(), [
'name' => '', // Autocompleted as string
'email' => '' // Autocompleted as string
]);
Dependency Injection: For constructor-injected dependencies:
class ProcessOrderAction
{
public function __construct(
private readonly OrderRepository $orders,
private readonly PaymentGateway $gateway
) {}
public function handle(Order $order): void
{
// IDE shows $orders and $gateway as available
}
}
Return Type Handling: Complex return types (collections, custom objects) are properly typed:
public function getUsers(): Collection
public function validateRequest(Request $request): void
Custom Action Locations:
Override default scan paths via config (config/ide-helper-actions.php):
'paths' => [
app_path('Actions'),
app_path('Domain/Actions'),
],
Excluding Actions:
Use skip config to exclude specific actions:
'skip' => [
'App\Actions\Deprecated\*',
],
CI/CD Integration: Add to GitHub Actions or GitLab CI:
- name: Generate IDE Helpers
run: php artisan ide-helper:actions
Missing Stub Files:
php artisan ide-helper:actions manuallyIDE Not Recognizing Helpers:
Settings > PHP > Stub files)Dependency Conflicts:
lorisleiva/lody or phpdocumentor/reflectioncomposer why-not to resolve conflicts or lock versionsActions Not Scanned:
app/Actions pathconfig/ide-helper-actions.phpPerformance Issues:
Verify Generation:
php artisan ide-helper:actions --verbose
Check output for scanned files and any errors.
Manual Stub Inspection:
Open bootstrap/cache/ide-helper-actions.php to verify:
// Should contain class definitions like:
class_alias('App\Actions\CreateUserAction', 'App\Actions\CreateUserAction');
IDE-Specific Issues:
Cache Path:
Defaults to bootstrap/cache/ide-helper-actions.php
Override via config:
'cache_path' => storage_path('framework/cache/ide-helpers.php'),
File Naming:
Generated file uses ide-helper-actions.php by default
Customize via config:
'filename' => 'actions-ide-helpers.php',
Custom Action Classes: Extend the helper to support custom Action implementations:
// In ServiceProvider
$this->app->bind('ide-helper-actions', function ($app) {
return new CustomActionHelper();
});
Pre/Post Generation Hooks: Add logic before/after generation:
// config/ide-helper-actions.php
'hooks' => [
'pre_generate' => function () {
// Custom logic
},
'post_generate' => function () {
// Post-processing
}
],
Custom Reflection: Override reflection logic for special cases:
// In ServiceProvider
$this->app->singleton('ide-helper-actions.reflection', function () {
return new CustomReflectionService();
});
Exclude Test Actions:
'skip' => [
'tests/Actions/*',
],
Parallel Generation: For large codebases, consider running in parallel:
php artisan ide-helper:actions --parallel
Cache Generated Files:
Add to .gitignore to avoid committing:
bootstrap/cache/ide-helper-actions.php
Action Service Integration:
When using ActionService, ensure your IDE is configured to recognize the service container resolution.
Dynamic Actions: For dynamically resolved actions, regenerate helpers after adding new actions:
php artisan ide-helper:actions --force
Laravel 13+ Compatibility: If using Laravel 13+, ensure you're on v0.11.0+:
composer require wulfheart/laravel-actions-ide-helper:^0.11
How can I help you explore Laravel packages today?