Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Laravel 10+ #139

Merged
merged 12 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Steam API key for testing
apiKey=
XDEBUG_MODE=coverage
XDEBUG_MODE=coverage
PHP_VERSION=8.1
19 changes: 11 additions & 8 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.0', '7.4', '7.3' ]
php: [ '8.1', '8.2', '8.3' ]
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: bcmath, simplexml, libxml, curl, json
extensions: bcmath, simplexml, libxml, curl, json, sodium
coverage: pcov

- name: Mitigate Composer lock issues
run: composer update

- name: PHP ${{ matrix.php }} - Validate composer.json and composer.lock
run: composer validate

- name: PHP ${{ matrix.php }} - Cache Composer packages
id: composer-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
Expand All @@ -45,8 +48,8 @@ jobs:
run: composer run-script test

- name: Publish Test Coverage
uses: paambaati/codeclimate-action@v2.7.5
if: ${{ matrix.php }} == '8.0' && ${{ github.ref }} == 'master'
uses: paambaati/codeclimate-action@v6
if: ${{ matrix.php }} == '8.1' && ${{ github.ref }} == 'master'
env:
apiKey: ${{ secrets.STEAM_API_KEY }}
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
Expand All @@ -62,4 +65,4 @@ jobs:
status: ${{ job.status }}
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "${{ matrix.php }}: Tests failed."
color: 'red'
color: 'red'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/.idea
/vendor
/coverage
composer.phar
.DS_Store
ocular.phar
uploadTests.sh
.env
.phpunit.*
*.clover
*.clover
58 changes: 35 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
[![License](https://poser.pugx.org/syntax/steam-api/license.svg)](https://packagist.org/packages/syntax/steam-api)

**Version Support**
`Laravel >= 6.0`
`PHP >= 7.3.0`
`Laravel >= 10.0`
`PHP >= 8.1`

- [Installation](#installation)
- [Usage](#usage)
Expand All @@ -30,7 +30,7 @@ This package provides an easy way to get details from the Steam API service. Th
Begin by installing this package with composer.

"require": {
"syntax/steam-api": "2.3.*"
"syntax/steam-api": "3.*"
}

Next, update composer from the terminal.
Expand All @@ -41,10 +41,19 @@ Next, update composer from the terminal.

Lastly, publish the config file. You can get your API key from [Steam](http://steamcommunity.com/dev/apikey).

php artisan vendor:publish
php artisan vendor:publish --provider="Syntax\SteamApi\SteamApiServiceProvider"

## Usage

```php
use Syntax\SteamApi\Facades\SteamApi;

/** Get Portal 2 */
$apps = SteamApi::app()->appDetails([620]);

echo $app->first()->name;
```

Each service from the Steam API has its own methods you can use.

- [Global](#global)
Expand Down Expand Up @@ -75,7 +84,7 @@ format | string | The format you want back. | No | null
##### Example usage

```php
Steam::convertId($id, $format);
SteamApi::convertId($id, $format);
```

> Example Output: [convertId](./examples/global/convertId.txt)
Expand All @@ -84,7 +93,7 @@ Steam::convertId($id, $format);
The [Steam News](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetNewsForApp_.28v0002.29) web api is used to get articles for games.

```php
Steam::news()
SteamApi::news()
```

#### GetNewsForApp
Expand All @@ -102,7 +111,7 @@ maxlength | int | The maximum number of characters to return | No | null

```php
<?php
$news = Steam::news()->GetNewsForApp($appId, 5, 500)->newsitems;
$news = SteamApi::news()->GetNewsForApp($appId, 5, 500)->newsitems;
?>
```

Expand All @@ -114,7 +123,7 @@ The [Player Service](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetO
When instantiating the player class, you are required to pass a steamId or Steam community ID.

```php
Steam::player($steamId)
SteamApi::player($steamId)
```

#### GetSteamLevel
Expand Down Expand Up @@ -178,7 +187,7 @@ The [User](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetFriendList_
When instantiating the user class, you are required to pass at least one steamId or steam community ID.

```php
Steam::user($steamId)
SteamApi::user($steamId)
```

#### ResolveVanityURL
Expand All @@ -191,7 +200,7 @@ Name | Type | Description | Required | Default
displayName| string | The display name to get the steam ID for. In `http://steamcommunity.com/id/gabelogannewell` it would be `gabelogannewell`. | Yes | NULL

```php
$player = Steam::user($steamId)->ResolveVanityURL('gabelogannewell');
$player = SteamApi::user($steamId)->ResolveVanityURL('gabelogannewell');
```

> Example Output: [ResolveVanityURL](./examples/user/ResolveVanityURL.txt)
Expand All @@ -208,11 +217,11 @@ steamId| int[] | An array of (or singular) steam ID(s) to get details for | No
```php
// One user
$steamId = 76561197960287930;
$player = Steam::user($steamId)->GetPlayerSummaries()[0];
$player = SteamApi::user($steamId)->GetPlayerSummaries()[0];

// Several users
$steamIds = [76561197960287930, 76561197968575517]
$players = Steam::user($steamIds)->GetPlayerSummaries();
$players = SteamApi::user($steamIds)->GetPlayerSummaries();
```

> Example Output: [GetPlayerSummaries](./examples/user/GetPlayerSummaries.txt)
Expand Down Expand Up @@ -250,7 +259,7 @@ The [User Stats](https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlaye
When instantiating the user stats class, you are required to pass a steamID or Steam community ID.

```php
Steam::userStats($steamId)
SteamApi::userStats($steamId)
```

#### GetPlayerAchievements
Expand Down Expand Up @@ -306,7 +315,7 @@ appId| int | The ID of the game you want the details for. | Yes |
This area will get details for games.

```php
Steam::app()
SteamApi::app()
```

#### appDetails
Expand All @@ -332,7 +341,7 @@ This method will return an array of app objects directly from Steam. It include
This method will get details for packages.

```php
Steam::package()
SteamApi::package()
```

#### packageDetails
Expand All @@ -353,7 +362,7 @@ l | string | The l is the language parameter, you can get the appropriate langua
This method will get user inventory for item.

```php
Steam::item()
SteamApi::item()
```

#### GetPlayerItems
Expand All @@ -374,7 +383,7 @@ steamid | int | The steamid of the Steam user you want for | Yes |
This service is used to get details on a Steam group.

```php
Steam::group()
SteamApi::group()
```

#### GetGroupSummary
Expand All @@ -390,7 +399,7 @@ group| string or int | The ID or the name of the group. | Yes

```php
<?php
$news = Steam::group()->GetGroupSummary('Valve');
$news = SteamApi::group()->GetGroupSummary('Valve');
?>
```

Expand All @@ -402,20 +411,23 @@ A Steam API key must be provided or most tests will fail.

**Run Tests**
```
# Build container
docker-compose build

# Install dependancies
docker-compose run php composer install
docker-compose run --rm php composer install

# Run tests (assumes apiKey is set in .env file)
docker-compose run php composer test
docker-compose run --rm php composer test

# Or with the apiKey inline
docker-compose run -e api=YOUR_STEAM_API_KEY php composer test
docker-compose run --rm -e api=YOUR_STEAM_API_KEY php composer test

# With coverage
docker-compose run php composer coverage
docker-compose run --rm php composer coverage

# Play around
docker-compose run php bash
docker-compose run --rm php bash
```

## Contributors
Expand Down
22 changes: 12 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "syntax/steam-api",
"description": "A steam-api client for Laravel 6+",
"version": "2.3.0",
"description": "A steam-api client for Laravel 10+",
"version": "3.0.0",
"license": "MIT",
"authors": [
{
Expand All @@ -10,19 +10,20 @@
}
],
"require": {
"php": "^7.3|^8.0",
"laravel/framework": "^6.20.12|^7.30.3|^8.22.1",
"guzzlehttp/guzzle": "^7.0",
"php": "^8.1",
"laravel/framework": "^10.0|^11.0",
"guzzlehttp/guzzle": "^7.8",
"ext-bcmath": "*",
"ext-simplexml": "*",
"ext-libxml": "*",
"ext-curl": "*",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^6.0",
"vlucas/phpdotenv": "^5.2"
"phpunit/phpunit": "^10.5|^11.0",
"orchestra/testbench": "^8.0",
"vlucas/phpdotenv": "^5.6",
"rector/rector": "^1.0"
},
"autoload": {
"psr-4": {
Expand All @@ -38,7 +39,8 @@
},
"minimum-stability": "stable",
"scripts": {
"test": "vendor/bin/phpunit",
"coverage": "vendor/bin/phpunit --coverage-clover=coverage.clover"
"test": "XDEBUG_MODE=off vendor/bin/phpunit -d memory_limit=512M",
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit -d memory_limit=512M --coverage-clover=coverage.clover",
"coverage:html": "XDEBUG_MODE=coverage vendor/bin/phpunit -d memory_limit=512M --coverage-html ./coverage"
}
}
Loading