Download the PHP package daycry/jwt without Composer
On this page you can find all versions of the php package daycry/jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package jwt
Short Description JWT Token for Codeigniter 4
License MIT
Homepage https://github.com/daycry/jwt
Informations about the package jwt
JWT for CodeIgniter 4
A high-performance JWT (JSON Web Token) library for CodeIgniter 4, built on top of the robust lcobucci/jwt
package.
โจ Features
- ๐ High Performance: Lazy loading and constraint caching for optimal speed
- ๐ Secure: Built on
lcobucci/jwt
with configurable validation constraints - โก Fast Methods: Quick validation and claim extraction without full decoding
- ๐๏ธ Flexible Configuration: Environment-aware settings and multiple algorithms
- ๐งช Well Tested: Comprehensive test suite with performance benchmarks
- ๐ฑ CI4 Integration: Native CodeIgniter 4 integration with services and helpers
๐ Requirements
- PHP 8.1 or higher
- CodeIgniter 4.x
lcobucci/jwt ^4.0
๐ Installation
Via Composer (Recommended)
Manual Installation
- Download this repository
- Add the namespace to app/Config/Autoload.php:
โ๏ธ Configuration
Publish Configuration File
This creates app/Config/JWT.php
with all available options:
Available CLI Commands
The library includes several helpful CLI commands:
Configuration File Structure
After publishing, you'll have app/Config/JWT.php
:
Environment Variables Support
For security, use environment variables in your .env
file. You can copy the provided example:
Then reference them in your configuration:
Note: CodeIgniter 4 automatically loads environment variables into configuration files, so no additional constructor is needed.
๐ Basic Usage
Simple Token Creation and Validation
Custom Configuration
๐๏ธ Advanced Usage
Custom Data Parameter
Array Data Handling
Encoded as JSON (Default)
Split as Individual Claims
โก High-Performance Methods
Quick Validation (No Full Decoding)
Unsafe Claim Extraction (Performance Critical)
Expiry Checking
๐ง Configuration Options
Validation Constraints
You can customize which constraints to validate:
Supported Algorithms
๐ ๏ธ Integration Features
CodeIgniter 4 Services
Helper Functions (If Implemented)
๐งช Testing and Benchmarks
Run Tests
Performance Benchmark
Sample benchmark results:
๐ Security Best Practices
1. Use Strong Secret Keys
The jwt:key
command will automatically add the key to your .env
file:
Important: Never commit your secret keys to version control. Always use environment variables.
2. Configure Appropriate Expiry Times
3. Validate All Necessary Claims
๐จ Error Handling
With Exceptions (Default)
Without Exceptions
๐ API Reference
Main Methods
Method | Description | Performance |
---|---|---|
encode($data, $uid = null) |
Create JWT token | Standard |
decode($token) |
Validate and decode token | Standard |
isValid($token) |
Quick validation check | Fast |
extractClaimsUnsafe($token) |
Extract without validation | Fastest |
isExpired($token) |
Check if token expired | Fast |
getTimeToExpiry($token) |
Get seconds until expiry | Fast |
clearCache() |
Clear constraint cache | Instant |
Configuration Methods
Method | Description |
---|---|
setParamData($name) |
Set custom data parameter name |
setSplitData($enabled) |
Enable/disable claim splitting |
getParamData() |
Get current data parameter name |
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built on top of the excellent
lcobucci/jwt
library - Inspired by the CodeIgniter 4 community
- Thanks to all contributors and users
๐ฌ Support
- ๐ซ Create an issue for bug reports or feature requests
- ๐ฐ Donate via PayPal to support development