GitHub integration for TomatoPHP CMS that automatically imports and synchronizes GitHub repository documentation (README files) as posts in your CMS. Perfect for maintaining documentation sites, portfolio showcases, or open-source project listings.
- 🚀 Automatic Import - Import GitHub repositories with a single click
- đź“„ README Sync - Automatically fetches and converts README.md to post content
- 📊 GitHub Stats - Imports stars, forks, watchers, and issue counts
- 📦 Packagist Integration - Fetches download statistics for PHP packages
- 🔄 Bulk Refresh - Update all imported repositories at once
- 🎨 Avatar Images - Automatically downloads repository owner avatars
- 🏷️ Auto Tagging - Extracts keywords from Packagist data
- ⚡ Queue Support - Background processing for better performance
- đź”” Notifications - User notifications on import success/failure
- đź§Ş Full Test Coverage - 39 comprehensive tests
Install the package via composer:
composer require tomatophp/filament-cms-githubRun the installation command:
php artisan filament-cms-github:installRegister the plugin in your Filament panel provider (/app/Providers/Filament/AdminPanelProvider.php):
use TomatoPHP\FilamentCmsGithub\FilamentCmsGithubPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugin(FilamentCmsGithubPlugin::make());
}- PHP 8.2 or higher
- Laravel 10.x or 11.x
- Filament 3.x
- TomatoPHP CMS 4.x
This package dispatches jobs to the queue for better performance. Make sure your queue is configured:
# Run queue worker
php artisan queue:workImported repositories are saved as posts with type open-source. You can customize this in your CMS configuration.
- Navigate to your CMS Posts page in Filament
- Click the "Github Import" action button
- Enter repository URL(s) and redirect path(s)
- Click submit
Example:
URL: https://github.com/tomatophp/filament-cms
Redirect: /posts
You can import multiple repositories at once:
URL | Redirect URL
-------------------------------------------- | ------------
https://github.com/tomatophp/filament-cms | /cms
https://github.com/tomatophp/filament-alerts| /alerts
https://github.com/tomatophp/filament-users | /users
To update all previously imported repositories with latest data:
- Use the "Refresh Github Links" action
- All posts with
type = 'open-source'and ameta_urlwill be updated
use TomatoPHP\FilamentCmsGithub\Services\GitHubService;
$service = app(GitHubService::class);
$post = $service->importRepository(
url: 'https://github.com/tomatophp/filament-cms',
userId: auth()->id(),
userType: get_class(auth()->user())
);use TomatoPHP\FilamentCmsGithub\Services\GitHubService;
use TomatoPHP\FilamentCms\Models\Post;
$service = app(GitHubService::class);
$post = Post::find(1);
$success = $service->refreshPost($post);use TomatoPHP\FilamentCmsGithub\Services\GitHubService;
$service = app(GitHubService::class);
$count = $service->refreshAllPosts(); // Returns number of posts refreshedThe main service class for GitHub operations.
Extracts repository name from GitHub URL.
$repo = $service->extractRepoFromUrl('https://github.com/tomatophp/filament-cms');
// Returns: 'tomatophp/filament-cms'Fetches repository data from GitHub API.
$data = $service->fetchRepoData('tomatophp/filament-cms');
// Returns array with: id, name, full_name, description, stargazers_count, etc.Fetches README content from repository.
$readme = $service->fetchReadme('tomatophp/filament-cms', 'master');
// Returns: markdown content as stringFetches package data from Packagist.
$data = $service->fetchPackagistData('tomatophp/filament-cms');
// Returns array with downloads, versions, keywords, etc.Imports a complete repository as a post.
$post = $service->importRepository(
url: 'https://github.com/tomatophp/filament-cms',
userId: 1,
userType: 'App\\Models\\User'
);Refreshes an existing post with latest GitHub data.
$success = $service->refreshPost($post);Refreshes all posts of type 'open-source' with meta_url.
$count = $service->refreshAllPosts();Provides a Filament action for importing repositories.
use TomatoPHP\FilamentCmsGithub\Filament\Actions\GithubImportAction;
// In your resource
protected function getHeaderActions(): array
{
return [
GithubImportAction::make(),
];
}Provides a Filament action for refreshing all repositories.
use TomatoPHP\FilamentCmsGithub\Filament\Actions\GithubRefreshAction;
protected function getHeaderActions(): array
{
return [
GithubRefreshAction::make(),
];
}Imported repositories are saved with the following structure:
[
'title' => ['en' => 'Repository Name', 'ar' => 'Repository Name'],
'slug' => 'repository-name',
'body' => ['en' => '# README content...', 'ar' => '# README content...'],
'short_description' => ['en' => 'Description', 'ar' => 'Description'],
'keywords' => ['en' => 'keyword1,keyword2', 'ar' => 'keyword1,keyword2'],
'type' => 'open-source',
'meta_url' => 'https://github.com/owner/repo',
'is_published' => true,
'published_at' => now(),
]GitHub statistics are stored as meta fields:
github_starts- Star countgithub_watchers- Watcher countgithub_language- Primary languagegithub_forks- Fork countgithub_open_issues- Open issue countgithub_default_branch- Default branch namegithub_docs- Homepage/documentation URLdownloads_total- Total Packagist downloads (if available)downloads_monthly- Monthly downloadsdownloads_daily- Daily downloads
$post = Post::find(1);
// Get star count
$stars = $post->meta('github_starts');
// Get total downloads
$downloads = $post->meta('downloads_total');Handles importing a single repository in the background.
use TomatoPHP\FilamentCmsGithub\Jobs\GitHubMetaGetterJob;
dispatch(new GitHubMetaGetterJob(
url: 'https://github.com/tomatophp/filament-cms',
redirect: '/posts',
userId: auth()->id(),
userType: get_class(auth()->user()),
panel: 'admin'
));Handles refreshing all repositories in the background.
use TomatoPHP\FilamentCmsGithub\Jobs\GitHubMetaRefreshJob;
dispatch(new GitHubMetaRefreshJob);The package dispatches the following events:
TomatoPHP\FilamentCms\Events\PostCreated- When a repository is importedTomatoPHP\FilamentCms\Events\PostUpdated- When a repository is refreshed
Users receive notifications for:
- Import Success - Repository imported successfully with link to view post
- Import Failure - Repository import failed with error details
- Refresh Success - All repositories refreshed successfully
The package includes comprehensive test coverage:
# Run tests
composer test
# Run tests with coverage
composer test-coverage
# Run static analysis
composer analyse
# Format code
composer format- GitHubServiceTest (17 tests) - Tests all service methods
- GitHubActionsTest (13 tests) - Tests Filament actions
- GitHubJobsTest (7 tests) - Tests job execution
- PluginTest (1 test) - Tests plugin registration
php artisan vendor:publish --tag="filament-cms-github-config"php artisan vendor:publish --tag="filament-cms-github-views"php artisan vendor:publish --tag="filament-cms-github-lang"php artisan vendor:publish --tag="filament-cms-github-migrations"Make sure your queue worker is running:
php artisan queue:workFor development, you can use sync driver in .env:
QUEUE_CONNECTION=syncGitHub API has rate limits. For authenticated requests (recommended), generate a personal access token and configure it in your application.
The package tries multiple branch names automatically:
mainmaster- Default branch from GitHub API
If README is not found, the post will be created with empty body content.
You can listen to the PostCreated event to perform custom processing:
use TomatoPHP\FilamentCms\Events\PostCreated;
use Illuminate\Support\Facades\Event;
Event::listen(PostCreated::class, function ($event) {
$post = $event->model;
// Custom processing here
if ($post->type === 'open-source') {
// Do something with imported repository
}
});use Illuminate\Support\Facades\Notification;
use TomatoPHP\FilamentCmsGithub\Jobs\GitHubMetaGetterJob;
class CustomNotificationHandler
{
public function handle(GitHubMetaGetterJob $job)
{
// Custom notification logic
}
}We welcome contributions! Please see CONTRIBUTING.md for details.
# Clone the repository
git clone https://github.com/tomatophp/filament-cms-github.git
# Install dependencies
composer install
# Run tests
composer testif you like to run PEST testing just use this command
composer testif you like to fix the code style, just use this command
composer formatif you like to check the code by PHPStan just use this command
composer analyseCheck out our Awesome TomatoPHP

