1. Go to this page and download the library: Download benwilkins/laravel-analyst library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/*
* Path to the client secret json file.
*/
'google_account_credentials_json' => storage_path('app/laravel-analyst/Google/account-credentials.json'),
/*
* The amount of minutes the Google API responses will be cached.
* If you set this to zero, the responses won't be cached at all.
*/
'cache_lifetime_in_minutes' => 60 * 24,
/*
* The directory where the underlying Google_Client will store it's cache files.
*/
'cache_location' => storage_path('app/laravel-analyst/'),
/*
* The directory where custom internal metrics are stored.
*/
'custom_metric_location' => '/app/Metrics/',
/*
* Default data client
*/
'default_client' => 'internal',
];
// app/Metrics/MyNewMetric.php
namespace Benwilkins\Analyst\Clients\Inernal\Metrics;
use Benwilkins\Analyst\Period;
class MyNewMetric extends Metric
{
public function run(Period $period, $params = [])
{
// Code to run the metric
}
}
use Benwilkins\Analyst\Period;
$data = Analyst::metric('new users', Period::days(30));