Download the PHP package jurager/tracker without Composer

On this page you can find all versions of the php package jurager/tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tracker

Jurager/Tracker

Latest Stable Version Total Downloads PHP Version Require License

This package allows you to track sanctum tokens by reading the request and recording the IP address, and other metadata to database.

With an IP address lookup, you may retrieve even more information, such as the geolocation, by using a supported provider or establishing your own custom providers.

It also comes with a trait that introduces three useful methods for your user model: 'logout,' 'logoutOthers,' and 'logoutAll.'

Requirements

PHP => 8.0 and Laravel => 8.x with Sanctum => 2.0

Installation

Publish the configuration with:

Run the migrations to update the tables:

Override Sanctum Model

This package comes with a custom model (Jurager\Tracker\Models\PersonalAccessToken) that extends the default Sanctum model.

Instruct Sanctum to use this custom model via the usePersonalAccessTokenModel method provided by Sanctum. Typically, you should call this method in the boot method of one of your application's service providers:

Pruning Outdated Records

This package allows you to remove outdated authentication records.

Period for records to expire is described in configuration tracker.expires.

Add schedule command to your Kernel.php, you can use period as you need

Install a User-Agent Parser

This package relies on a User-Agent parser to extract the informations.

Currently supported parsers:

Before using this package, you need to choose a supported parser.

Use the Trait

This package provides a Jurager\Tracker\Traits\Tracked trait that can be used on your user model to quickly revoke tokens.

It introduces convenient methods:

Usage

Use Sanctum as like you would normally do.

The PersonalAccessToken model provided by this package will automatically be populated with the extra informations.

IP Lookup

By default, package collects the IP and the information given by the User-Agent header.

But you can go even further and collect other data, like the geolocation.

To do so, you first have to enable the IP lookup feature in the configuration file.

This package comes with two officially supported providers for IP address lookup (see the IP Address Lookup section in the config/tracker.php configuration file).

IP2Location Lite

This package officially support the IP address geolocation with the IP2Location DB3.

Here are the steps to enable and use it:

Custom Provider

You can add your own providers by creating a class that implements the Jurager\Tracker\Interfaces\IpProvider interface and use the Jurager\Tracker\Traits\MakesApiCalls trait.

Your custom class have to be registered in the custom_providers array of the configuration file.

Let's see an example of an IP lookup provider with the built-in IpApi provider:

As you can see, the class has a getRequest method that must return a GuzzleHttp\Psr7\Request instance.

Guzzle utilizes PSR-7 as the HTTP message interface. Check its documentation: http://docs.guzzlephp.org/en/stable/psr7.html

The IpProvider interface comes with required methods related to the geolocation. All keys of the API response are accessible in your provider via $this->result, which is a Laravel collection.

If you want to collect other informations, you can add a getCustomData method in your custom provider. This custom data will be saved in the logins table in the ip_data JSON column. Let's see an example of additional data:

Handle Errors

This package fires the FailedApiCall event if an exception is triggered during an API request to your IP address lookup provider.

This event has an exception attribute containing the GuzzleHttp\Exception\TransferException (see Guzzle documentation).

This event can be listened to in order to add your own logic.

Events

PersonalAccessTokenCreated

You can listen to the Jurager/Tracker/Events/PersonalAccessTokenCreated event on a new login.

It has a personalAccessToken property, which has the newly created Jurager/Tracker/Models/PersonalAccessToken and a context property, which receives a Jurager/Tracker/RequestContext which contains all the data collected on the request.

Available properties:

Available methods:

Available methods in the parser:

Available methods in the IP address lookup provider:

License

Open source, licensed under the MIT license.


All versions of tracker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
guzzlehttp/guzzle Version ^7.4
illuminate/database Version ^8.0|^9.0|^10.0
illuminate/queue Version ^8.0|^9.0|^10.0
illuminate/support Version ^8.0|^9.0|^10.0
laravel/sanctum Version ^2.0|^3.0|^10.0
nesbot/carbon Version ^2.55.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jurager/tracker contains the following files

Loading the files please wait ....