tecnozt/proteczt-client

Laravel client package for Proteczt License Management System - verify and control application licenses remotely.

Maintainers

Package info

github.com/jarwonozt/proteczt-client

Homepage

pkg:composer/tecnozt/proteczt-client

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-02-26 17:41 UTC

This package is auto-updated.

Last update: 2026-04-26 18:26:05 UTC


README

Packagist Version PHP Version License

Laravel client package for Proteczt — a remote license management system. Install this package in your distributed Laravel applications to control access from a central Proteczt server.

Requirements

Dependency Version
PHP ^8.2
Laravel ^11.0 or ^12.0

Installation

composer require tecnozt/proteczt-client

Laravel auto-discovery registers the service provider automatically. No manual registration needed.

Configuration

1. Publish the config file

php artisan vendor:publish --tag=proteczt-config

This creates config/proteczt.php in your application.

2. Add environment variables to .env

PROTECZT_API_URL=https://your-proteczt-server.com
PROTECZT_API_TOKEN=your-api-token-here
PROTECZT_DOMAIN=your-app-domain.com   # Optional — auto-detected if omitted

# Optional tuning
PROTECZT_AUTO_REGISTER=true
PROTECZT_SKIP_LOCAL=true
PROTECZT_CACHE_DURATION=0        # 0 = real-time (check every request), 60-300 = reduce API load
PROTECZT_TIMEOUT=10
PROTECZT_VERIFY_SSL=true

Get your API token: Login to your Proteczt server dashboard → API Tokens → Generate New Token.

3. Register the middleware

Apply license checking to your routes. In bootstrap/app.php (Laravel 11+):

use Tecnozt\Proteczt\Http\Middleware\CheckProtecztLicense;

->withMiddleware(function (Middleware $middleware) {
    // Apply to all web routes:
    $middleware->append(CheckProtecztLicense::class);

    // Or apply only to specific route groups (recommended):
    $middleware->alias([
        'proteczt' => CheckProtecztLicense::class,
    ]);
})

Then in your routes:

// routes/web.php
Route::middleware('proteczt')->group(function () {
    // Protected routes
});

4. Register your application

php artisan proteczt:register

This sends your application details (name, domain, hostname) to the Proteczt server. This also happens automatically on the first web request if auto_register is enabled.

How It Works

┌─────────────────────┐           Register / Check Status           ┌─────────────────────┐
│  Laravel App        │ ─────────────────────────────────────────>  │  Proteczt Server    │
│  (Client)           │                                              │  (License API)      │
│                     │  { active: true/false }                     │                     │
│  CheckProteczt      │ <─────────────────────────────────────────  │                     │
│  License Middleware │                                              └─────────────────────┘
└─────────────────────┘
        │
        ├─ active: true  → Request continues normally
        └─ active: false → 403 License Inactive page (or JSON)
  1. First boot: Service provider registers the app with Proteczt (stored in storage/app/.proteczt_registered).
  2. Every request: Middleware checks license status (cached for 1 hour by default).
  3. If active: Request passes through normally.
  4. If inactive/expired: Returns 403 with an error page (or JSON for API requests).
  5. If server is unreachable: Fail-open — request is allowed to prevent downtime.

Artisan Commands

Command Description
php artisan proteczt:register Register this app to Proteczt server
php artisan proteczt:register --force Re-register (overwrite existing)
php artisan proteczt:check Check license status (from cache)
php artisan proteczt:check --fresh Check status (bypass cache)
php artisan proteczt:refresh Force-refresh license cache

Controlling Your App from the Server

Once installed, you control the application entirely from the Proteczt dashboard:

Action Effect
Set status → Inactive App blocked within 1 hour (or immediately after proteczt:refresh)
Set status → Active App resumes within 1 hour
Set Expired At date App automatically blocked on that date
Delete client App unregistered — future check-status returns inactive

Facade

use Tecnozt\Proteczt\Facades\Proteczt;

// Check if license is active
if (Proteczt::isActive()) {
    // proceed
}

// Get full status with data
$status = Proteczt::checkStatus();
// $status['active']      → bool
// $status['data']        → array|null (app info from server)
// $status['fail_open']   → bool (true if server was unreachable)

// Force refresh
Proteczt::refreshStatus();

// Register (usually automatic)
Proteczt::register();

Publishing Views

To customise the "License Inactive" error page:

php artisan vendor:publish --tag=proteczt-views

This copies the view to resources/views/vendor/proteczt/errors/license-expired.blade.php.

Configuration Reference

Key Env Variable Default Description
api_url PROTECZT_API_URL Proteczt server URL (required)
api_token PROTECZT_API_TOKEN Bearer token from Proteczt (required)
domain PROTECZT_DOMAIN null (auto) Override domain detection
auto_register PROTECZT_AUTO_REGISTER true Auto-register on first request
skip_local PROTECZT_SKIP_LOCAL true Skip check in local/testing env
cache_duration PROTECZT_CACHE_DURATION 0 Cache TTL in seconds (0 = no cache, real-time enforcement)
timeout PROTECZT_TIMEOUT 10 HTTP request timeout in seconds
verify_ssl PROTECZT_VERIFY_SSL true Verify SSL certificates

Security

  • API token is stored in .env and never exposed to end users.
  • Cache keys are SHA-256 hashed (domain + token) to prevent enumeration.
  • Fail-open by design: If the Proteczt server is unreachable, your clients will not experience downtime. If you prefer fail-closed, override isActive() via the service container.
  • HTTPS strongly recommended in production. The verify_ssl option should always be true.
  • A 401/403 response from the server (e.g., invalid token) immediately returns inactive without caching.

Testing

# Check if the package is correctly integrated
php artisan proteczt:check

# Force block your app to test the error page
# → Go to Proteczt dashboard → Clients → Set status to Inactive
# → Clear cache:
php artisan proteczt:refresh
# → Visit any route — you should see the license error page

# Re-enable your app
# → Set status to Active in the dashboard
php artisan proteczt:refresh

Troubleshooting

Problem Solution
App not registering Check PROTECZT_API_URL and PROTECZT_API_TOKEN in .env
App always blocked Check client status in Proteczt dashboard
Stale status after change Run php artisan proteczt:refresh
SSL error in local Set PROTECZT_VERIFY_SSL=false (local only)
Skip not working Set PROTECZT_SKIP_LOCAL=true and APP_ENV=local

Changelog

See CHANGELOG.md.

License

MIT — see LICENSE.

Made with ❤️ by Tecnozt