Installation and Configuration

Install Bundle

To install statistics explorer bundle use following commands:

composer require pimcore/statistics-explorer
./bin/console pimcore:bundle:enable PimcoreStatisticsExplorerBundle
./bin/console pimcore:bundle:install PimcoreStatisticsExplorerBundle


The statistics explorer needs to be embedded into an existing host application that provides the context in which the statistics explorer is executed.

The statistics explorer can be executed in multiple contexts within one host application and each context is connected to user & login information. The name for contexts can be freely selected, example would be pimcore_admin, portal, frontend, ...

To set up a context and embed the statistics explorer, there are three additional setup steps necessary besides the actual installation of the bundle.

Setup User Provider

The host application needs to take about user authentication (e.g. via a symfony firewall) and provide the statistics explorer the user information.

This is done by creating a service that is implementing the UserProviderInterface and that is tagged with the pimcore.statistics_explorer.user_provider_context tag which defines the context the user provider is for. This service has methods to return the current logged-in user and other users that configurations can be shared with.

The bundle ships with a sample implementation for Pimcore users which also can be used for your application.

Sample User Provider Configuration
        autowire: true
        autoconfigure: true
        public: false
        class: Pimcore\Bundle\StatisticsExplorerBundle\User\PimcoreUserProvider
            - { name: 'pimcore.statistics_explorer.user_provider_context', context: 'portal' } 

Setup Routes

All controller actions of the statistics explorer need to be executed in the defined context and most probably in the context of the corresponding firewall. To provide maximal flexibility, the statistics explorer does not predefine any routes but allows you to define the route prefix(es) in which the statistics explorer should be reachable.

This can be done by adding following entry to your routing.yml whereas the prefix can be selected freely.

    resource: "@PimcoreStatisticsExplorerBundle/Controller"
    type:     annotation
    prefix:   /admin/stats

The urls for statistics explorer will add the context name and the actual action to it, and look like similar as /admin/stats/portal/data-sources.

See also Using Statistics Explorer and Using Statistics Loader for further details.

Setup Data Sources

The last setup step is to configure data sources that should be used by the statistics explorer. Data sources are symfony services that implement the StatisticsStorageAdapterInterface and are tagged with the pimcore.statistics_explorer.data_source which defines the data source name and the context in which it should be available.

As an alternative to tagged services, there is also the possibility to add data sources during runtime via events.

The bundle ships with two implementations for the interface which can be used right away to define data sources:

  • ElasticsearchAdapter

    • expects index name as argument.
    • define the elasticsearch cluster host by setting pimcore_statistics_explorer.es_hosts configuration.
    • optionally, a ElasticsearchClientFactory can be provided to specify a special elasticsearch cluster (by default the cluster defined in pimcore_statistics_explorer.es_hosts configuration is used).
    • Supports elasticsearch versions 6 and 7.
  • MySqlAdapter

    • expects table name as argument
    • optionally, a Connection can be provided to specify a special database connection (by default the default Pimcore connection is used)

By implementing the interface, also additional data sources could be supported.

Sample Data Source Configuration
        class: Pimcore\Bundle\StatisticsExplorerBundle\StatisticsStorageAdapter\ElasticsearchAdapter
        autowire: true
        autoconfigure: true
        public: false
            $indexName: 'data_objects_car'
            $label: 'Data Objects Car'
            - { name: 'pimcore.statistics_explorer.data_source', 'dataSourceName': 'data_objects_car', context: 'portal' }

        autowire: true
        autoconfigure: true
        public: false
        class: Pimcore\Bundle\StatisticsExplorerBundle\StatisticsStorageAdapter\MySqlAdapter
            $tableName: 'assets'
            $label: 'Assets'  
            - { name: 'pimcore.statistics_explorer.data_source', 'dataSourceName': 'assets', context: 'portal' }
            - { name: 'pimcore.statistics_explorer.data_source', 'dataSourceName': 'assets', context: 'another_portal' }