PHPackages                             inspector/inspector - 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. inspector/inspector

ActiveLibrary

inspector/inspector
===================

Inspect the your app's data, config and user input for issues

v1.1.1(11y ago)492MITPHP

Since Feb 27Pushed 11y ago1 watchersCompare

[ Source](https://github.com/inspector-php/inspector)[ Packagist](https://packagist.org/packages/inspector/inspector)[ RSS](/packages/inspector-inspector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (0)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ca6601dcd22bf6cecc960ed028a66ec231843c8c097f635c4ff368200747e621/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f696e73706563746f722d7068702f696e73706563746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/inspector-php/inspector/?branch=master)

Inspector
=========

[](#inspector)

Inspect your app's data, config and user input for issues.

Use-cases
---------

[](#use-cases)

- Test customer databases for configuration issues
- Test customer databases for inconsistencies / invalid data
- Validate user input (find invalid email addresses, phonenrs, etc)
- ... etc etc

The framework lets you write 'Inspections' for any type of data, and raise 'Issues' when needed.

The issues contain (translatable) user-level error messages, proposed solutions, and hyperlinks to fix the issue.

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

[](#installation)

It is recommended to use composer to install Inspector:

```
composer require inspector/inspector "~1.0"

```

Alternatively you can add the following to the require section in your composer.json manually:

```
"inspector/inspector": "~1.0"

```

Run composer update afterwards.

How to use Inspector
--------------------

[](#how-to-use-inspector)

### Create an Inspection class

[](#create-an-inspection-class)

You can create a new Inspection class for each type of data that you want to inspect. For example a `UserInspector`

```
namespace Acme\Inspector\Inspection;

use Inspector\Inspection\InspectionInterface
use Acme\Inspector\Issue\UserWithoutPasswordIssue;
use PDO;

// As a convention, end the classname with "Inspection"
class UserInspection
{
    private $pdo;

    // Request dependencies from the container
    public function __construct(PDO $pdo)
    {
        $this->pdo = $pdo;
    }

    // The inspector will run all methods starting with `inspect`
    public function inspectPasswords(InspectionInterface $inspection)
    {
        // Query for users without a password
        $res = $pdo->queryForUsersWithoutPasswords();

        // Loop through the results
        foreach ($res as $row) {
            // Instantiate a new issue for each user without a password
            $issue = new UserWithoutPasswordIssue($inspection);

            // Attach arbitrary data to the issue for later usage in the templates
            $issue->setData('username', $row['username']);
            $issue->setData('userid', $row['id']);

            // Add this new issue to the inspection
            $inspection->addIssue($issue);
        }
    }
}
```

### Create an Issue class

[](#create-an-issue-class)

Each issue is described in it's own class, in this case `UserWithoutPasswordIssue`:

```
namespace Acme\Inspector\Issue;

use Inspector\Issue\IssueInterface;
use Inspector\Issue\BaseIssue

// An issue must implement the IssueInterface
// To simplify this, simply extend from the BaseIssue
class UserWithoutPasswordIssue extends BaseIssue implements IssueInterface
{
    // Optionally provide links to where to solve the issue
    public function getLinks()
    {
        $links = array();
        $links[] = new Link('/users/' . $this->getData('userid') . '/resetpassword', 'Reset password');
        return $links;
    }
}
```

### Run inspections

[](#run-inspections)

```
use Inspector\Inspector;
use Inspector\Loader\YamlLoader;
use Inspector\Formatter\ConsoleFormatter;

// Create a new container, or reuse an existing one (Symfony DI, Pimple, etc)
$container = array();
$container['pdo'] = $myPdoHandle;

// Instantiate a new Inspector
$inspector = new Inspector($container);

// Use a YamlLoader to quickly import a suite of Inspections
$loader = new YamlLoader();
$loader->load($inspector, '/my/inspector/suite.yml');

// Run all the inspections
$inspector->run();

// Create a new formatter to display the output
$formatter = new ConsoleFormatter();

// Echo out the formatted inspector results
echo $formatter->format($inspector);
```

### Creating a inspection suite file

[](#creating-a-inspection-suite-file)

You can define a set of inspections in a YAML file for quick loading and running. The YAML file supports includes, and lets you specify classnames that contain `inspect` methods:

```
include:
    - other.yml

classes:
    - Acme\Inspection\UserInspection
```

### Running inspections from the console

[](#running-inspections-from-the-console)

A console command is included, you can run it like this:

```
vendor/bin/inspector inspector:run path/to/my/suite.yml
```

It is possible to add more verbose output. Simply add -v or -vv

```
vendor/bin/inspector inspector:run path/to/my/suite.yml -vv
```

It is also possible to run a single inspection:

```
vendor/bin/inspector inspector:run My\\Inspection\\Class
```

This runs the inspection suite, and outputs the results to the console.

### Running inspections on SQL databases

[](#running-inspections-on-sql-databases)

If your inspections need an SQL database connection, you can use the `--pdoconfig=/path/to/config.ini` option. The ini file should contain the `server`, `name`, `username` and `password` for your database. You can define which `driver` to use, which will default to `mysql` if omitted.

For example:

```
name=mydatabase
server=localhost
username=joe
password=secret
driver=pgsql
```

License
-------

[](#license)

MIT (see [LICENSE.md](LICENSE.md))

Brought to you by the LinkORB Engineering team
----------------------------------------------

[](#brought-to-you-by-the-linkorb-engineering-team)

[![](https://camo.githubusercontent.com/62fb66b034de7ea7fca9fd9776424b5348daa76ef8622caf92c2f7622003e5ef/687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67)](https://camo.githubusercontent.com/62fb66b034de7ea7fca9fd9776424b5348daa76ef8622caf92c2f7622003e5ef/687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67)
Check out our other projects at [linkorb.com/engineering](http://www.linkorb.com/engineering).

Btw, we're hiring!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~1 days

Total

5

Last Release

4092d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1db66b320db18b8036ea68211b7d8a39e7c6da97e6fd29f59a50380ebb69d0bb?d=identicon)[joostfaassen](/maintainers/joostfaassen)

---

Top Contributors

[![joostfaassen](https://avatars.githubusercontent.com/u/411113?v=4)](https://github.com/joostfaassen "joostfaassen (13 commits)")[![h-wang](https://avatars.githubusercontent.com/u/3410322?v=4)](https://github.com/h-wang "h-wang (12 commits)")[![r3wald](https://avatars.githubusercontent.com/u/190202?v=4)](https://github.com/r3wald "r3wald (1 commits)")

---

Tags

inspectorinspectdata-integrityissuesanity check

### Embed Badge

![Health badge](/badges/inspector-inspector/health.svg)

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

###  Alternatives

[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2332.0M2](/packages/inspector-apm-inspector-laravel)[inspector-apm/inspector-php

Inspector monitoring for PHP applications.

342.4M15](/packages/inspector-apm-inspector-php)[oro/twig-inspector

Oro Twig Inspector adds the possibility to find twig templates and blocks used for rendering HTML pages faster during development

47532.6k14](/packages/oro-twig-inspector)[grazulex/laravel-devtoolbox

Swiss-army artisan CLI for Laravel — Scan, inspect, debug, and explore every aspect of your Laravel application from the command line.

1535.4k](/packages/grazulex-laravel-devtoolbox)[iamfarhad/laravel-audit-log

Comprehensive entity-level audit logging package for Laravel applications with model-specific tables, field exclusion, and batch processing support

1315.6k](/packages/iamfarhad-laravel-audit-log)[bdk/debug

Browser/javascript like console class for PHP

819.0k1](/packages/bdk-debug)

PHPackages © 2026

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