PHPackages                             kwadwokyeremeh/laravel-package-ide-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kwadwokyeremeh/laravel-package-ide-helper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kwadwokyeremeh/laravel-package-ide-helper
=========================================

Standalone IDE Helper Generator for Laravel Packages - No Laravel Required

v1.0.2(2mo ago)142MITPHPPHP ^8.1

Since Apr 9Pushed 2mo agoCompare

[ Source](https://github.com/kwadwokyeremeh/laravel-package-ide-helper)[ Packagist](https://packagist.org/packages/kwadwokyeremeh/laravel-package-ide-helper)[ RSS](/packages/kwadwokyeremeh-laravel-package-ide-helper/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (4)Versions (4)Used By (2)

Laravel Package IDE Helper
==========================

[](#laravel-package-ide-helper)

A **standalone IDE helper generator and linter** for Laravel packages. Unlike other IDE helper tools, this works **without requiring Laravel application or artisan command access** - perfect for package development!

🎯 Why This Package?
-------------------

[](#-why-this-package)

When developing Laravel packages, you don't have access to `php artisan ide-helper:generate`. This tool solves that by:

- ✅ **No Laravel required** - Works on any PHP codebase
- ✅ **Static analysis** - Analyzes code without bootstrapping Laravel
- ✅ **Package-aware** - Understands Laravel package structure
- ✅ **IDE agnostic** - Works with VS Code, PHPStorm, Vim, etc.
- ✅ **Zero configuration** - Auto-detects namespace, vendor, and structure
- ✅ **Built-in linter** - Catches common issues and enforces best practices

📦 Installation
--------------

[](#-installation)

### As a Development Dependency

[](#as-a-development-dependency)

```
composer require --dev kwadwokyeremeh/laravel-package-ide-helper
```

### Globally

[](#globally)

```
composer global require kwadwokyeremeh/laravel-package-ide-helper
```

🚀 Usage
-------

[](#-usage)

### Generate IDE Helpers

[](#generate-ide-helpers)

Run from your package root:

```
vendor/bin/generate-ide-helper generate .
```

This will:

1. Scan your package for Models, Facades, Commands, etc.
2. Generate IDE helper files in `.idea-ide-helper/`
3. Create PHPDoc stubs for better autocompletion

### Advanced Usage

[](#advanced-usage)

```
# Specify output directory
vendor/bin/generate-ide-helper generate . --output ./ide-helpers

# Use custom config
vendor/bin/generate-ide-helper generate . --config my-config.php

# Generate only models
vendor/bin/generate-ide-helper generate . --models true --facades false --commands false

# Override namespace
vendor/bin/generate-ide-helper generate . --namespace "MyPackage\\Namespace"

# Specify vendor name
vendor/bin/generate-ide-helper generate . --vendor "my-vendor"
```

### Command Options

[](#command-options)

```
generate  [options]

Arguments:
  path                  Path to the Laravel package directory

Options:
  --output, -o          Output directory for IDE helper files (default: .idea-ide-helper)
  --config, -c          Path to configuration file
  --models, -M          Generate model helpers (default: true)
  --facades, -F         Generate facade helpers (default: true)
  --commands, -C        Generate command helpers (default: true)
  --events, -E          Generate event/helpers (default: false)
  --providers, -P       Generate service provider helpers (default: true)
  --namespace, -N       Package namespace (auto-detected if not provided)
  --vendor-name         Vendor name (auto-detected if not provided)
  --inline, -i          Inject PHPDocs directly into model files (recommended!)
  --backup, -b          Create backup before modifying files (use with --inline)
  --help, -h            Show help

```

### 📝 Inline PHPDoc Injection (Recommended)

[](#-inline-phpdoc-injection-recommended)

The `--inline` option injects comprehensive PHPDoc blocks directly into your model files!

**Usage:**

```
# Inject PHPDocs into models
vendor/bin/generate-ide-helper generate . --inline

# With backup
vendor/bin/generate-ide-helper generate . --inline --backup
```

**Example Output:**

```
/**
 * App\Models\User
 *
 * @table users
 *
 * @property int $id (auto-increment)
 * @property string $name
 * @property \Illuminate\Support\Carbon|string|null $email_verified_at
 * @property string|null $settings - User preferences
 * @property float $balance (default: 0.00)
 *
 * @method \Illuminate\Database\Eloquent\Relations\HasMany|Post[] posts()
 * @method static \Illuminate\Database\Eloquent\Builder|User query()
 */
class User extends Model { ... }
```

🔍 Linter
--------

[](#-linter)

The package includes a powerful linter that checks your Laravel package for common issues, best practices, and code quality problems.

### Basic Linting

[](#basic-linting)

```
vendor/bin/generate-ide-helper lint .
```

### Advanced Linting

[](#advanced-linting)

```
# Output as JSON
vendor/bin/generate-ide-helper lint . --format json

# Save report to file
vendor/bin/generate-ide-helper lint . --format file --output lint-report.json

# Only show errors and warnings
vendor/bin/generate-ide-helper lint . --severity warning

# Run only specific checks
vendor/bin/generate-ide-helper lint . --only models --only commands

# Exclude specific checks
vendor/bin/generate-ide-helper lint . --exclude naming --exclude types

# Fail on warnings instead of errors
vendor/bin/generate-ide-helper lint . --fail-on warning

# Use custom config
vendor/bin/generate-ide-helper lint . --config lint-config.php
```

### Lint Command Options

[](#lint-command-options)

```
lint  [options]

Arguments:
  path                  Path to the Laravel package directory

Options:
  --config, -c          Path to configuration file
  --format, -f          Output format: console, json, file (default: console)
  --output, -o          Output file path (for file format)
  --severity, -s        Minimum severity: error, warning, info, hint (default: hint)
  --only                Run only specific checks (e.g., models, commands)
  --exclude             Exclude specific checks
  --fail-on             Exit with error on: error, warning (default: error)

```

### Available Lint Checks

[](#available-lint-checks)

CheckDescription**general**PHP tags, namespaces, strict types, trailing whitespace**models**Fillable/guarded, casts, relationships, table names**facades**Accessor methods, proper facade structure**commands**Signatures, descriptions, handle methods, return types**providers**Register/boot methods, parent calls, config publishing**naming**File names, class names, naming conventions**types**Return types, parameter types, type hints**best\_practices**Security issues, debug functions, hardcoded secrets### Example Lint Output

[](#example-lint-output)

```
┌─────────────────────────────────────────────────────────────┐
│                    Laravel Package Linter                    │
└─────────────────────────────────────────────────────────────┘

Scanning Package
================

─────────────────────────────────────────────────────────────
Lint Results
─────────────────────────────────────────────────────────────

 ❌  Errors (2)

 src/Models/User.php:15 - Model doesn't define $fillable or $guarded.
    This may allow mass assignment vulnerabilities.
    💡 Suggestion: Define protected $fillable = [...] or protected $guarded = ['*'];

 src/Commands/MyCommand.php:1 - Command is missing $signature property.
    💡 Suggestion: Add: protected $signature = 'your:command {argument?} {--option?}';

 ⚠️  Warnings (3)

 src/Models/Post.php:1 - Consider defining $casts property for automatic type conversion.

─────────────────────────────────────────────────────────────
Summary
─────────────────────────────────────────────────────────────

 ┌─────────────────┬───────┐
 │ Metric          │ Count │
 ├─────────────────┼───────┤
 │ Files Scanned   │ 12    │
 │ Total Issues    │ 5     │
 │ ❌ Errors       │ 2     │
 │ ⚠️  Warnings    │ 3     │
 │ ℹ️  Info         │ 0     │
 │ 💡 Hints        │ 0     │
 └─────────────────┴───────┘

 ❌ Found 2 error(s). Please fix them before proceeding.

```

### Lint Configuration

[](#lint-configuration)

Create a custom config file for advanced linting:

```
