Laravel Vapor

How to make Inspector works on Laravel Vapor.

When using Vapor you have to enable the "serverless" flag in the Application Settings.

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:

php artisan inspector:test

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:

id: 2
name: vapor-laravel-app
environments:
    production:
        runtime: docker # Use docker as runtime environment
        build:
            - 'composer install --no-dev'

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:

php.ini
disable_functions=exec,passthru,shell_exec,system,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

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

environment.Dockerfile

# Update the `php.ini` file...
# Requires a `php.ini` file at the root of your project...
COPY ./php.ini /usr/local/etc/php/conf.d/overrides.ini

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

Last updated