PHPackages                             aqtivite/laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. aqtivite/laravel

ActiveLibrary[Framework](/categories/framework)

aqtivite/laravel
================

Laravel wrapper for the Aqtivite PHP SDK

0390↓71.4%PHP

Since Apr 5Pushed 3mo agoCompare

[ Source](https://github.com/aqtivite-dev/laravel)[ Packagist](https://packagist.org/packages/aqtivite/laravel)[ RSS](/packages/aqtivite-laravel/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Aqtivite Laravel
================

[](#aqtivite-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ec61fc35046a4a1221052a3b8ea3b1aad8116aa7acbddf2fd4de7e3a777faaa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61717469766974652f6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aqtivite/laravel)[![Total Downloads](https://camo.githubusercontent.com/412e21ae7ffa890c4cbd8ee2c50c92ddbbc26b23008440e4a990d91d322da7d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61717469766974652f6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aqtivite/laravel)

Laravel wrapper for the [Aqtivite PHP SDK](https://github.com/aqtivite/php), providing a seamless integration with Laravel's ecosystem including automatic token management, events, Artisan commands, and more.

Features
--------

[](#features)

- 🔐 **Automatic Token Management** - Tokens are automatically stored, refreshed, and validated
- 📦 **Laravel Integration** - Facade, helper functions, and dependency injection support
- 🎯 **Events** - Laravel events for token lifecycle (loaded, refreshed, expired, cleared)
- ⚡ **Artisan Commands** - CLI commands for login, logout, health checks, and more
- 🔧 **Flexible Storage** - Cache or file-based token storage with custom driver support
- 🎨 **Macroable** - Extend the client with custom functionality using macros
- 🛡️ **Type Safe** - Full IDE autocomplete and type hinting support

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- Laravel 11.0 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require aqtivite/laravel
```

Publish the configuration file:

```
php artisan vendor:publish --tag=aqtivite-config
```

Configuration
-------------

[](#configuration)

Add your Aqtivite credentials to your `.env` file:

```
AQTIVITE_CLIENT_ID=your_client_id
AQTIVITE_CLIENT_SECRET=your_client_secret

# Authentication method: password or api_key
AQTIVITE_AUTH_METHOD=password
AQTIVITE_USERNAME=your_username
AQTIVITE_PASSWORD=your_password

# Optional: Use test environment
AQTIVITE_TEST_MODE=false

# Optional: Token storage driver (cache or file)
AQTIVITE_TOKEN_STORE=cache
```

### Configuration File

[](#configuration-file)

The configuration file `config/aqtivite.php` contains all available options:

```
return [
    'client_id' => env('AQTIVITE_CLIENT_ID'),
    'client_secret' => env('AQTIVITE_CLIENT_SECRET'),
    'test_mode' => env('AQTIVITE_TEST_MODE', false),
    'base_url' => env('AQTIVITE_BASE_URL'),

    'auth' => [
        'method' => env('AQTIVITE_AUTH_METHOD', 'password'),
        'username' => env('AQTIVITE_USERNAME'),
        'password' => env('AQTIVITE_PASSWORD'),
        'api_key' => env('AQTIVITE_API_KEY'),
        'api_secret' => env('AQTIVITE_API_SECRET'),
    ],

    'token_store' => [
        'driver' => env('AQTIVITE_TOKEN_STORE', 'cache'),
        'cache_key' => 'aqtivite_token',
        'file_path' => storage_path('app/aqtivite_token.json'),
    ],
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Using the helper function:

```
// Get authenticated user
$user = aqtivite()->me();

// List users
$users = aqtivite()->user()->list();

// Get specific user
$user = aqtivite()->user()->get($userId);

// Create user
$newUser = aqtivite()->user()->create([
    'name' => 'John Doe',
    'email' => 'john@example.com',
]);
```

Using the Facade:

```
use Aqtivite\Laravel\Facades\Aqtivite;

$user = Aqtivite::me();
$users = Aqtivite::user()->list();
```

Using dependency injection:

```
use Aqtivite\Laravel\Aqtivite;

class UserController extends Controller
{
    public function __construct(private Aqtivite $aqtivite)
    {
    }

    public function index()
    {
        return $this->aqtivite->user()->list();
    }
}
```

### Token Management

[](#token-management)

Tokens are automatically managed - you don't need to handle authentication manually:

```
// Check if token exists
if (aqtivite()->hasStoredToken()) {
    // Token exists
}

// Get stored token
$token = aqtivite()->getStoredToken();

// Clear token (forces re-authentication on next request)
aqtivite()->clearToken();

// Manual login
$token = aqtivite()->login();

// Logout
aqtivite()->logout();
```

Token Storage
-------------

[](#token-storage)

### Cache Driver (Default)

[](#cache-driver-default)

Stores tokens in Laravel's cache. Fast and recommended for most applications.

```
AQTIVITE_TOKEN_STORE=cache
```

**Pros:**

- Fast
- Uses your existing cache driver (Redis, Memcached, etc.)
- Automatic expiration

**Cons:**

- Cleared when cache is flushed (`php artisan cache:clear`)

### File Driver

[](#file-driver)

Stores tokens in a JSON file on disk. Useful for long-running processes.

```
AQTIVITE_TOKEN_STORE=file
```

**Pros:**

- Persists across cache flushes
- Survives application restarts
- Useful for queue workers and scheduled tasks

**Cons:**

- Slower than cache
- Requires file write permissions

### Custom Driver

[](#custom-driver)

Implement your own token storage:

```
use Aqtivite\Laravel\Contracts\TokenStoreInterface;
use Aqtivite\Php\Auth\Token;

class DatabaseTokenStore implements TokenStoreInterface
{
    public function get(): ?Token
    {
        $data = DB::table('aqtivite_tokens')->first();

        if (!$data) {
            return null;
        }

        return new Token(
            accessToken: $data->access_token,
            refreshToken: $data->refresh_token,
            tokenType: $data->token_type,
            expiresIn: $data->expires_in,
        );
    }

    public function put(Token $token): void
    {
        DB::table('aqtivite_tokens')->updateOrInsert(
            ['id' => 1],
            [
                'access_token' => $token->accessToken,
                'refresh_token' => $token->refreshToken,
                'token_type' => $token->tokenType,
                'expires_in' => $token->expiresIn,
                'updated_at' => now(),
            ]
        );
    }

    public function forget(): void
    {
        DB::table('aqtivite_tokens')->delete();
    }
}
```

Register in `config/aqtivite.php`:

```
'token_store' => [
    'driver' => \App\Services\DatabaseTokenStore::class,
],
```

Events
------

[](#events)

Listen to token lifecycle events in your `EventServiceProvider`:

```
use Aqtivite\Laravel\Events\{
    TokenLoaded,
    TokenRefreshed,
    TokenExpired,
    TokenCleared,
    LoginSucceeded,
    LogoutSucceeded,
    AuthenticationFailed,
};

protected $listen = [
    TokenRefreshed::class => [
        LogTokenRefresh::class,
    ],

    TokenExpired::class => [
        NotifyAdminOfExpiredToken::class,
    ],

    AuthenticationFailed::class => [
        LogAuthenticationFailure::class,
        SendSlackAlert::class,
    ],
];
```

### Available Events

[](#available-events)

EventDescriptionProperties`TokenLoaded`Token loaded from storage`$token``TokenRefreshed`Token refreshed automatically`$token``TokenExpired`Expired token detected and removed`$token``TokenCleared`Token manually cleared-`LoginSucceeded`Manual login successful`$token``LogoutSucceeded`Logout successful-`AuthenticationFailed`Authentication failed`$message`, `$exception`### Example Listener

[](#example-listener)

```
namespace App\Listeners;

use Aqtivite\Laravel\Events\TokenRefreshed;
use Illuminate\Support\Facades\Log;

class LogTokenRefresh
{
    public function handle(TokenRefreshed $event): void
    {
        Log::info('Aqtivite token refreshed', [
            'expires_in' => $event->token->expiresIn,
            'timestamp' => now(),
        ]);
    }
}
```

Artisan Commands
----------------

[](#artisan-commands)

### Login

[](#login)

Manually authenticate and obtain a token:

```
php artisan aqtivite:login
```

### Logout

[](#logout)

Logout and clear the stored token:

```
php artisan aqtivite:logout
```

### Check Session

[](#check-session)

Validate the current session and display user information:

```
php artisan aqtivite:check-session
```

### Health Check

[](#health-check)

Check API connectivity and authentication status:

```
php artisan aqtivite:health
```

### Token Status

[](#token-status)

Display the current token status:

```
php artisan aqtivite:status
```

### Clear Token

[](#clear-token)

Clear the stored token:

```
php artisan aqtivite:clear-token
```

Advanced Usage
--------------

[](#advanced-usage)

### Extending with Macros

[](#extending-with-macros)

Add custom functionality using macros:

```
use Aqtivite\Laravel\Aqtivite;

// In a service provider
public function boot()
{
    Aqtivite::macro('admin', function () {
        return new AdminModule($this->getHttpClient());
    });
}

// Usage
aqtivite()->admin()->users()->list();
```

### Example: Admin Module

[](#example-admin-module)

```
namespace App\Aqtivite;

use Aqtivite\Php\Modules\Module;

class AdminModule extends Module
{
    public function users()
    {
        return new AdminUserResource($this->http);
    }

    public function roles()
    {
        return new RoleResource($this->http);
    }
}
```

### Testing

[](#testing)

Mock the Aqtivite client in your tests:

```
use Aqtivite\Laravel\Aqtivite;
use Aqtivite\Php\Response\ApiResponse;

public function test_user_list()
{
    $mock = $this->mock(Aqtivite::class);

    $mock->shouldReceive('user->list')
        ->once()
        ->andReturn(new ApiResponse(
            status: true,
            data: [
                ['id' => 1, 'name' => 'John Doe'],
                ['id' => 2, 'name' => 'Jane Smith'],
            ]
        ));

    $response = $this->get('/api/users');

    $response->assertStatus(200);
}
```

### Error Handling

[](#error-handling)

All exceptions extend `Aqtivite\Php\Exceptions\AqtiviteException`:

```
use Aqtivite\Php\Exceptions\{
    AqtiviteException,
    AuthenticationException,
    ApiException,
};

try {
    $user = aqtivite()->user()->get($userId);
} catch (AuthenticationException $e) {
    // Authentication failed
    Log::error('Aqtivite auth failed: ' . $e->getMessage());
} catch (ApiException $e) {
    // API error
    Log::error('Aqtivite API error: ' . $e->getMessage());
} catch (AqtiviteException $e) {
    // General Aqtivite error
    Log::error('Aqtivite error: ' . $e->getMessage());
}
```

API Documentation
-----------------

[](#api-documentation)

For full API documentation, visit the [Aqtivite API Documentation](https://api.aqtivite.com.tr/docs).

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for recent changes.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Aqtivite Team](https://github.com/aqtivite)
- [All Contributors](../../contributors)

License
-------

[](#license)

This software is proprietary and confidential. The source code is publicly available for transparency and security auditing, but usage requires a valid license agreement.

**Copyright © 2024-2026 Aqtivite. All rights reserved.**

For licensing information and inquiries:

- Email:
- Website:

Please see [LICENSE.md](LICENSE.md) for complete terms and conditions.

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance55

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e4800fac3175e2175f25894653a0bec431b5ff0a920c57d89cbf84a5574685a?d=identicon)[aqtivite](/maintainers/aqtivite)

---

Top Contributors

[![x-adam](https://avatars.githubusercontent.com/u/60411758?v=4)](https://github.com/x-adam "x-adam (10 commits)")

### Embed Badge

![Health badge](/badges/aqtivite-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/aqtivite-laravel/health.svg)](https://phpackages.com/packages/aqtivite-laravel)
```

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M299](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
