gboquizosanchez / screenscraper
Laravel wrapper for ScreenScraper API
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/gboquizosanchez/screenscraper
Requires
- php: ^8.3
- spatie/laravel-data: ^4.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- hermes/dependencies: ^1.1
- larastan/larastan: ^2.9
- orchestra/testbench: ^9.1
- pestphp/pest: ^3.5
README
ScreenScraper.org API Container for Laravel
Summary
A library that lets you get data from ScreenScraper directly in your Laravel application.
Starting 🚀
Prerequisites 📋
- Composer.
- PHP version 8.3 or higher.
Running 🛠️
Install the package via composer:
composer require gboquizosanchez/screenscraper
Establish the configuration in the .env file:
SCREENSCRAPER_BASE_URL=https://api.screenscraper.fr/api2/ SCREENSCRAPER_OUTPUT=json SCREENSCRAPER_USERNAME=your_username SCREENSCRAPER_PASSWORD=your_password SCREENSCRAPER_DTO_MAPPING=true SCREENSCRAPER_RAW_PROPERTIES=false SCREENSCRAPER_DEV_ID=xxx SCREENSCRAPER_DEV_PASSWORD=yyy SCREENSCRAPER_SOFTNAME="ScreenScraper API Client for Laravel"
You can also publish the configuration file to customize the package:
php artisan vendor:publish --provider="ScreenScraper\ScreenScraperServiceProvider"
Note: You need to have a ScreenScraper account to use the API. If you don't have one, you can request one here. And also, you need to have an account. You can get one on the register page.
Basic Usage 👷
You can use two different methods:
Using the facade
This method provides directly from .env file the username and the web API key.
use ScreenScraper\ScreenScraperClient; ScreenScraperClient::getGame(gameId: 1);
Using the ScreenScraper model directly
You can provide a custom username and password if you want to use different credentials.
Or, you can use the default ones from the .env using config('screenscraper.credentials').
use ScreenScraper\Data\AuthData; use ScreenScraper\Models\ScreenScraper; $auth = new AuthData( devId: developer_identifier, devPassword: developer_password, softname: software_name, output: json or xml, ssid: user_identifier, sspassword: user_password, ); $client = new ScreenScraper($auth); $client->getGame(gameId: 1);
Mapping the response 🗺️
There are two ways to map the response. By default, the package uses the DTO mapping.
SCREENSCRAPER_DTO_MAPPING=true SCREENSCRAPER_MAPPING=false
Note: If you want to use the raw mapping, you need to set the SCREENSCRAPER_DTO_MAPPING to false and the SCREENSCRAPER_RAW_MAPPING to true. RAW only works with DTO mapping disabled.
Available methods 📚
This package provides all methods available in the ScreenScraper API.
See the ScreenScraperClient facade for more information.
Working with ⚙️
PHP dependencies 📦
Develop dependencies 🔧
Testing ✅
composer test
Problems? 🚨
Let me know about yours by opening an issue!
Credits 🧑💻
License 📄
MIT License (MIT). See License File.