承接 ethelserth/biblionet-laravel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ethelserth/biblionet-laravel

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ethelserth/biblionet-laravel

包简介

Laravel integration for the Biblionet Greek books API client

README 文档

README

Laravel integration for ethelserth/biblionet-php, the PHP client for the Biblionet Greek books API.

This package provides a service provider, config publishing, and a facade so the Biblionet client works as a native Laravel citizen.

Requirements

  • PHP 8.1 or higher
  • Laravel 10, 11, 12, or 13
  • Biblionet API credentials (request access at biblionet.gr)

Installation

composer require ethelserth/biblionet-laravel

Laravel's package auto-discovery will register the service provider and facade automatically.

Publish the config file:

php artisan vendor:publish --tag=biblionet-config

Add your credentials to .env:

BIBLIONET_USERNAME=your-username
BIBLIONET_PASSWORD=your-password

Usage

Via dependency injection (recommended)

use Ethelserth\Biblionet\BiblionetClient;

class BookController extends Controller
{
    public function __construct(
        private readonly BiblionetClient $biblionet,
    ) {}

    public function show(int $id): JsonResponse
    {
        $title = $this->biblionet->getTitle($id);

        return response()->json($title);
    }
}

Via facade

use Ethelserth\BiblionetLaravel\Facades\Biblionet;

$title       = Biblionet::getTitle(72584);
$summaries   = Biblionet::getMonthTitles(2024, 1);
$contributors = Biblionet::getContributors(72584);

Via the container

$client = app(BiblionetClient::class);
$title  = $client->getTitle(72584);

Configuration

After publishing, config/biblionet.php exposes:

Key Env variable Default Description
username BIBLIONET_USERNAME '' Your Biblionet username
password BIBLIONET_PASSWORD '' Your Biblionet password
timeout BIBLIONET_TIMEOUT 30 HTTP timeout in seconds

Credentials are validated lazily — the application boots normally even if they are not set. The exception fires only when something first tries to resolve the client from the container.

Swapping the HTTP client

By default the package uses Guzzle as its PSR-18 HTTP client. If you have already bound Psr\Http\Client\ClientInterface in your application's service container, the package will use that instead:

// In your own AppServiceProvider
$this->app->bind(ClientInterface::class, fn() => new YourPreferredClient());
$this->app->bind(RequestFactoryInterface::class, fn() => new YourFactory());
$this->app->bind(StreamFactoryInterface::class, fn() => new YourFactory());

Testing

When testing code that uses the Biblionet client, mock BiblionetClient directly rather than faking HTTP:

use Ethelserth\Biblionet\BiblionetClient;
use Ethelserth\Biblionet\DTOs\Title;

$this->mock(BiblionetClient::class)
    ->shouldReceive('getTitle')
    ->with(72584)
    ->andReturn(new Title(...));

License

MIT. See LICENSE.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固