artistan/git-info

automatic env configurations dependent on git branch (non-production) or tag (production)

2.0.1 2018-07-19 14:35 UTC

This package is not auto-updated.

Last update: 2021-11-27 14:29:46 UTC


README

Packagist Packagist Coverage Status Build Status

Artistan/git-info assists with dynamic environment configurations based on your git branch or tag.

git-info will create a config that you can use to link to dynamic places such as versioned cdn repository folders.

Works well as a simple Php object or as a package for Laravel 5.6.

composer

    "require": {
        "artistan/git-info": "*"
    }

cli install

composer require artistan/git-info 
php artisan vendor:publish --provider=artistan/git-info 

Example Laravel

./app/Providers/AppServiceProvider.php

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        /**
         * last-cached will be null if not cached...
         */
        if (is_null(config('cdn.last-cached'))) {
            config([
                'cdn.last-cached' => microtime(true),
                /**
                 * This will set my path dynamically based on the tag/branch
                 */
                'cdn.path' => config('git-info.path'),
                'cdn.url' => config('cdn.uri').config('git-info.path')
            ]);
        }
        /**
         * now I can use config('cdn.url') to route to my current versioned content on my cdn
         */
    }

Example Php

require '../vendor/autoload.php';

$git = new Artistan\GitInfo\GitInfoEnv();

// build all dynamic with
var_dump($git->getConfigs('/path/[REPO]/[BRANCH]/[TAG]'))

// or dig into all the options...
var_dump($git->getShortHash());
var_dump($git->getVersion());
var_dump($git->getDate());
var_dump($git->getApplicationVersionString());
var_dump($repo = $git->getRepo());
var_dump($branch = $git->getBranch());
var_dump($tag = $git->getLatestTag());
// null coalesce allows $tag to failover to $branch if it is null
var_dump($path = $git->buildPath($repo,$branch,$tag??$branch,null));

will end up with /path/branchName or /path/{v#.#.#}

Documentation Updates

PHP-Markdown-Documentation-Generator

./vendor/bin/phpdoc-md generate --ignore=test,examples src > api.md