Installation

How to connect your CodeIgniter application to Inspector.

Requirements

  • PHP >= 7.4

  • CodeIgniter >= 4

Installation

Install the latest version using the composer command below:

composer require inspector-apm/inspector-codeigniter

Run the install command to publish the Inspector.php configuration file in your application app/Config directory:

php spark inspector:install

Configure The Ingestion Key

Add the environment variable below to your .env file in order to make your application able to send data to your dashboard. You can get a new Ingestion Key by creating a new app in your account: https://app.inspector.dev

#--------------------------------------------------------------------
# INSPECTOR
#--------------------------------------------------------------------

inspector.ingestionKey = '974yn8c34ync8xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

Add The Exception Handler

In your app/Config/Exceptions.php add the line of code below in the handle method to enable exception tracking:

HTTP Request Monitoring

The package provides your application with the inspector filter that you can use to monitor incoming HTTP requests.

We highly recommend to add inspector to the global filters in your app/Config/Filter.php configuration class in order to monitor all HTTP requests:

You can eventually turn off monitoring using the ignoreRoutes configuration property: https://docs.inspector.dev/guides/codeigniter/configuration#ignore-routes

Verify And Deploy

Run the command below to check if your system is properly configured. If all checks are green you can deploy in your production environment.

If everything is "green" you can release the update in your production environment.

By default Inspector will monitor:

  • Http Requests

  • Spark Commands

  • Database queries

  • Unhandled Exceptions

In the next sections you can learn how to further customize the library behaviour.

Helper

We highly recommend adding the helper in the Config/Autoload.php configuration class to make it available globally into the application:

The helper provides a shortcut to the inspector instance to monitor custom code blocks or manually report specific exceptions.

Learn more about custom Segments here: https://docs.inspector.dev/guides/raw-php/custom-segments

Last updated