PHP code example of fissible / drift

1. Go to this page and download the library: Download fissible/drift 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/ */

    

fissible / drift example snippets


// Registered automatically by DriftServiceProvider
use Fissible\Drift\Drivers\Laravel\Inspectors\LaravelRouteInspector;

$this->app->singleton(RouteInspectorInterface::class, function () {
    return new LaravelRouteInspector(
        router: $this->app['router'],
        filter: fn($route) => str_starts_with($route->uri, 'api/'),
    );
});

use Fissible\Drift\DriftDetector;
use Fissible\Accord\FileSpecSource;

$source   = new FileSpecSource('/var/www/app');
$detector = new DriftDetector($source);
$report   = $detector->detect($routes, 'v1');

$report->isClean();            // true if no drift
$report->hasBreakingChanges(); // true if routes were removed
$report->hasAdditiveChanges(); // true if routes were added
$report->summary();            // human-readable string

use Fissible\Drift\VersionAnalyser;

$analyser       = new VersionAnalyser($source);
$recommendation = $analyser->analyse($report);

$recommendation->bumpType;             // 'major' | 'minor' | 'patch' | 'none'
$recommendation->recommendedVersion;   // '1.2.0'
$recommendation->

use Fissible\Drift\ChangelogGenerator;

$generator = new ChangelogGenerator();
$entry     = $generator->generate($report, $recommendation);

// Prepend the entry to CHANGELOG.md (creates the file if missing)
$generator->prepend($entry, base_path('CHANGELOG.md'));

use Fissible\Drift\RouteInspectorInterface;
use Fissible\Drift\RouteDefinition;

class MyFrameworkInspector implements RouteInspectorInterface
{
    public function getRoutes(): array
    {
        return array_map(
            fn($route) => new RouteDefinition($route->method, $route->path),
            $this->router->getRoutes(),
        );
    }
}
bash
php artisan accord:validate
php artisan accord:version
php artisan drift:coverage
bash
php artisan accord:validate
php artisan accord:validate --api-version=v2
bash
php artisan accord:version
php artisan accord:version --api-version=v1 --dry-run
php artisan accord:version --yes          # skip confirmation prompt
bash
php artisan drift:coverage
php artisan drift:coverage --api-version=v1