PHPackages                             kafkiansky/better-laravel - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. kafkiansky/better-laravel

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kafkiansky/better-laravel
=========================

A set of rules for the Psalm static analysis tool that help to detect popular issues when working with the Laravel framework.

v0.2.0(3y ago)114.6kMITPHPPHP ^8.1

Since Jun 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kafkiansky/better-laravel)[ Packagist](https://packagist.org/packages/kafkiansky/better-laravel)[ RSS](/packages/kafkiansky-better-laravel/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

Better Laravel
==============

[](#better-laravel)

[![test](https://github.com/kafkiansky/better-laravel/workflows/test/badge.svg?event=push)](https://github.com/kafkiansky/better-laravel/workflows/test/badge.svg?event=push)[![static analysis](https://github.com/kafkiansky/better-laravel/workflows/static%20analysis/badge.svg)](https://github.com/kafkiansky/better-laravel/actions?query=workflow%3A%22static+analysis%22)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/d64af05d931ad6f5e7f857403c211bdea6d3e5a5b701dc53efdfda08d0ae660b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b61666b69616e736b792f6265747465722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kafkiansky/better-laravel)

### Contents

[](#contents)

- [**Installation**](#installation)
- [**Motivation**](#motivation)
- [**Hooks**](#hooks)
    - [**DontExtendApplicationEventServiceProvider**](#DontExtendApplicationEventServiceProvider)
    - [**DontUseEnvOutsideConfiguration**](#DontUseEnvOutsideConfiguration)
    - [**ConfigurationOptionMustExists**](#ConfigurationOptionMustExists)
- [**Testing**](#testing)
- [**License**](#license)

Installation
------------

[](#installation)

```
composer require kafkiansky/better-laravel --dev
```

Motivation
----------

[](#motivation)

Laravel is a framework focused on ease of development. However, while providing many simple tools to quickly implement production ready solutions, it also adds more options to allow bugs. This package provides a set of plugins for the `Psalm` static analyzer, which covers many known issues.

Hooks
-----

[](#hooks)

#### DontExtendApplicationEventServiceProvider

[](#dontextendapplicationeventserviceprovider)

How often have you made the mistake of inheriting the right `EventServiceProvider`? For example, you have a service provider `A` in which you register subscribers or listeners, and then inherit it in service provider `B` in which you register only listeners or only subscribers. So you risk duplicating subscribers or listeners because `Laravel` will register them twice in the dispatcher.

The `DontExtendApplicationEventServiceProvider` hook will detect such service providers and prevent them from using inheritance from project event service providers.

#### DontUseEnvOutsideConfiguration

[](#dontuseenvoutsideconfiguration)

You have probably heard that the `env` function will always return null when caching a configuration. This is because Laravel does not load environment variables if it sees a cached configuration file in `bootstrap/cache/config.php`. This hook works quite simply: if it sees calls to the `env` function outside the configuration files, it shows an error.

⚠️ **Important restriction: all configuration files must be stored in the `config` folder.**

#### ConfigurationOptionMustExists

[](#configurationoptionmustexists)

Laravel allows you to work conveniently with configuration through dot notation. This is both convenient because it allows you to have unlimited nesting of the configuration, and inconvenient because no one validates such a configuration, and you can get the name wrong. This hook parses all the configuration files of your project and checks that the options you are accessing really exist.

⚠️ **Important restriction: all configurations must be stored in the config folder and the file names must match the namespace (root) of the configuration.**

For example, you have the following config in a file called `api.php`:

```
return [
    'http' => [
        'uri' => 'https://httpbin.org',
    ],
];
```

When accessing the `api.http.ur` configuration, you will see an error from `Psalm` that such configuration option is missing.

Testing
-------

[](#testing)

```
$ composer test
```

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~207 days

Total

3

Last Release

1098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b0c87976a285325177559e27d154a9b5019466800c6a3342db916140c512ede?d=identicon)[kafkiansky](/maintainers/kafkiansky)

---

Top Contributors

[![kafkiansky](https://avatars.githubusercontent.com/u/37590388?v=4)](https://github.com/kafkiansky "kafkiansky (1 commits)")

---

Tags

phplaravelstatic analysispsalm

### Embed Badge

![Health badge](/badges/kafkiansky-better-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/kafkiansky-better-laravel/health.svg)](https://phpackages.com/packages/kafkiansky-better-laravel)
```

###  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)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[calebdw/larastan

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

16132.2k4](/packages/calebdw-larastan)

PHPackages © 2026

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