PHP code example of spiriitlabs / commit-history-bundle

1. Go to this page and download the library: Download spiriitlabs/commit-history-bundle 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/ */

    

spiriitlabs / commit-history-bundle example snippets




return [
    // ...
    Spiriit\Bundle\CommitHistoryBundle\SpiriitCommitHistoryBundle::class => ['all' => true],
];



namespace App\Controller;

use Spiriit\CommitHistory\Service\FeedFetcherInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class MyController extends AbstractController
{
    public function changelog(Request $request, FeedFetcherInterface $feedFetcher): Response
    {
        // Get year from query parameter, defaults to current year
        $year = $request->query->getInt('year') ?: (int) date('Y');

        $commits = $feedFetcher->fetch($year);
        $availableYears = $feedFetcher->getAvailableYears();

        return $this->render('changelog.html.twig', [
            'commits' => $commits,
            'available_years' => $availableYears,
            'selected_year' => $year,
        ]);
    }
}



namespace App\Service\DiffParser;

use Spiriit\CommitHistory\DTO\DependencyChange;
use Spiriit\CommitHistory\DiffParser\DiffParserInterface;

class GemfileDiffParser implements DiffParserInterface
{
    public function supports(string $filename): bool
    {
        return basename($filename) === 'Gemfile.lock';
    }

    /**
     * @return DependencyChange[]
     */
    public function parse(string $diff, string $filename): array
    {
        // Parse the diff and return DependencyChange objects
        $changes = [];
        // ... your parsing logic
        return $changes;
    }
}
yaml
spiriit_commit_history:
    resource: '@SpiriitCommitHistoryBundle/Resources/config/routes.php'
    type: php
    prefix: /commits    # Customize the URL path here