spits-online/laravel-openprovider-api
最新稳定版本:1.0.1
Composer 安装命令:
composer require spits-online/laravel-openprovider-api
包简介
This is my package laravel-openprovider-api
README 文档
README
Overview
The Laravel Openprovider package simplifies integrating the powerful Openprovider API into your Laravel applications. It provides a user-friendly way to manage Domains and DNS Zone records. This package is designed to make communication between Laravel and Openprovider seamless and efficient.
Installation
Prerequisites
Before installing this package, ensure your system meets the following requirements:
- PHP: Version
^8.3 - Laravel: Version
^11.0,^12.0 - Openprovider Account
Step-by-Step Installation
- Add the package to your Laravel project using Composer:
composer require spits-online/laravel-openprovider-api
- Once installed, the package will automatically register the
LarvelOpenproviderApiServiceProviderusing Laravel's package auto-discovery. - Run the following command to publish the package configuration:
php artisan vendor:publish --tag="laravel-openprovider-api-config"This will create aconfig/openprovider-api.phpfile in your application.
Configuration
OPENPROVIDER_USERNAME="{{username}}" OPENPROVIDER_PASSWORD="{{password}}"
The config/openprovider-api.php file contains all configurable options, including:
-
Openprovider base URL: the API URL for openprovider
OPENPROVIDER_BASE_URLmost likely"https://api.openprovider.eu/v1beta" -
Server IP: Set the IP address of your server to communicate with the API
OPENPROVIDER_IP -
Openprovider username: Set the username of your account (must have permission to use API, can be set in Openprovider dashboard)
OPENPROVIDER_USERNAME. -
Openprovider password: Set the password of your account (must have permission to use API, can be set in Openprovider dashboard)
OPENPROVIDER_PASSWORD.OPENPROVIDER_BASE_URL="https://api.openprovider.eu/v1beta" OPENPROVIDER_IP={IP address of your server} OPENPROVIDER_USERNAME={Openprovider username} OPENPROVIDER_PASSWORD={Openprovider password}
For detailed configuration options, refer to the comments within the config/openprovider-api.php file.
Usage
1. Domain management
This package provides functionality for managing domains via the Openprovider API. Below are the key actions you can perform with the DomainService.
Retrieve a list of domains
You can retrieve a list of domain using the getDomains() method.
To be able to retrieve the domains, make sure you have specified the credentials in your .env file.
use Spits\LaravelOpenproviderApi\Services\DomainService; $domains = app(new DomainService())->index(options: ['limit' => 100, 'offset' => 100]);
Parameters:
options: An array of options for the request see the Openprovider docs for the available options.
Retrieving a single domain
You can also retrieve a single domain using the getDomain() method. This allows you to get only one domain by specifying its id.
use Spits\LaravelOpenproviderApi\Services\DomainService; $domain = app(new DomainService())->getDomain(id: 'Openprovider ID');
Parameters:
id: The id of the domain
Update domain
You can update a domain by passing the id and data array to the updateDomain method.
This method requires the domain's identifier.
use Spits\LaravelOpenproviderApi\Services\DomainService; $response = new DomainService()->updateDomain(id: 'id', data: []);
Parameters:
id: TheIDof the domain you wish to updatedata: The data you wish to update. See the Openprovider docs for the updatable attributes
2. Managing DNS zones
This package supports managing DNS zones.
We made specific controllers for the Dns zone records as its our own main use case.
But the DnsService class can be used for all functions related to DNS zones.
Retrieving DNS zone records
You can get the records by using the show function in DnsRecordsController.
use Spits\LaravelOpenproviderApi\Services\DnsService; class DnsRecordsController { public function show(string $domain, DnsService $service) { $options = request()->get('options', ['with_records' => 'true']); $response = $service->getDnsZone($domain, $options); return $response->collect(); } }
Parameters:
domain: The domain for which you want to see de DNS zone informationoptions: An array set as query param with all the options you want to send with the call. See the docs for available options
Creating / Updating / Removing records
We chose too split these in separate controller functions.
But all can be done in 1 operation by calling the updateDnsZone function in Spits\LaravelOpenproviderApi\Services\DnsService
use Spits\LaravelOpenproviderApi\Services\DnsService; class DnsRecordsController { public function store(string $domain, DnsService $service, DnsRecordStoreRequest $request) { $data = [ 'provider' => $request->validated('provider'), 'records' => [ 'add' => [ $request->validated('record'), ], ], ]; return $service->updateDnsZone($domain, $data); } }
Exporting records
We created the export function in Spits\LaravelOpenproviderApi\Http\Controllers\DnsRecordsController to export Dns zone records to an .xlsx file.
use Spits\LaravelOpenproviderApi\Services\DnsService; class DnsRecordsController { public function export(string $domain, DnsService $service) { $options = request()->get('options', ['with_records' => 'true']); $response = $service->getDnsZone($domain, $options); $data = $response->collect(); $collection = collect($data['data']['records'])->map(function ($item) { return (object) $item; }); $export = new DnsZoneExport($collection); return Excel::download($export, 'dns_zone_'.$domain.'.xlsx'); } }
Contributing
Please submit ideas, issues and pull requests to the GitHub repository.
License
This package is open-sourced software licensed under the MIT license.
Contact
For any inquiries or support, please contact Spits.
spits-online/laravel-openprovider-api 适用场景与选型建议
spits-online/laravel-openprovider-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「openprovider」 「spits」 「laravel-openprovider-api」 「Openprovider API」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spits-online/laravel-openprovider-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spits-online/laravel-openprovider-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spits-online/laravel-openprovider-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package allows you to connect to Bird's API using Laravel
PHP client for the Openprovider REST API
Alfabank REST API integration
OpenProvider API client
A Laravel wrapper for the HostFact / WeFact API
OpenProvider for Laravel 6.x/7.x/8.x/9.x/10.x
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-22