Download the PHP package zeroad.network/token without Composer
On this page you can find all versions of the php package zeroad.network/token. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zeroad.network/token
More information about zeroad.network/token
Files in zeroad.network/token
Package token
Short Description An HTTP-header-based "access / entitlement token" library for Zero Ad Network partnering sites using PHP
License Apache-2.0
Homepage http://zeroad.network
Informations about the package token
zeroad.network/token (PHP)
The official PHP module for integrating websites with the Zero Ad Network platform.
What is Zero Ad Network?
Zero Ad Network is a browser-based platform that creates a better web experience for both users and content creators:
For Users:
- Browse without ads, trackers, cookie consent dialogs, and marketing pop-ups
- Access paywalled content across multiple sites with a single subscription
- Support content creators directly through fair revenue distribution
For Publishers:
- Generate revenue from users who would otherwise use ad blockers
- Provide a cleaner user experience while maintaining income
- Get paid based on actual user engagement with your content
How It Works:
- Users subscribe and install the Zero Ad Network browser extension
- The extension sends cryptographically signed tokens to partner sites
- Partner sites verify tokens and enable premium features (ad-free, paywall-free)
- Monthly revenue is distributed to publishers based on user engagement time
Features
This module provides:
- ✅ Zero dependencies - Lightweight and secure (only requires ext-sodium)
- ✅ Cryptographic verification - ED25519 signature validation using ext-sodium
- ✅ Performance optimized - Built-in APCu caching for 10-20x performance boost
- ✅ PHP 7.2+ compatible - Works with legacy and modern PHP versions
- ✅ Easy integration - Simple API with minimal configuration
Runtime Compatibility
| Runtime | Version | Ready |
|---|---|---|
| PHP 7 | 7.2+ | ✅ |
| PHP 8 | 8.0+ | ✅ |
Required:
ext-sodium(included by default in PHP 7.2+)
Recommended:
ext-apcu(for caching - provides 10-20x performance improvement)
Installation
Optional: Install APCu for Caching
Highly recommended for production environments:
Quick Start
1. Register Your Site
Before implementing, you need to:
- Sign up for a Zero Ad Network account
- Register your site to receive your unique
Client ID
2. Choose Your Features
Decide which features your site will support:
Constants::FEATURE['CLEAN_WEB']: Remove ads, cookie consent screens, trackers, and marketing dialogsConstants::FEATURE['ONE_PASS']: Provide free access to paywalled content and base subscription plans
3. Basic Implementation
4. In Your Templates
Token Context
After parsing, the token context contains boolean flags for each feature:
Important: All flags default to false for:
- Users without subscriptions
- Expired tokens
- Invalid/forged tokens
- Missing tokens
Performance & Caching
APCu Cache (Highly Recommended)
The module includes built-in APCu caching to dramatically improve performance by avoiding redundant cryptographic operations.
Performance Impact:
- Without cache: ~100-200μs per token verification
- With APCu cache: ~10-20μs per cached token (10-20x faster!)
- Cache is shared between all PHP-FPM workers
- Automatically respects token expiration
Configuration
How Caching Works:
- Token header is hashed (xxHash) to create cache key
- If cached and not expired, returns immediately (~15μs)
- If cache miss, performs crypto verification (~150μs)
- Result cached with TTL = min(config TTL, token expiry time)
- Expired tokens automatically removed from cache
Cache automatically respects token expiration - even with long cache TTL, expired tokens are never served from cache.
Without APCu
If APCu is not available, the module works normally but performs full crypto verification on every request. Consider:
- Enabling OPcache to cache compiled PHP code
- Using a reverse proxy cache (Varnish, nginx)
- Installing APCu for best performance
Performance Benchmarks
Typical performance on modern hardware:
| Operation | Without Cache | With APCu Cache | Improvement |
|---|---|---|---|
| Parse token | ~150μs | ~15μs | 10x faster |
| 1000 req/sec | 150ms blocking | 15ms blocking | 90% less CPU |
Advanced Configuration
Cache Configuration
Recommended TTL Settings:
| Scenario | TTL | Reason |
|---|---|---|
| High traffic (1000+ req/sec) | 10-30s | Maximize cache hits |
| Normal traffic (100-1000 req/sec) | 5-10s | Balance freshness and performance |
| Low traffic (<100 req/sec) | 2-5s | Keep data fresh |
Logging
Set Log Level:
Custom Log Handler:
Security
Token Verification
All tokens are cryptographically signed using ED25519 by Zero Ad Network:
- Signature verification happens locally on your server using Zero Ad Network's official public key
- Trusted authority - Only tokens signed by Zero Ad Network are valid
- No external API calls - verification is instant and offline
- Tamper-proof - modified tokens fail verification automatically (constant-time comparison)
- Time-limited - expired tokens are automatically rejected
Token Structure
Each token contains:
- Protocol version - Currently v1
- Nonce - Random 4-byte value
- Expiration timestamp - Unix timestamp
- Feature flags - Bitmask of enabled features
- Client ID (optional) - For developer tokens
- Cryptographic signature - ED25519 signature
Example token:
Privacy
Tokens contain no personally identifiable information:
- ❌ No user IDs
- ❌ No email addresses
- ❌ No tracking data
- ✅ Only: expiration date and feature flags
Framework Examples
Laravel
Symfony
WordPress
Complete Usage Example
Implementation Requirements
When implementing Zero Ad Network features, you must fulfill these requirements to remain in good standing:
CLEAN_WEB Requirements
- ✅ Disable all advertisements on the page
- ✅ Disable all cookie consent screens (headers, footers, dialogs)
- ✅ Fully opt out users from non-functional trackers
- ✅ Disable all marketing dialogs or popups (newsletters, promotions)
ONE_PASS Requirements
- ✅ Provide free access to content behind paywalls
- ✅ Provide free access to your base subscription plan (if applicable)
⚠️ Failure to comply will result in removal from the Zero Ad Network platform.
Troubleshooting
Tokens Not Working
Check APCu Status
Common Issues
- All flags are false - Token is expired, invalid, or missing
- Performance slow - Install APCu for 10-20x speedup
- Token rejected - Verify Client ID matches registered site
- Headers not sent - Ensure header() is called before any output
API Reference
Site
Creates a site instance with helper methods.
Constants
Logger
Resources
License
Apache License 2.0 - see LICENSE file for details
About Zero Ad Network
Zero Ad Network is building a fairer internet where:
- Users enjoy cleaner, faster browsing
- Publishers earn sustainable revenue
- Privacy is respected by default
Join thousands of publishers creating a better web experience.
All versions of token with dependencies
ext-sodium Version *