PHP code example of gaiththewolf / git-manager

1. Go to this page and download the library: Download gaiththewolf/git-manager library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gaiththewolf / git-manager example snippets



namespace App\Http\Controllers;

use GitManager;

class UpdaterController extends Controller
{

    public function __construct()
    {
        // init and set git working directory
        GitManager::init(base_path());
    }

    public function index()
    {
        $version = GitManager::version(); // get string of installed git version
        $version = trim(str_replace("git version", "",$version));

        $lastUpdate = trim(GitManager::lastUpdate()); // get string of last update datetime

        $status = GitManager::status(); // get Object git status }

Gaiththewolf\GitManager\Data\GitStatus {#1512 ▼ // app\Http\Controllers\UpdaterController.php:37
  +branch: "main"
  +isUpToDate: true
  +isPush: false
  +isPull: false
}

Illuminate\Support\Collection {#1512 ▼ // app\Http\Controllers\UpdaterController.php:37
  #items: array:4 [▶
    0 => Gaiththewolf\GitManager\Data\GitLog {#763 ▶
      +hash: "1c1efa505bb1c15f6bc40747f3d73"
      +merge: array:2 [▶
        0 => "d0f83"
        1 => "5f047"
      ]
      +author: array:2 [▶
        "full_name" => "User 1"
        "email" => "[email protected]"
      ]
      +date: "Tue Jun 13 14:30:35 2023 +0100"
      +message: "Merge branch 'main' of github.com:gaiththewolf/projectXXX"
    }
    1 => Gaiththewolf\GitManager\Data\GitLog {#778 ▶
      +hash: "d0f6283eebb28d4fbc9231d3e4d6e2720cd9"
      +merge: []
      +author: array:2 [▶
        "full_name" => "User 1"
        "email" => "[email protected]"
      ]
      +date: "Tue Jun 13 14:30:27 2023 +0100"
      +message: "fix"
    }
    2 => Gaiththewolf\GitManager\Data\GitLog {#1579 ▶
      +hash: "5f23047507e41a429ca2a7adadcfd127"
      +merge: []
      +author: array:2 [▶
        "full_name" => "User 2"
        "email" => "[email protected]"
      ]
      +date: "Tue Jun 13 14:29:50 2023 +0100"
      +message: "Update README.md"
    }
    3 => Gaiththewolf\GitManager\Data\GitLog {#780 ▶
      +hash: "5160f64d7ad207322cde61bd965c2ad3a"
      +merge: []
      +author: array:2 [▶
        "full_name" => "User 1"
        "email" => "[email protected]"
      ]
      +date: "Tue Jun 13 14:07:35 2023 +0100"
      +message: "Update README.md"
    }
  ]
  #escapeWhenCastingToString: false
}

Gaiththewolf\GitManager\Data\GitPull {#1512 ▼ // app\Http\Controllers\UpdaterController.php:37
  +files: array:1 [▶
    0 => " README.md"
  ]
  +isUpToDate: false
  +changed: "1"
  +insertion: "2"
  +deletion: "0"
}