Package Data | |
---|---|
Maintainer Username: | jamesmirvine |
Maintainer Contact: | james@jamesmirvine.com (James M Irvine) |
Package Create Date: | 2014-07-31 |
Package Last Update: | 2016-03-02 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:16:53 |
Package Statistics | |
---|---|
Total Downloads: | 140 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
The package supports use with the Laravel framework (v5) providing a Stat
facade for the StatCounter API. You can find the documentation for this package here.
###Setup:
In order to install, add the following to your composer.json
file within the require
block:
{
"require": {
"injic/laravel-statcounter": "2.*",
}
}
Now, run the command composer update
.
Within Laravel, locate the file /config/app.php
. Add the following to the providers
array:
Injic\LaravelStatcounter\LaravelStatcounterServiceProvider::class,
Furthermore, add the following the aliases
array:
'Stat' => Injic\LaravelStatcounter\Facades\Stat::class,
Publish the configuration
$ php artisan vendor:publish --provider="Injic\LaravelStatcounter\LaravelStatcounterServiceProvider"
Find the package's config found in /config/statcounter.php
. You'll need to fill out your StatCounter username, API password, and project information. Since the config file contains further information on the individual values, here are a few things to note:
username
is the case-sensitive login username for StatCounterpassword
referes to the API password, not the login password (see API Password)default
must match one of the project names under projects
your-project-name
is the only value that isn't specified by StatCounter. It's an alias of your choosing used when calling functions which handle projects.projects
and security-codes
must having matching keys (i.e. the project names).###Usage:
Methods of the Stat
class simplify what is needed for a StatCounter API query as described in the StatCounter API Documentation. Additionally, the Stat
class was modeled off of the Laravel DB Query design, and you may expect similar methods.
You can find the documentation for this package here.
###Examples:
// Retrieve an array of browser objects (http://api.statcounter.com/docs/v3#browsers)
$stats = Stat::browsers()->get();
// Retrieve an array of summary objects (http://api.statcounter.com/docs/v3#summary-daily)
$now = \Carbon\Carbon::now(); // http://carbon.nesbot.com/
$stats = Stat::summary()->setRange(Granularity::DAILY, $now->subWeek(), $now)->get();
// Paginate the recent visitor objects (http://api.statcounter.com/docs/v3#visitors)
// https://laravel.com/docs/5.2/pagination
$stats = Stat::recentVisitors()->paginate(20);
// Add new project to StatCounter with the project name, project url, and project timezone
$project Stat::addProject('project-name','www.example.com','America/Chicago');
<html>
<body>
<!-- Prints the StatCounter tracker using Laravel Templates -->
{!! Stat::tracker() !!}
</body>
</html>