Laravel Vapor

How to make Inspector works on Laravel Vapor.

Use the default Vapor runtime

Behind the scene, Inspector uses curl to send data from your application to the monitoring system. In the default Vapor runtime curl is available in custom path, so you need to let the package know this path to properly build the curl command to send the data.

The package has an option for this configuration. You just need to publish the Inspector configuration file using the command below:

php artisan vendor:publish --provider="Inspector\Laravel\InspectorServiceProvider"

After publishing the config/inspector.php file you can customize the curlPath field in the "options" property:

/*
 |--------------------------------------------------------------------------
 | Custom transport options
 |--------------------------------------------------------------------------
 |
 | This is where you can set the transport option settings you'd like us to use when
 | communicating with Inspector.
 |
 */

'options' => [
    'curlPath' => '/opt/bin/curl --cacert /opt/lib/curl/cert.pem',
],

Test and Deploy

You can run the test command to verify everything is well configured before deploy in production:

Use Docker runtime

Docker based runtimes offer much more control over the execution environment, so you can deploy applications up to 10GB in size and allow you to install additional PHP extensions or libraries.

In order to use a Docker image instead of the Vapor native runtimes, set the runtime configuration option to docker within your vapor.yml file:

Learn more about Docker runtime in Vapor.

To make Inspector works you must be sure that the current PHP installation in the Docker image has proc_open, and proc_close native functions enabled.

The default Docker runtime should have these functions enabled by default. In alternative you need to create a custom php.ini file in your project root directory with these two functions not listed in the disable_functions parameter:

Add the entry below in your environment .Dockerfile to override the default php.ini configuration:

Now you can continue installing the library as usual: https://docs.inspector.dev/guides/laravel/installation

Increase ulimits

Ulimit is a Unix property used to set the number of open file descriptors for each process. It is also used to set restrictions on the resources used by a process. If the load on your application starts to increase due to background jobs, commands, or requests you could easily hit this limit for the underlying docker container behind your Vapor environment.

To increase this limit you can add ulimits section to the vapor.yml file for both production and staging environments.

Following this documentation on the docker https://docs.docker.com/reference/compose-file/build/#ulimits

Last updated