# Versioning your Laravel Project

![A possible format of a version string showing in the footer](https://1927469528-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAjqOQ_2PfydngAA_RX%2F-ML2eY5z7EYwTc2rQmGM%2F-MLD5mR9K6b-FaqtAZ_f%2FScreenshot%202020-11-03%20at%2012.32.42.png?alt=media\&token=73b191da-38a8-43f4-924b-55572e8bcf67)

Using Git for version control, we can tag releases and then pull that tag information into our project so that it can be displayed to users.  This can be helpful where you have multiple deployments of the same code base and need to be sure which version a site is running.

### Create a version.php config file

{% code title="/config/version.php" %}

```php
<?php

    $tag  = exec('git describe --tags --abbrev=0');
    
    if(empty($tag)) {
        $tag = '-.-.-';
    }

    $hash = trim(exec('git log --pretty="%h" -n1 HEAD'));
    $date = Carbon\Carbon::parse(trim(exec('git log -n1 --pretty=%ci HEAD')));

return [

    'tag' => $tag,
    'date' => $date,
    'hash' => $hash,
    'string' => sprintf('%s-%s (%s)',$tag, $hash, $date->format('d/m/y H:i')),
    
];

```

{% endcode %}

The above gives our config a `version` element that we can then include within views, emails, support logs etc.

The config elements are accessed as `{{config('version.string')}}` for example.  Caching config avoids the exec functions being called on every request for the version information.

### Tagging releases

Using the github Desktop client, right click the commit and add the tag.

![](https://1927469528-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAjqOQ_2PfydngAA_RX%2F-ML2eY5z7EYwTc2rQmGM%2F-MLD7tE-AjYwfsad06KS%2Fimage.png?alt=media\&token=45f3fa57-d0d8-4b7d-8d14-6b61e40d988b)

Using github on the web;&#x20;

![](https://1927469528-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAjqOQ_2PfydngAA_RX%2F-ML2eY5z7EYwTc2rQmGM%2F-MLD9AMLwqAItdRVG0np%2FScreenshot%202020-11-03%20at%2012.47.54.png?alt=media\&token=c0b19f7b-8d0a-4341-8422-12d180e1c5d1)

Using Bitbucket.  In the Commits view, click on the latest commit and select tag from the sidebar;

![](https://1927469528-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAjqOQ_2PfydngAA_RX%2F-ML2eY5z7EYwTc2rQmGM%2F-MLDAVyMttOmqX3TjQZl%2FScreenshot%202020-11-03%20at%2012.54.54.png?alt=media\&token=ba7b267d-eb40-4e51-901c-19f99d792fe3)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://talltips.novate.co.uk/laravel/versioning-your-laravel-project.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
