modernman00 / shared-lib
Shared library for common functions and classes across projects
Requires
- cloudmersive/cloudmersive_virusscan_api_client: ^3.1
- dompdf/dompdf: ^3.1
- eftec/bladeone: ^4.18
- firebase/php-jwt: ^7.0
- guzzlehttp/guzzle: ^7.9
- intervention/image: ^3.11
- monolog/monolog: ^3.9
- mpdf/mpdf: ^8.3
- pelago/emogrifier: ^7.3
- phpmailer/phpmailer: ^6.9
- spatie/image-optimizer: ^1.6
- sunspikes/clamav-validator: ^3.0
- symfony/mailer: ^7.3
- symfony/rate-limiter: ^7.2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- mockery/mockery: ^1.6
- php-mock/php-mock: ^2.6
- php-mock/php-mock-phpunit: ^2.13
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-06-17 00:30:13 UTC
README
A comprehensive PHP shared library containing common functions and classes for use across multiple projects.
Features
- Authentication & Security: JWT handling, secure sessions, token management
- Database Operations: PDO utilities, query builders, database helpers
- Form Building: Bootstrap and Bulma form builders
- File Management: Upload handling, image optimization, virus scanning
- Email Services: PHPMailer integration, email templates
- Validation & Sanitization: Input validation, data sanitization
- Rate Limiting: Request throttling and rate limiting
- Logging: Monolog integration for structured logging
- Exception Handling: Custom exception classes
Installation
Install via Composer:
composer require waleolaogun/shared-lib
Requirements
- PHP 8.1 or higher
- Composer for dependency management
Usage
Basic Example
<?php require_once 'vendor/autoload.php'; use Src\Auth; use Src\Db; use Src\Utility; // Initialize database connection $db = new Db(); // Use authentication $auth = new Auth($db); // Use utility functions $sanitized = Utility::sanitizeInput($_POST['data']);
Available Classes
Src\Auth- Authentication and authorizationSrc\Db- Database operations and utilitiesSrc\Email- Email sending capabilitiesSrc\FileUploader- File upload handlingSrc\JwtHandler- JWT token managementSrc\Limiter- Rate limiting functionalitySrc\Utility- General utility functions- And many more...
Development
Setting Up Development Environment
-
Clone the repository:
git clone https://github.com/modernman00/shared-lib.git cd shared-lib -
Install dependencies:
composer install
-
Run code quality checks:
# PHP CS Fixer vendor/bin/php-cs-fixer fix --dry-run --diff # PHPStan static analysis vendor/bin/phpstan analyse
Code Quality Standards
This project follows PSR-12 coding standards and uses:
- PHP CS Fixer for code formatting
- PHPStan for static analysis (Level 6)
- Composer audit for security vulnerability scanning
CI/CD Pipeline
The project uses GitHub Actions for continuous integration and deployment:
- Automated Testing: Runs on PHP 8.1, 8.2, and 8.3
- Code Quality Checks: PHP CS Fixer and PHPStan analysis
- Security Scanning: Dependency vulnerability checks
- Automated Dependency Updates: Dependabot integration
- Release Management: Automated release asset creation
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and ensure they pass all quality checks
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
All pull requests are automatically tested against our CI pipeline.
Running Tests Locally
# Install development dependencies composer install --dev # Run PHP CS Fixer vendor/bin/php-cs-fixer fix --dry-run --diff --verbose # Run static analysis vendor/bin/phpstan analyse --memory-limit=1G # Check for security vulnerabilities composer audit
Versioning
This project uses Semantic Versioning. For available versions, see the releases page.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please open an issue on the GitHub repository.
Changelog
For a detailed changelog, see RELEASES.