sado729 / project-version
Laravel Project Version Automatically Increase
Requires
- php: ^8.0
- illuminate/console: ^9.0|^10.0|^11.0
- illuminate/database: ^9.0|^10.0|^11.0
- illuminate/events: ^9.0|^10.0|^11.0
- illuminate/http: ^9.0|^10.0|^11.0
- illuminate/routing: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- illuminate/view: ^9.0|^10.0|^11.0
- symfony/process: ^6.0|^7.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.0|^10.0
This package is auto-updated.
Last update: 2026-05-17 12:53:40 UTC
README
Laravel paketi layihənizin versiyasını avtomatik olaraq git aktivliyinə əsasən artırır. Versiya "major.minor.patch" formatındadır:
- patch — hər dəyişdirilən fayl üçün +1 (ignor edilməyənlər arasından)
- minor —
module_pathskonfiqurasiyasındakı qovluqlara əlavə olunan hər yeni modul üçün +1, patch sıfırlanır - major —
version:release majorkomandası ilə artırılır
Versiya informations cədvəlində saxlanılır, tarixçə isə version_histories cədvəlində.
Quraşdırma
composer require sado729/project-version
php artisan vendor:publish --provider="Sado729\ProjectVersion\ProjectVersionServiceProvider"
php artisan migrate
config/project-version.php-ni öz layihənizə uyğunlaşdırın (ignor paternləri, modul yolları, patch overflow, və s.).
Avtomatik versiyalama (tövsiyə olunan)
php artisan version:install-hooks
Bu komanda .git/hooks/post-commit və post-merge skriptlərini yazır. Mövcud hook-larla toqquşmur — özünə aid bloku marker arasında əlavə edir, başqa məzmunu pozmur. Yenidən çağırılsa, mövcud bloku yeniləyir (idempotent).
Bundan sonra:
git commit→ versiya son commit-in diff-inə görə yenilənirgit pull/git merge→ versiyaORIG_HEAD..HEADdiapazonuna görə yenilənir
Hook-u silmək üçün:
php artisan version:install-hooks --uninstall
.git/hooks/versiya nəzarətində saxlanılmadığından hər klondan sonra bir dəfə quraşdırılmalıdır.
Əl ilə komandalar
# İki ref arası diff (custom range) php artisan version:bump --from=HEAD~1 --to=HEAD # Working tree (uncommitted + untracked) php artisan version:bump --working-tree # Manual release php artisan version:release patch php artisan version:release minor php artisan version:release major # Köhnə davranış: git pull + bump php artisan git:pull
View-da istifadə
<footer>v@projectVersion</footer>
Yaxud helper:
echo project_version(); // "1.2.7"
Konfiqurasiya
config/project-version.php:
| Açar | Təyinat |
|---|---|
ignore_patterns |
Versiyaya təsir etməyən fayllar (glob, fnmatch ilə müqayisə). Default: *.md, lock fayllar, vendor/*, node_modules/*, storage/*, tests/*, və s. |
module_paths |
"Yeni modul" sayılan yollar. Default: app/*. |
patch_rollover_threshold |
Patch bu rəqəmə çatanda minor-a roll over edir. Default: null (söndürülmüş). Məs. 100 → 1.0.847 əvəzinə 1.8.47. |
history_enabled |
version_histories cədvəlinə hər bump-da yazsın? Default: true. |
git_repository_name, git_branch_name |
git:pull komandası üçün. |
Event
use Sado729\ProjectVersion\Events\GitPullEvent; Event::listen(GitPullEvent::class, function (GitPullEvent $event) { logger()->info("Yeni versiya: {$event->version}"); });
Middleware
Route::middleware('project-version')->group(fn () => /* ... */);
CI/CD
Local hook əvəzinə CI-də versiyalama üçün hazır nümunə: examples/github-actions-version-bump.yml.
Testlər
composer install vendor/bin/phpunit
License
MIT — License File