PHPackages                             aazbeltran/laravel-backpack-phpstan-extension - 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. [Admin Panels](/categories/admin)
4. /
5. aazbeltran/laravel-backpack-phpstan-extension

ActivePhpstan-extension[Admin Panels](/categories/admin)

aazbeltran/laravel-backpack-phpstan-extension
=============================================

PHPStan extension for Laravel Backpack - Adds static analysis support for Backpack CRUD, Basset, and other Backpack components

v1.0.1(11mo ago)0194MITPHPPHP ^8.1|^8.2|^8.3CI failing

Since Aug 29Pushed 11mo agoCompare

[ Source](https://github.com/aazbeltran/laravel-backpack-phpstan-extension)[ Packagist](https://packagist.org/packages/aazbeltran/laravel-backpack-phpstan-extension)[ RSS](/packages/aazbeltran-laravel-backpack-phpstan-extension/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

Laravel Backpack PHPStan Extension
==================================

[](#laravel-backpack-phpstan-extension)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a40b0ba912c8e084339b6cd085c853e67455a885f3a6e3815f6a88683d7c5335/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61617a62656c7472616e2f6c61726176656c2d6261636b7061636b2d7068707374616e2d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aazbeltran/laravel-backpack-phpstan-extension)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5eb58a1dc67f5ffed027a19411178495187cef0135ffd331d95e129b3296eb41/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61617a62656c7472616e2f6c61726176656c2d6261636b7061636b2d7068707374616e2d657874656e73696f6e2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/aazbeltran/laravel-backpack-phpstan-extension/actions?query=workflow%3Aci+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/22d5928efe147cf54a007f8f14f232df0e5293f5014166af8963d77419f25eca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61617a62656c7472616e2f6c61726176656c2d6261636b7061636b2d7068707374616e2d657874656e73696f6e2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/aazbeltran/laravel-backpack-phpstan-extension/actions?query=workflow%3Aci+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5235d6bea64db5bedaca21e54be8a0a5a6ba7196d67fab8b58d643756c0c0bdc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61617a62656c7472616e2f6c61726176656c2d6261636b7061636b2d7068707374616e2d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aazbeltran/laravel-backpack-phpstan-extension)

**Comprehensive PHPStan support for Laravel Backpack CRUD with Pro package compatibility**

*Make your Backpack applications statically analyzable and improve code quality with zero configuration*

---

✨ Features
----------

[](#-features)

🔮 **Magic Method Resolution** - Automatically resolves dynamic methods on CrudField and CrudColumn classes
⛓️ **Fluent Interface Support** - Maintains proper return types for seamless method chaining
💎 **Pro Package Ready** - Full compatibility with Backpack Pro operations and advanced features
🏗️ **Laravel Facades** - Complete type hints for Laravel facades used throughout Backpack
📚 **Comprehensive Stubs** - Type definitions for all major Backpack classes and components
🚀 **Zero Configuration** - Works out of the box with sensible defaults

🚀 Quick Start
-------------

[](#-quick-start)

### Installation

[](#installation)

```
composer require --dev aazbeltran/laravel-backpack-phpstan-extension
```

### Configuration

[](#configuration)

Add to your `phpstan.neon`:

```
includes:
    - vendor/aazbeltran/laravel-backpack-phpstan-extension/extension.neon
```

### Run Analysis

[](#run-analysis)

```
vendor/bin/phpstan analyse
```

That's it! 🎉 Your Backpack code is now statically analyzed.

📖 Usage Examples
----------------

[](#-usage-examples)

### Before: PHPStan Errors ❌

[](#before-phpstan-errors-)

```
// PHPStan errors: Unknown methods, undefined properties
$this->crud->addField(['name' => 'title', 'type' => 'text'])
          ->removeField('slug')
          ->modifyField('content', ['type' => 'wysiwyg']);

$this->crud->addColumn(['name' => 'status', 'type' => 'select'])
          ->removeColumn('internal_notes')
          ->modifyColumn('created_at', ['type' => 'datetime']);
```

### After: Clean Analysis ✅

[](#after-clean-analysis-)

```
// PHPStan understands the fluent interface and method chaining
$this->crud->addField(['name' => 'title', 'type' => 'text'])
          ->removeField('slug')                    // ✅ Method resolved
          ->modifyField('content', ['type' => 'wysiwyg']); // ✅ Return type maintained

$this->crud->addColumn(['name' => 'status', 'type' => 'select'])
          ->removeColumn('internal_notes')        // ✅ Method resolved
          ->modifyColumn('created_at', ['type' => 'datetime']); // ✅ Fluent interface
```

### Pro Package Support

[](#pro-package-support)

```
// Pro operations work seamlessly
use Backpack\Pro\Http\Controllers\Operations\CloneOperation;
use Backpack\Pro\Http\Controllers\Operations\FetchOperation;

class ArticleCrudController extends CrudController
{
    use CloneOperation, FetchOperation; // ✅ Traits properly typed

    public function setup()
    {
        $this->crud->setModel(Article::class);
        $this->crud->setRoute('admin/article');
        $this->crud->clone();  // ✅ Pro method resolved
        $this->crud->fetch();  // ✅ Pro method resolved
    }
}
```

🎯 Supported Components
----------------------

[](#-supported-components)

**Core CRUD Features**- ✅ **CrudPanel** - Main panel operations and configuration
- ✅ **CrudField** - Field definitions with fluent interface
- ✅ **CrudColumn** - Column definitions with fluent interface
- ✅ **CrudFilter** - Filter definitions and logic
- ✅ **CrudButton** - Button definitions and positioning
- ✅ **Widget** - Dashboard and page widgets
- ✅ **CrudController** - Base controller functionality
- ✅ **CrudPanelFacade** - Static facade access

**Pro Package Features**- ✅ **CloneOperation** - Entity cloning functionality
- ✅ **FetchOperation** - AJAX data fetching
- ✅ **InlineCreateOperation** - Inline entity creation
- ✅ **ChartController** - Dashboard charts and analytics
- ✅ **Pro Fields** - Advanced field types
- ✅ **Pro Widgets** - Enhanced widget components

**Laravel Integration**- ✅ **Facades** - Route, Auth, Request, Schema, etc.
- ✅ **Eloquent Models** - Enhanced model typing
- ✅ **Request/Response** - HTTP layer improvements
- ✅ **Validation** - Custom rule definitions

⚠️ Version Compatibility
------------------------

[](#️-version-compatibility)

> **Important Notice**: This extension was developed and tested against specific versions of Laravel Backpack packages. Compatibility with other versions is not guaranteed.

### Tested Versions

[](#tested-versions)

- **Laravel Backpack CRUD**: `^6.0`
- **Laravel Backpack Pro**: `^2.0` (optional)
- **Laravel**: `^10.0|^11.0`
- **PHP**: `^8.1`
- **PHPStan**: `^1.10|^2.0`

### Maintenance Notice

[](#maintenance-notice)

⚠️ **Limited Maintenance**: Due to the lack of access to Backpack Pro licenses for all contributors, this extension has limited long-term maintenance plans. Community contributions are encouraged and appreciated.

For the most up-to-date compatibility information, please check our [compatibility matrix](COMPATIBILITY.md).

🧪 Testing
---------

[](#-testing)

Run the test suite:

```
composer test
```

Run PHPStan analysis on the extension itself:

```
composer analyse
```

Run code style fixes:

```
composer format
```

📊 Error Reduction Results
-------------------------

[](#-error-reduction-results)

Based on real-world testing with Laravel Backpack codebases:

- **Before**: 655+ PHPStan errors
- **After**: 98 errors resolved (15% improvement)
- **Key fixes**: Magic methods, property access, Pro compatibility

🔧 Advanced Configuration
------------------------

[](#-advanced-configuration)

### Custom Stub Paths

[](#custom-stub-paths)

```
# phpstan.neon
includes:
    - vendor/aazbeltran/laravel-backpack-phpstan-extension/extension.neon

parameters:
    backpackExtension:
        additionalStubs:
            - path/to/your/custom-stubs.php
```

### Selective Feature Enabling

[](#selective-feature-enabling)

```
parameters:
    backpackExtension:
        enabledFeatures:
            - crud_fields      # Enable CrudField magic methods
            - crud_columns     # Enable CrudColumn magic methods
            - pro_operations   # Enable Pro operation support
            - laravel_facades  # Enable Laravel facade stubs
```

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

### Quick Development Setup

[](#quick-development-setup)

```
git clone https://github.com/aazbeltran/laravel-backpack-phpstan-extension.git
cd laravel-backpack-phpstan-extension
composer install
composer test
```

For AI agents and automated tools, see [AGENTS.md](AGENTS.md) for detailed development instructions.

📚 Documentation
---------------

[](#-documentation)

- [Installation Guide](docs/installation.md)
- [Configuration Options](docs/configuration.md)
- [Troubleshooting](docs/troubleshooting.md)
- [Compatibility Matrix](COMPATIBILITY.md)
- [API Reference](docs/api-reference.md)

🆘 Support
---------

[](#-support)

- 📖 **Documentation**: [https://github.com/aazbeltran/laravel-backpack-phpstan-extension/docs](docs/)
- 🐛 **Issues**: [GitHub Issues](https://github.com/aazbeltran/laravel-backpack-phpstan-extension/issues)
- 💬 **Discussions**: [GitHub Discussions](https://github.com/aazbeltran/laravel-backpack-phpstan-extension/discussions)
- 💡 **Feature Requests**: [Feature Request Template](https://github.com/aazbeltran/laravel-backpack-phpstan-extension/issues/new?template=feature_request.md)

📃 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

🙏 Credits
---------

[](#-credits)

- **Laravel Backpack Team** - For creating an amazing admin panel package
- **PHPStan Team** - For providing excellent static analysis tools
- **Community Contributors** - For reporting issues and suggesting improvements

---

**Made with ❤️ for the Laravel Backpack community**

[⭐ Star this repo](https://github.com/aazbeltran/laravel-backpack-phpstan-extension) | [🐦 Follow on Twitter](https://twitter.com/BackpackForLaravel) | [📱 Join Discord](https://discord.gg/backpack)

Supported Classes
-----------------

[](#supported-classes)

- `CrudPanel` - Main CRUD panel functionality
- `CrudField` - Form field configuration
- `CrudColumn` - Column configuration for list views
- `CrudFilter` - Filter configuration
- `CrudController` - Base CRUD controller
- `Widget` - Widget system
- Facades (CRUD facade support)

Error Reduction
---------------

[](#error-reduction)

This extension helps eliminate common PHPStan errors when working with Laravel Backpack:

### Before (with errors):

[](#before-with-errors)

```
Call to an undefined method Backpack\CRUD\app\Library\CrudPanel\CrudField::type()
Call to an undefined method Backpack\CRUD\app\Library\CrudPanel\CrudField::required()

```

### After (no errors):

[](#after-no-errors)

```
CRUD::field('name')->type('text')->required(); // ✅ All methods recognized
```

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
composer test
```

### Running PHPStan Analysis

[](#running-phpstan-analysis)

```
composer analyse
```

Requirements
------------

[](#requirements)

- PHP 8.1+
- PHPStan ^1.10 or ^2.0
- Laravel Backpack CRUD ^6.0

Supported Backpack Packages
---------------------------

[](#supported-backpack-packages)

- [Backpack CRUD](https://backpackforlaravel.com/docs/6.x/crud-tutorial) ^6.0
- [Backpack Basset](https://github.com/Laravel-Backpack/basset) ^1.0
- [Backpack Pro](https://backpackforlaravel.com/products/pro-for-unlimited-projects) (optional)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for release history.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance51

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

343d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3081a499443e911c56aad48b16617baf3be05dac0d49983528a28e26a19e7458?d=identicon)[aazbeltran](/maintainers/aazbeltran)

---

Top Contributors

[![aazbeltran](https://avatars.githubusercontent.com/u/7277106?v=4)](https://github.com/aazbeltran "aazbeltran (14 commits)")

---

Tags

phpPHPStanlaravelstatic analysisextensioncrudbackpacktype-checking

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/aazbeltran-laravel-backpack-phpstan-extension/health.svg)

```
[![Health](https://phpackages.com/badges/aazbeltran-laravel-backpack-phpstan-extension/health.svg)](https://phpackages.com/packages/aazbeltran-laravel-backpack-phpstan-extension)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k60.6M10.3k](/packages/larastan-larastan)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

5014.2M110](/packages/shipmonk-dead-code-detector)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

16132.2k4](/packages/calebdw-larastan)[novius/laravel-backpack-crud-extended

This package extends Laravel Backpack\\CRUD

619.1k2](/packages/novius-laravel-backpack-crud-extended)[inani/nova-resource-maker

A Laravel Nova package to help you generate resources fields

2413.7k](/packages/inani-nova-resource-maker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
