Bundle include segment.io library for analytics
include segmentio/analytics-php
The bulk of the documentation is stored in the Resources/doc folder in this bundle
Installing the bundle via packagist is the quickest and simplest method of installing the bundle. Here are the steps:
$ php composer.phar require "farmatholin/segment-io-bundle":"dev-master"
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Farmatholin\SegmentIoBundle\SegmentIoBundle(),
// ...
);
}
That's it! You are ready to use Segment.io with symfony2.
Required segment write key:
# SegmentIoBundle Configuration
# app/config/config.yml
segment_io:
write_key: "%your_key%" #add your key
env: prod #default prod. Can be prod (sending to segment) and dev (not sending)
options:
consumer: socket #default
debug: false #default
ssl: false #default
max_queue_size: 10000 #default
batch_size: 100 #default
timeout: 0.5 #default
filename: null #default
Get segment_io.analytics
service from the service container and start using it:
$analytics = $this->get('segment_io.analytics');
$analytics->page()
Refer to Segment.io analytics-php library.