{"id":34638302,"url":"https://github.com/spinen/laravel-version","last_synced_at":"2025-12-24T17:12:28.294Z","repository":{"id":56371163,"uuid":"171871830","full_name":"spinen/laravel-version","owner":"spinen","description":"Helpers to keep track of the version of your Laravel application","archived":false,"fork":false,"pushed_at":"2025-11-30T15:05:15.000Z","size":73,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-12-02T21:58:34.206Z","etag":null,"topics":["api","api-client","client","laravel","semantic","spinen","version"],"latest_commit_sha":null,"homepage":"https://spinen.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spinen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-02-21T12:56:21.000Z","updated_at":"2025-11-30T15:05:08.000Z","dependencies_parsed_at":"2024-04-09T00:36:36.577Z","dependency_job_id":null,"html_url":"https://github.com/spinen/laravel-version","commit_stats":{"total_commits":75,"total_committers":4,"mean_commits":18.75,"dds":0.2533333333333333,"last_synced_commit":"bbf070a5bc04d9c83da3c51ebadaef3a27984f33"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/spinen/laravel-version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spinen","download_url":"https://codeload.github.com/spinen/laravel-version/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spinen%2Flaravel-version/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28005414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","client","laravel","semantic","spinen","version"],"created_at":"2025-12-24T17:11:01.456Z","updated_at":"2025-12-24T17:12:28.279Z","avatar_url":"https://github.com/spinen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SPINEN's Laravel Version\n\n[![Latest Stable Version](https://poser.pugx.org/spinen/laravel-version/v/stable)](https://packagist.org/packages/spinen/laravel-version)\n[![Latest Unstable Version](https://poser.pugx.org/spinen/laravel-version/v/unstable)](https://packagist.org/packages/spinen/laravel-version)\n[![Total Downloads](https://poser.pugx.org/spinen/laravel-version/downloads)](https://packagist.org/packages/spinen/laravel-version)\n[![License](https://poser.pugx.org/spinen/laravel-version/license)](https://packagist.org/packages/spinen/laravel-version)\n\nThere are many times that it is nice to know the version of your application.  At [Spinen](https://spinen.com), we adhere to [Semantic Versioning](https://semver.org) for our applications using [git-flow](https://github.com/nvie/gitflow).  We keep a file in the root of our projects named `VERSION` with the current version. The CI/CD process modifies the `VERSION` file to append meaningful data. Then in the views we display the version like this `\u003cmeta name=\"application-version\" content=\"{{ $version }}\"\u003e`. Additionally, we have a smokescreen test to hit a `/version` route to make sure that the expected version of the site is running.\n\n## Build Status\n\n| Branch | Status | Coverage | Code Quality |\n| ------ | :----: | :------: | :----------: |\n| Develop | [![Build Status](https://github.com/spinen/laravel-version/workflows/CI/badge.svg?branch=develop)](https://github.com/spinen/laravel-version/workflows/CI/badge.svg?branch=develop) | [![Code Coverage](https://scrutinizer-ci.com/g/spinen/laravel-version/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-version/?branch=develop) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-version/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/spinen/laravel-version/?branch=develop) |\n| Master | [![Build Status](https://github.com/spinen/laravel-version/workflows/CI/badge.svg?branch=master)](https://github.com/spinen/laravel-version/workflows/CI/badge.svg?branch=master) | [![Code Coverage](https://scrutinizer-ci.com/g/spinen/laravel-version/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-version/?branch=master) | [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spinen/laravel-version/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spinen/laravel-version/?branch=master) |\n\n## Prerequisite\n\nAs side from Laravel \u003e= 8, there are no packages that are required.\n\n## Install\n\nInstall Version:\n\n```bash\n$ composer require spinen/laravel-version\n```\n\nThe package uses the [auto registration feature](https://laravel.com/docs/5.8/packages#package-discovery) of Laravel 5.\n\n## Description of version file\n\nYou need a file, with the Semantic Version of your application. For example...\n\n```text\n4.3.6\n```\n\nThen you can add additional data either manually or via your CI/CD pipeline to be similar to this...\n\n```text\n4.3.6\n\nfeature/some_great_thing\nsha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0\nbuild:11425\n20190220170058+0000\n```\n\nBreakdown of the line of the file\n\n| Line | Content | Source | Purpose |\n| :----: | ------ | ------ | ------ |\n| 1 | 4.3.6 | Original content in the `VERSION` file | Split on `.` to get `major`, `minor`, `patch` |\n| 2 | \"\\n\" | (Optional) New line | Readability |\n| 3 | feature/some_great_thing | Name of branch | Becomes the `pre_release` |\n| 4 | sha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0 | Git commit SHA | Part of `meta` |\n| 5 | build:11425 | Build number | Part of `meta` |\n| 6 | 20190220170058+0000 | Datetime stamp of build | Part of `meta` |\n\nSome notes about the file...\n\n* We assume that the first line is only `major`.`minor`.`patch`\n* The first non-empty line after the version will become the `pre_release`\n* If `pre_release` is `master`, then it gets ignored\n* All of the lines after the line being used as the `pre_release` get concatenated together with a `.` to become the `meta`, so there can be as many lines as you would like\n\n## Using the package\n\nThe `Spinen\\Version\\Version` object loads the configured version file to parse the file into the following public properties on the object...\n\n| Property | Example |\n| ------ | ------ |\n| semver | 4.3.6-feature/some_great_thing+sha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0.build:11425.20190220170058+0000 |\n| version | 4.3.6 |\n| major | 4 |\n| minor | 3 |\n| patch | 6 |\n| pre_release | feature/some_great_thing |\n| meta | sha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0.build:11425.20190220170058+0000 |\n\nYou can inject `Spinen\\Version\\Version` into your code to gain access to the properties.  For our use, here are 3 main uses of the package...\n\n1. `$version` variable in views\n2. `/version` route\n3. `version` commands\n\n#### Variable in views\n\nAn instance of `\\Spinen\\Version\\Version` is added to to all views as the `$version` variable. You can do things like...\n\n* Add version to HTML Header\n    * `\u003cmeta name=\"application-version\" content=\"{{ $version }}\"\u003e` to get `\u003cmeta name=\"application-version\" content=\"4.3.6-feature/some_great_thing+sha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0.build:11425.20190220170058+0000\"\u003e`\n    * NOTE: Casting object to string is the same as `$version-\u003esemver`\n* Add version to footer of page\n    * `\u003csmall class=\"app_version\"\u003e{{ $version-\u003eversion }}\u003c/small\u003e` to get `\u003csmall class=\"app_version\"\u003e4.3.6\u003c/small\u003e`\n\n#### Route\n\nVisiting `/version` will return the version...\n\n```bash\n$ curl https://localhost/version\n4.3.6-feature/some_great_thing+sha:3c40a5b0d0a07973bd117a39b53367c9ff4d4cc0.build:11425.20190220170058+0000\n```\n\n#### Commands\n\nThe following `artisan` commands are added...\n\n| Command | Description |\n| ------ | ------ |\n|  version | Display full version of the application. |\n|  version:major | Display major version of the application. |\n|  version:meta | Display meta version of the application. |\n|  version:minor | Display minor version of the application. |\n|  version:patch | Display patch version of the application. |\n|  version:pre_release | Display pre_release version of the application. |\n|  version:semver | Display semver version of the application. |\n\n## Configuration\n\nPublish the package config file to `config/version.php`:\n\n```bash\n$ php artisan vendor:publish --tag version-config\n```\n\nThis file is fully documented.  You will need to make the changes to that file to suit your needs. There are 3 main configuration items...\n\n1. `file` - Name of the file that has the version\n2. `route` - Configuration of the route to display the version\n3. `view` - Configuration of the view composer to add the version to the views\n\n## Example CI to modify version file\n\nWe use [GitLab](https://about.gitlab.com), so here is a partial example `job` that we have in our `.gitlab-ci.yml`...\n\n```yaml\nversion:\n  stage: build\n\n  image: php7.2\n\n  dependencies: []\n\n  script:\n    - echo \"\" \u003e\u003e VERSION\n    - echo \"${CI_COMMIT_REF_NAME}\" \u003e\u003e VERSION\n    - echo \"sha:${CI_COMMIT_SHA}\" \u003e\u003e VERSION\n    - echo \"build:${CI_PIPELINE_ID}\" \u003e\u003e VERSION\n    - date +\"%Y%m%d%k%M%S%z\" \u003e\u003e VERSION\n\n  artifacts:\n    name: \"${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}-version\"\n    paths:\n      - VERSION\n    expire_in: 3 days\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinen%2Flaravel-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspinen%2Flaravel-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspinen%2Flaravel-version/lists"}