Symfony

Setup guide to install and configure the 1Pilot client on Symfony

Install on Symfony Application

Setup for Symfony 6, 5 & 4.4

Install Symfony Bundle version 2

composer require 1pilotapp/symfony-client:^2.0
  1. add a new config/packages/one_pilot_client.yaml file with the following content
one_pilot_client:
    private_key: "%env(ONE_PILOT_PRIVATE_KEY)%"
    mail_from_address: "%env(ONE_PILOT_MAIL_FROM_ADDRESS)%"
  1. add the following parameters to your .env file:
ONE_PILOT_PRIVATE_KEY="your key"
ONE_PILOT_MAIL_FROM_ADDRESS="your_app_mail_from@example.com"

ONE_PILOT_PRIVATE_KEY can be any random alphanumeric string. If you are not sure what key to use, go to 1Pilot dashboard and open the page to add a new site: a random key will be generated for you, and you can copy / paste it into your file. Of course you are free to create a totally different key, just make sure you have the same key in your .env and on the 1Pilot dashboard.

ONE_PILOT_MAIL_FROM_ADDRESS is the email address that you use to send mail from your application. It's used by the email verification tool to ensure emails are properly sent by your application.

  1. add to your config/routes.yaml the following configuration:
one_pilot:
    resource: "@OnePilotClientBundle/Resources/config/routing.xml"
    prefix:   /

Setup for Symfony 4.0 - 4.3

Install Symfony Bundle version 1 (for symfony 4.0 - 4.3)

composer require 1pilotapp/symfony-client:^1.0
  1. add a new config/packages/one_pilot_client.yaml file with the following content
one_pilot_client:
    private_key: "%env(ONE_PILOT_PRIVATE_KEY)%"
    mail_from_address: "%env(ONE_PILOT_MAIL_FROM_ADDRESS)%"
  1. add the following parameters to your .env file:
ONE_PILOT_PRIVATE_KEY="your key"
ONE_PILOT_MAIL_FROM_ADDRESS="your_app_mail_from@example.com"

ONE_PILOT_PRIVATE_KEY can be any random alphanumeric string. If you are not sure what key to use, go to 1Pilot dashboard and open the page to add a new site: a random key will be generated for you, and you can copy / paste it into your file. Of course you are free to create a totally different key, just make sure you have the same key in your .env and on the 1Pilot dashboard.

ONE_PILOT_MAIL_FROM_ADDRESS is the email address that you use to send mail from your application. It's used by the email verification tool to ensure emails are properly sent by your application.

  1. add the following configuration to your config/routes.yaml:
one_pilot:
    resource: "@OnePilotClientBundle/Resources/config/routing.xml"
    prefix:   /

Setup for Symfony 3

Install Symfony Bundle version 1

composer require 1pilotapp/symfony-client:^1.0
  1. add the following configuration keys to your app/config/config.yml file:
one_pilot_client:
    private_key: "%one_pilot_private_key%"
    mail_from_address: "%one_pilot_mail_from_address%"
  1. add the following parameters to your app/config/parameters.yml.dist file:
    one_pilot_private_key: ~
    one_pilot_mail_from_address: ~

This defines the new required configuration parameters.

  1. add the following parameters to your app/config/parameters.yml file:
    one_pilot_private_key: "your key"
    one_pilot_mail_from_address: "your_app_mail_from@example.com"

one_pilot_private_key can be any random alphanumeric string. If you are not sure what key to use, go to 1Pilot dashboard and open the page to add a new site: a random key will be generated for you, and you can copy / paste it into your file. Of course you are free to create a totally different key, just make sure you have the same key in your parameters.yml and on the 1Pilot dashboard.

one_pilot_mail_from_address is the email address that you use to send mail from your application. It's used by the email verification tool to ensure emails are properly sent by your application.

  1. add the following configuration to your app/config/routing.yml:
one_pilot:
    resource: "@OnePilotClientBundle/Resources/config/routing.xml"
    prefix:   /
  1. add the following line to your app/AppKernel.php file, in the registerBundles method:
...
new OnePilot\ClientBundle\OnePilotClientBundle(),
...

Connection troubleshooting

Symfony firewall

A common issue with Symfony applications is the Symfony firewall not allowing 1Pilot servers to connect to your website and redirecting their requests from /onepilot/* to the login form.

To fix that you have to allow anonymous access to /onepilot/ routes in the Symfony firewall and access_control list.

To proceed, edit config/packages/security.yaml and add the following lines in the firewalls section before the main entry:

        1pilot:
            pattern:   ^/onepilot/
            anonymous: true

and the following line in the access_control section

        - { path: '^/onepilot', roles: IS_AUTHENTICATED_ANONYMOUSLY }

Server time issue

If your server time is not set correctly, you can have issue connecting your application to 1Pilot. To solve that, edit app/config/config.yml and set skip_timestamp_validation as follows:

one_pilot_client:
    private_key: "..."
    skip_timestamp_validation: true

Please note that this option will decrease security and that you should set your server time correctly if possible.