Giter Site home page Giter Site logo

wakatime-php-api's Introduction

WakaTime PHP API

WakaTime API for PHP

Become a Patron

Overview

This is a PHP package for WakaTime API. It supports resource endpoints from WakaTime API with additional helper methods for hours logged.

If you are using Laravel check out WakaTime Reports and Laravel.

If you find that some resource endpoints are missing feel free to send me a PR. (Be sure to include tests for your code)

Installation

Type this from command line:

composer require mabasic/wakatime-php-api

Usage

<?php

use GuzzleHttp\Client as Guzzle;
use Mabasic\WakaTime\WakaTime;

$wakatime = new WakaTime(new Guzzle, $your_api_key_for_wakatime);

You can get your Api Key from your settings page.

Resource Endpoints

Users

$wakatime->currentUser()

// or

$wakatime->users('username');

See: https://wakatime.com/developers/#users for details.

Summaries

$wakatime->summaries($startDate, $endDate, $project = null)

See: https://wakatime.com/developers/#summaries for details.

Stats

$wakatime->stats($range, $project = null)

See: https://wakatime.com/developers/#stats for details.

Heartbeats

$date = '01/22/2016';

$wakatime->heartbeats($date);

See: https://wakatime.com/developers#heartbeats for details.

Helper methods aka Reports aka Shortcuts

getHoursLoggedFor

$wakatime->getHoursLoggedFor($startDate, $endDate, $project = null)

Calculates hours logged for a specific period. You can optionally specify a project.

$startDate must be lower than $endDate

Example:

$startDate = '11/21/2014';
$endDate = '12/21/2014';

$hours = $wakaTime->getHoursLoggedFor($startDate, $endDate);

getHoursLoggedForLast

public function getHoursLoggedForLast($period, $project = null)

Calculates hours logged in last xy days, months. You can optionally specify a project.

Example:

$hours = $wakaTime->getHoursLoggedForLast('7 days');

getHoursLoggedForToday

public function getHoursLoggedForToday($project = null)

Returns hours logged today. You can optionally specify a project.

getHoursLoggedForYesterday

public function getHoursLoggedForYesterday($project = null)

Returns hours logged yesterday. You can optionally specify a project.

getHoursLoggedForLast7Days

public function getHoursLoggedForLast7Days($project = null)

Basic users can only see data for maximum 7 days. Become a Premium user to preserve all data history. You can still use any method as long as it is under 7 days.

getHoursLoggedForLast30Days

public function getHoursLoggedForLast30Days($project = null)

Calculates hours logged for last 30 days in history. You can optionally specify a project.

getHoursLoggedForThisMonth

public function getHoursLoggedForThisMonth($project = null)

Calculates hours logged for this month. You can optionally specify a project.

getHoursLoggedForLastMonth

public function getHoursLoggedForLastMonth($project = null)

Calculates hours logged for last month. You can optionally specify a project.


For developers only

Copy .env.example file to .env and set your api key and project name before running tests with:

vendor/bin/phpunit

Laravelista Sponsors & Backers

I would like to extend my thanks to the following sponsors & backers for funding my open-source journey. If you are interested in becoming a sponsor or backer, please visit the Laravelista Backers page.

Contributing

Thank you for considering contributing to WakaTime PHP API! The contribution guide can be found on the Laravelista website.

Code of Conduct

In order to ensure that the Laravelista community is welcoming to all, please review and abide by the Code of Conduct.

License

WakaTime PHP API is open-source software licensed under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.