Download the PHP package ditshej/op-cards-php without Composer

On this page you can find all versions of the php package ditshej/op-cards-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package op-cards-php

op-cards-php

CI Packagist Version

PHP client library for one-piece-cards-api — a self-hostable HTTP API serving One Piece TCG card data. Use this package to talk to your own instance of that API from any PHP application. Framework-agnostic core with optional Laravel integration.


How it works

This SDK does not call any shared or public service. You bring your own backend:

  1. Install and host one-piece-cards-api on a server you control. It exposes the HTTP endpoints (/packs, /cards, …) and issues bearer tokens.
  2. Install this package in your PHP project and point it at your instance's base URL and token.

Note: op-cards.ditshej.ch is the maintainer's private instance and is not a public API. Replace it with your own host in the examples below.


Installation

Requires PHP 8.4+ and guzzlehttp/guzzle.


Configuration

The client requires two values:

Variable Description
OPCARDS_TOKEN Bearer token issued by your API instance
OPCARDS_BASE_URI Base URL of your API instance, e.g. https://op-cards.ditshej.ch/api/v1/ (maintainer's instance — replace with yours)

Standalone usage


Laravel integration

The package supports auto-discovery. Once installed, the OpCardsServiceProvider is registered automatically.

Add the credentials to your .env:

Optionally publish the config file:

This creates config/opcards.php where you can override the values.

Use the Facade anywhere in your Laravel app:

Or inject OpCardsClient directly:


Available methods

Method Returns Description
packs() PackResource[] All available card packs
pack(string $id) PackResource Single pack by ID
cards(?CardFilter $filter) array{data: CardResource[], meta: array} Paginated card list, optionally filtered
card(string $id) CardResource Single card by ID
allCards(?CardFilter $filter) CardResource[] All cards across all pages, flat array

Filtering cards

CardFilter is a fluent builder for the cards() and allCards() endpoints:

All filter methods

Method Description
color(string $value) Card color (e.g. 'Red', 'Blue')
category(string $value) Card category (e.g. 'Character', 'Event')
cost(int ...$values) Exact cost — single value or multiple
costBetween(int $min, int $max) Cost range (inclusive)
powerBetween(int $min, int $max) Power range (inclusive)
rarity(string $value) Rarity (e.g. 'L', 'R', 'C')
attribute(string $value) Attribute (e.g. 'Strike', 'Slash')
type(string $value) Card type / crew name
keyword(string $value) Keyword ability
pack(string $id) Filter by pack ID
cardSet(string $value) Filter by card set (e.g. 'OP-01')
search(string $query) Full-text search
altArt(bool $value) Include/exclude alternate art variants
perPage(int $value) Results per page
page(int $value) Page number

Error handling

All API errors throw exceptions that extend Ditshej\OpCards\Exceptions\ApiException:

Exception HTTP status
AuthenticationException 401
NotFoundException 404
RateLimitException 429
ApiException all other errors

All exceptions expose getStatusCode(): int in addition to the standard getMessage() and getCode().


All versions of op-cards-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ditshej/op-cards-php contains the following files

Loading the files please wait ...