Adback/ApiClientBundle

This bundle will use the library to call the AdBack api.
See the AdBack website for more informations.
Installation
Launch the composer command :
composer require adback/adback-sdk-php-symfony
If you are using a version of symfony >= 4, it should automatically activate the bundle.
If you are using a version of symfony < 4, you have to add the bundle to your AppKernel.php file :
new Adback\ApiClientBundle\Adback\ApiClientBundle(),
Configuration
Symfony 4
In your .env file, the following lines should have been added :
ADBACK_API_CLIENT_ACCESS_TOKEN=adback-access-token
Modify it with the token provided by the AdBack team.
Then follow the paragraph linked to the type of cache you have choosen :
Redis
In the config/packages/adback_sdk_php.yaml you should add the following configuration :
cache_type: redis
cache_service: redis_service
redis_service is the name of the redis connection you are using to store the data.
Doctrine
In the config/packages/adback_sdk_php.yaml you should add the following configuration :
cache_type: doctrine
entity_manager: doctrine.orm.entity_manager
doctrine.orm.entity_manager is the name of the doctrine connection you are using to store the data.
Do not forget to create the table linked to the AdBack sdk.
Custom
If you want to write your own cache driver, you should create a class that implements
Adback\ApiClient\Driver\ScriptCacheInterface and name this service adback_api_client.script_cache.
In the config/packages/adback_sdk_php.yaml you should add the following configuration :
cache_type: custom
If the service is missing, an error will be issued by the Symfony DIC when the service is being used.
Symfony < 4
In your app/config/config.yml file, you should add the following lines :
adback_api_client:
access_token: "your-access-token"
Modify it with the token provided by the AdBack team.
Then follow the paragraph linked to the type of cache you have choosen :
Redis
In the app/config/config.yml you should add the following configuration :
adback_api_client:
cache_type: redis
cache_service: redis_service
redis_service is the name of the redis connection you are using to store the data.
Doctrine
In the app/config/config.yml you should add the following configuration :
adback_api_client:
cache_type: doctrine
entity_manager: doctrine.orm.entity_manager
doctrine.orm.entity_manager is the name of the doctrine connection you are using to store the data.
Do not forget to create the table linked to the AdBack sdk.
Custom
If you want to write your own cache driver, you should create a class that implements
Adback\ApiClient\Driver\ScriptCacheInterface and name this service adback_api_client.script_cache.
In the app/config/config.yml you should add the following configuration :
adback_api_client:
cache_type: custom
If the service is missing, an error will be issued by the Symfony DIC when the service is being used
Usage
Refresh command
In order to have the AdBack script always up-to-date you should launch the command adback:api-client:refresh-tag
periodically (at least once a day).
This command will call our api and store the response in the cache type you have chosen
Add the script to your pages
At the bottom of your webpages, you should add the script twig generation function :
{{ adback_generate_scripts() }}
Full configuration description
adback_api_client:
access_token: ~
api_url: 'https://adback.co/api'
script_url: script/me
cache_type: redis
generator_type: script
cache_service: redis
entity_manager: doctrine.orm.entity_manager
key_prefix: ''