# PHP Insights: Your Code Quality Companion

By Dinesh Uprety
Published: 2024-05-04
Updated: 2024-05-04
Canonical: https://laranepal.com/blog/php-insights-your-code-quality-companion

# Mastering Advance PHP Automated Tooling

Are you looking to enhance the quality of your PHP code effortlessly? Let's explore some automated tools that can aid in
auditing your code and identifying areas for improvement. In this guide, we'll walk through the tools I commonly use and
how to interpret their findings. Although these tools may offer overlapping features and analyses, each brings its own
unique checks to the table, providing a comprehensive audit experience.

## PHP Insights: Your Code Quality Companion

![PHP Insights](https://laranepal.com/storage/5dELcUm7ay6ii8c7FsE2PhD3r9JYROW0Icn1ZZM5.gif "Logo PHP Insights")

**[PHP Insights](https://phpinsights.com/)** emerges as a versatile tool tailored to uplift your PHP projects' code
quality. Crafted by [Nuno Maduro](https://github.com/nunomaduro), with design by [Caneco](https://github.com/caneco),
and currently maintained by [Chris
Gmyr](https://github.com/cmgmyr), [Jibé Barth](https://github.com/Jibbarth),
and [Steve McDougall](https://github.com/JustSteveKing), PHP Insights stands out with its array of built-in checks. It
facilitates the creation of reliable, loosely coupled, simple, and clean code. Notably, PHP Insights seamlessly
integrates with frameworks like **Laravel**, **Symfony**, **WordPress**, and more, extending its utility beyond Laravel
projects.

At the time of writing, **PHP Insights** gives you insights into 4 distinct categories:

* Code (105 insights)
* Architecture (20 insights)
* Complexity (1 insight)
* Style (84 insights)

The results that **PHP Insights** generates are also presented in a nice, easy-to-read format in your terminal after
running. After the command has run, you'll be presented with an overview of the results like so:
![Automation Tool](https://laranepal.com/storage/STPwIzRoe6uOaX0pzPNhEkzUQ857zq2TTx1CxHT5.png "PHP Insights")

## Installation

To get started, we'll first need to install PHP Insights using the following command:

```shell
composer require nunomaduro/phpinsights --dev
```

After that, you can publish the package's config file using the following command:

```shell
php artisan vendor:publish --provider="NunoMaduro\PhpInsights\Application\Adapters\Laravel\InsightsServiceProvider"
```

## Analysing Your Code with PHP Insights

That's it! You should now be ready to run **`PHP Insights`** using the following command:

```shell
php artisan insights
```

Running the command above will analyse your entire codebase. However, if you'd prefer to only analyse a specific file or
directory, you can pass a path to the `insights` Artisan command. For example, if we only wanted to analyse the code in
our` app/Http/Controllers` directory, we could run the following command:

```shell
php artisan insights app/Http/Controllers
```

Or for example, if we wanted to analyse a specific controller (such as `app/Http/Controllers/UserController.php`), we
could run the following command:

```shell
php artisan insights app/Http/Controllers/UserController.php
```

> Note for Laravel 7 users: phpinsights requires **[`PHP 7.3+`](https://www.php.net/releases/)**, and` PHPUnit 9.0+`.
> For
> upgrading PHPUnit, you can use following
> command:

```shell
composer require --dev phpunit/phpunit:^9.0 --update-with-dependencies
```

## Conclusion

Elevate PHP project quality effortlessly. **PHP Insights** offers comprehensive code auditing, seamlessly integrating
with
Laravel and other frameworks. Streamline analysis, make informed decisions, and enhance code maintainability today.
