PHP code example of ditshej / op-cards-php

1. Go to this page and download the library: Download ditshej/op-cards-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ditshej / op-cards-php example snippets


use Ditshej\OpCards\OpCardsClient;

$client = new OpCardsClient(
    token: $_ENV['OPCARDS_TOKEN'],
    baseUri: $_ENV['OPCARDS_BASE_URI'],
);

use Ditshej\OpCards\Laravel\Facades\OpCards;

$packs = OpCards::packs();

use Ditshej\OpCards\OpCardsClient;

class CardController extends Controller
{
    public function __construct(private OpCardsClient $client) {}
}

use Ditshej\OpCards\Filters\CardFilter;

// Paginated — single page
$result = $client->cards(
    (new CardFilter)
        ->color('Red')
        ->cost(3, 5, 7)      // multi-value: cost=3 OR cost=5 OR cost=7
        ->rarity('L')
        ->perPage(50)
        ->page(2)
);

$cards = $result['data']; // CardResource[]
$meta  = $result['meta']; // current_page, last_page, per_page, total

// Fetch all pages automatically
$allCards = $client->allCards(
    (new CardFilter)->color('Red')->pack('OP01')
);
bash
composer 
bash
php artisan vendor:publish --tag=opcards-config