- How do I install the laravel-github-contributions package?
- Install it with Composer by requiring jeffersongoncalves/laravel-github-contributions in your Laravel project. Laravel's package auto-discovery registers the service provider, so no manual registration is usually needed. Publish any provided config file if you need to customize defaults, then set your GitHub token.
- What GitHub token do I need to query the contribution calendar GraphQL API?
- You need a GitHub personal access token that can read user profile data, since the contribution calendar comes from GitHub's GraphQL API. A classic token with the read:user scope is typically sufficient for public contribution data. Store the token in your .env file and never commit it to source control.
- Which Laravel versions does this package support?
- Support depends on the package's composer.json constraints, so check the repository's requirements before installing. It is designed for modern Laravel applications using Composer and package auto-discovery. If you are on an older Laravel release, verify compatibility or pin an appropriate package version.
- How do I fetch a GitHub contribution calendar in Laravel?
- Use the package's provided facade or service to request a user's contribution data, which returns the daily contribution levels used for a heatmap. Configure your GitHub token first so the GraphQL request can authenticate. The result can then be passed to your view or API response.
- What do the 0 to 4 contribution levels mean?
- GitHub's contribution calendar returns a level from 0 to 4 for each day, representing relative contribution intensity rather than an exact count. Level 0 means no contributions, while 4 indicates the highest activity tier for that period. This makes the data directly suitable for rendering a heatmap.
- Can I show contributions for any GitHub username, not just my own account?
- Yes, the contribution calendar query is based on a GitHub login, so you can request data for any public user whose calendar is visible. Pass the desired username to the package rather than relying on the authenticated account. Private contribution counts will only appear when the token belongs to that user and privacy settings allow it.
- How do I render the contribution heatmap in a Blade view?
- Fetch the contribution levels in your controller and pass the resulting collection to your Blade view. Loop over the days and map each 0 to 4 level to a color class in your CSS to build the grid. The package supplies the data; the visual styling stays under your control.
- How can I avoid GitHub GraphQL API rate limits?
- Cache the contribution results in Laravel's cache store so you are not querying GitHub on every page load. Contribution data changes slowly, so a cache duration of several hours is usually fine. Also ensure a valid token is configured, since unauthenticated GraphQL requests have much stricter limits.
- Can I test my integration without calling the real GitHub API?
- Yes, you should fake or mock the HTTP and GraphQL responses in your test suite so tests do not depend on GitHub availability or rate limits. Laravel's HTTP client fakes make it straightforward to return canned contribution data. Then assert that your controller or component renders the expected levels.
- Are there alternatives to this package for showing GitHub activity in Laravel?
- You can call GitHub's GraphQL or REST APIs directly with Laravel's HTTP client if you only need a one-off query. Dedicated GitHub API wrapper packages also exist but may not include contribution-calendar helpers. This package is a focused option when you specifically want a ready-made 0 to 4 contribution heatmap integration.