PHP code example of jeffersongoncalves / laravel-zero-git

1. Go to this page and download the library: Download jeffersongoncalves/laravel-zero-git 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/ */

    

jeffersongoncalves / laravel-zero-git example snippets


use JeffersonGoncalves\LaravelZero\Git\GitRemoteParser;

$info = GitRemoteParser::parse('[email protected]:acme/widgets.git');

$info->host;       // "github.com"
$info->owner;      // "acme"
$info->repo;       // "widgets"
$info->fullName(); // "acme/widgets"

GitRemoteParser::parse('not a url'); // null

GitRemoteParser::slug('[email protected]:Acme/Widgets.git'); // "acme-widgets"

use JeffersonGoncalves\LaravelZero\Git\RepositoryResolver;

$resolver = new RepositoryResolver(); // current working directory
$info = $resolver->resolve();         // RemoteInfo|null (reads `origin`)

$resolver->resolve('upstream');       // a different remote
$resolver->currentRemoteUrl();        // the raw URL string, or null

// Point it at a specific directory:
$resolver = new RepositoryResolver('/path/to/repo');