Download the PHP package williamug/versioning without Composer
On this page you can find all versions of the php package williamug/versioning. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download williamug/versioning
More information about williamug/versioning
Files in williamug/versioning
Package versioning
Short Description A PHP package that helps you display the version of your Laravel or vanilla PHP application by leveraging git version tags
License MIT
Homepage https://github.com/williamug/versioning
Informations about the package versioning
Versioning
A robust PHP package that helps you display your application's version by leveraging Git tags. Features include caching, multiple format options, error handling, and support for both Laravel and vanilla PHP applications.
Works with Laravel and vanilla PHP!
Quick Links:
- Vanilla PHP: VANILLA-PHP-USAGE.md - Standalone usage without Laravel
- FTP Deployment: FTP-DEPLOYMENT.md - Deploy via FTP without git
Features
- Multiple Version Formats: Tag, full, commit hash, or tag with commit
- Performance: Built-in caching support to minimize Git command executions
- Secure: Proper input sanitization and error handling
- Laravel Integration: Seamless integration with Laravel's facade and Blade directives
- Vanilla PHP Support: Works standalone without any framework
- Configurable: Extensive configuration options
- FTP Deployment Support: Works with deployments that don't include git history
- Well-tested: Comprehensive test coverage
Requirements
- PHP 8.2 or higher
- Laravel 10.x, 11.x, or 12.x (for Laravel integration) or vanilla PHP
- Git installed on your system
- Optional: Laravel Cache for caching (automatically available in Laravel)
Installation
Install the package via Composer:
Laravel Configuration (Optional)
Publish the configuration file:
This creates config/versioning.php where you can customize:
Usage
Vanilla PHP
Option 1: Using the Helper Function (Simplest)
Option 2: Using the Standalone Class (More Features)
See VANILLA-PHP-USAGE.md for complete standalone usage guide.
Laravel
Using the Facade
Using Blade Directives
Using the Helper Function
Configuration Options
Repository Path
Specify where your .git directory is located:
Caching
Enable caching to improve performance:
Fallback Version
Set a default version when Git is unavailable:
You can set this in your .env:
Version Format
Choose default format:
Version Prefix
Control whether to include 'v' prefix:
Error Handling
The package gracefully handles errors:
- Returns fallback version if Git is not installed
- Returns fallback version if not in a Git repository
- Returns fallback version if no tags exist
- Catches and handles all exceptions
Testing
Development
Common Use Cases
Display Version in Footer
API Response
Admin Dashboard
Clear Cache After Deployment
Troubleshooting
"dev" is always displayed
- Ensure you're in a Git repository
- Ensure Git is installed:
git --version - Ensure you have tags:
git tag - Check your repository path in config
Create a tag if none exist
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Asaba William
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of versioning with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0