video-games-records / igdb-bundle
VideoGamesRecords IgdbBundle
Installs: 1
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/video-games-records/igdb-bundle
Requires
- php: ^8.4
- ext-gd: *
- doctrine/doctrine-bundle: ~2.0
- doctrine/orm: ^3.3
- kris-kuiper/igdbv4: ^1.1
- symfony/config: ^7.2
- symfony/console: ^7.2
- symfony/dependency-injection: ^7.2
- symfony/dotenv: ^7.2
- symfony/flex: ^2
- symfony/framework-bundle: ^7.2
- symfony/http-kernel: ^7.2
- symfony/lock: ^7.2
- symfony/messenger: ^7.2
- symfony/runtime: ^7.2
- symfony/scheduler: ^7.2
- symfony/twig-bundle: ^7.2
- symfony/validator: ^7.2
- symfony/yaml: ^7.2
- webmozart/assert: *
Requires (Dev)
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^2.1
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-symfony: ^2.0
- squizlabs/php_codesniffer: ^3.7
- symfony/browser-kit: ^7.2
- symfony/http-client: ^7.2
- symfony/phpunit-bridge: ^7.0
- symfony/web-profiler-bundle: ^7.2
Suggests
- jms/serializer-bundle: For API serialization support
- sonata-project/admin-bundle: For admin interfaces (^4.0)
- sonata-project/doctrine-orm-admin-bundle: For Doctrine ORM admin support (^4.8)
README
A Symfony bundle that provides IGDB (Internet Game Database) integration for the VideoGamesRecords application. This bundle facilitates data retrieval from the IGDB APIs using the kris-kuiper/igdbv4 package and provides Sonata Admin interfaces for managing IGDB data.
Features
- 🎮 IGDB API Integration using kris-kuiper/igdbv4 package
- 🏗️ Symfony 7.2+ Compatibility with modern PHP 8.4+
- 🔧 Auto-configured Services with dependency injection
- 📊 Sonata Admin Interfaces for all IGDB entities (read-only)
- 🌍 Multi-language Support (French/English) with complete translations
- 🛡️ Security-first Approach with read-only admin interfaces
- 📝 JMS Serializer Configuration for API responses
- ⚡ Command-line Tools for data import from IGDB
- 🎨 Custom Twig Templates for enhanced admin display
Requirements
- PHP: 8.4+
- Symfony: 7.2+
- Doctrine ORM: 3.3+
- Sonata Admin Bundle: For admin interfaces (optional)
- JMS Serializer Bundle: For API serialization
Installation
Install the bundle via Composer:
composer require video-games-records/igdb-bundle
Add the bundle to your config/bundles.php
:
return [ // ... VideoGamesRecords\IgdbBundle\VideoGamesRecordsIgdbBundle::class => ['all' => true], ];
Configuration
Configure your IGDB API credentials in config/packages/video_games_records_igdb.yaml
:
video_games_records_igdb: client_id: '%env(IGDB_CLIENT_ID)%' client_secret: '%env(IGDB_CLIENT_SECRET)%'
Add your credentials to .env
:
IGDB_CLIENT_ID=your_client_id IGDB_CLIENT_SECRET=your_client_secret
Entities
The bundle provides the following IGDB entities:
🎮 Game
- Complete game information from IGDB
- Relations to genres and platforms
- Release date management
- Version parent relationships
🏷️ Genre
- Game genre classifications
- Slug and URL management
🖥️ Platform
- Gaming platform information
- Generation and abbreviation data
- Relations to platform types and logos
🔧 PlatformType
- Platform type classifications
- Console, PC, Mobile, etc.
🖼️ PlatformLogo
- Platform logo images
- Dimensions and image metadata
- URL generation for different sizes
Contracts
GameInfoInterface
The bundle provides a GameInfoInterface
contract that defines the essential methods for game information:
interface GameInfoInterface { public function getName(): string; public function getSlug(): string; public function getGenres(): Collection; public function getReleaseDate(): ?DateTime; public function getSummary(): ?string; public function getStoryline(): ?string; public function getUrl(): ?string; }
This interface can be implemented by other game entities in your application to ensure consistency across different game data sources (IGDB, manual entries, etc.).
Linking to IGDB Games
To create a relationship between your custom game entities and IGDB games, add a ManyToOne relation in your entity:
use VideoGamesRecords\IgdbBundle\Entity\Game as IgdbGame; class YourGameEntity implements GameInfoInterface { #[ORM\ManyToOne(targetEntity: IgdbGame::class)] #[ORM\JoinColumn(name: 'igdb_game_id', referencedColumnName: 'id', nullable: true)] private ?IgdbGame $igdbGame = null; public function getIgdbGame(): ?IgdbGame { return $this->igdbGame; } public function setIgdbGame(?IgdbGame $igdbGame): self { $this->igdbGame = $igdbGame; return $this; } // Implement GameInfoInterface methods... } ## Available Commands ### Data Import Commands Import data from IGDB API: ```bash # Search and import games php bin/console app:search-and-import-games # Import genres php bin/console app:import-genres # Import platforms php bin/console app:import-platforms # Import platform types php bin/console app:import-platform-types # Import platform logos php bin/console app:import-platform-logos
Development Commands
Installation and Setup
composer install # Install dependencies composer update # Update dependencies
Testing
./vendor/bin/simple-phpunit # Run PHPUnit tests make test # Run tests (via Makefile)
Code Quality
make phpstan # Run PHPStan static analysis (level 5) make phpcs # Run PHP CodeSniffer (PSR-12 standard) make phpcs-fix # Auto-fix PHP CodeSniffer issues make lint # Run all linting tools
Admin Interfaces (Optional)
The bundle provides read-only Sonata Admin interfaces for all entities if Sonata Admin Bundle is installed:
- Games Admin:
/admin/igdb/game/list
- Genres Admin:
/admin/igdb/genre/list
- Platforms Admin:
/admin/igdb/platform/list
- Platform Types Admin:
/admin/igdb/platform-type/list
- Platform Logos Admin:
/admin/igdb/platform-logo/list
Security Features
- ✅ Read-only interfaces - No create/edit/delete actions
- ✅ Route-level protection - Dangerous routes are removed
- ✅ Data integrity - IGDB data cannot be modified
- ✅ Comprehensive filtering - Advanced search capabilities
Translations
Admin interfaces support multiple languages:
- 🇫🇷 French (
fr
) - 🇬🇧 English (
en
)
All labels, filters, and messages are fully translated.
Installation with Admin Support
To enable admin interfaces, install Sonata Admin Bundle:
composer require sonata-project/admin-bundle composer require sonata-project/doctrine-orm-admin-bundle
The admin interfaces will be automatically available once Sonata Admin is installed and configured.
API Serialization
The bundle includes JMS Serializer configuration for API responses:
Serialization Groups
Each entity has specific serialization groups:
igdb-game:read
- Game dataigdb-genre:read
- Genre dataigdb-platform:read
- Platform dataigdb-platform-type:read
- Platform type dataigdb-platform-logo:read
- Platform logo data
Usage Example
use JMS\Serializer\SerializerInterface; class GameController { public function getGame(Game $game, SerializerInterface $serializer): JsonResponse { $json = $serializer->serialize($game, 'json', [ 'groups' => ['igdb-game:read'] ]); return new JsonResponse($json, 200, [], true); } }
Architecture
Bundle Structure
src/
├── Admin/ # Sonata Admin classes
├── Client/ # IGDB API client
├── Command/ # Console commands
├── Contract/ # Interfaces
├── DependencyInjection/ # Service configuration
├── Endpoint/ # API endpoints
├── Entity/ # Doctrine entities
├── Repository/ # Doctrine repositories
└── Resources/
├── serialization/ # JMS Serializer config
├── translations/ # Multi-language support
└── views/ # Custom Twig templates
Service Configuration
- Auto-wired services via
config/services.yml
- Auto-discovery of services in
src/
directory - PSR-4 autoloading with namespace
VideoGamesRecords\IgdbBundle\
- Automatic Twig namespace registration for templates
Code Standards
- PHP Version: 8.4+
- Code Style: PSR-12 (enforced via phpcs.xml)
- Static Analysis: PHPStan level 5
- Framework: Symfony 7.2+
- Documentation: PHPDoc annotations
Development
Adding New Entities
- Create the entity in
src/Entity/
- Add the admin class in
src/Admin/
- Configure the admin service in
config/admin.yml
- Add serialization config in
src/Resources/serialization/
- Add translations in
src/Resources/translations/
Custom Templates
Custom Twig templates are available in src/Resources/views/Admin/
:
list_unix_timestamp.html.twig
- For Unix timestamp displayshow_unix_timestamp.html.twig
- For detailed Unix timestamp displayshow_collection.html.twig
- For entity collections display
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Follow PSR-12 coding standards
- Add tests for new functionality
- Run the test suite (
make test
) - Run code quality tools (
make lint
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This bundle is part of the VideoGamesRecords project.
Support
For issues and questions:
- Create an issue in the project repository
- Check the VideoGamesRecords documentation
- Review IGDB API documentation
Made with ❤️ for the VideoGamesRecords community