fastwhale/wordpress-php-sdk
Composer 安装命令:
composer require fastwhale/wordpress-php-sdk
包简介
WordPress Laravel PHP SDK
关键字:
README 文档
README
Installation
Require this package in your composer.json and update composer.
composer require fastwhale/wordpress-php-sdk
After updating composer, add the ServiceProvider to the providers array in config/app.php
Fastwhale\WordPress\WordPressServiceProvider::class,
You can use the facade for shorter code. Add this to your aliases:
'WP' => Fastwhale\WordPress\WordPressFacade::class,
Add the config files
php artisan vendor:publish --provider="Fastwhale\WordPress\WordPressServiceProvider"
Documentation
Authentication
To use authenticated requests you have to sign in to the WordPress website to generate a JWT token. WordPress doesn't support this by default, you have to install a JWT compatible plugin. This package is tested with: https://nl.wordpress.org/plugins/jwt-authentication-for-wp-rest-api/
use Fastwhale\WordPress\WordPressFacade as WordPress; $token = WordPress::login($request->get('email'), $request->get('password')); // {'token': '...'}
Now you can save the $token->token to your database.
use Fastwhale\WordPress\WordPressFacade as WordPress;
WordPress::setAccessToken($token);
Application Password
You can use the newly introduced Application Password (in WordPress 5.6).
$wp = WordPress::setServer('https://www.example.com')
->setUsername('username')
->setApplicationPassword('application password');
Interact with objects
User
WordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/users/
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::user()->list();
$result = WordPress::user()->create($data);
$user = WordPress::user()->get($id);
$result = WordPress::user()->update($id, $data);
$result = WordPress::user()->delete($id);
Post
WordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/posts/
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::post()->list();
$result = WordPress::post()->create($data);
$user = WordPress::post()->get($id);
$result = WordPress::post()->update($id, $data);
$result = WordPress::post()->delete($id);
Post from custom post type
WordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/posts/
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::customPost('custom_post_type')->list();
$result = WordPress::customPost('custom_post_type')->create($data);
$user = WordPress::customPost('custom_post_type')->get($id);
$result = WordPress::customPost('custom_post_type')->update($id, $data);
$result = WordPress::customPost('custom_post_type')->delete($id);
Tags
WordPress Rest API documentation: https://developer.wordpress.org/rest-api/reference/tags/
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::tag()->list();
$result = WordPress::tag()->create($data);
$user = WordPress::tag()->get($id);
$result = WordPress::tag()->update($id, $data);
$result = WordPress::tag()->delete($id);
Create new post
$data = [
'title' => 'title',
'parent' => 0,
'slug' => Str::slug('title', '-'),
'content' => 'content',
];
$post = WordPress::post()->create($data);
// {'id': ...}
Uploading media
use Illuminate\Support\Facades\Storage;
use Fastwhale\WordPress\WordPressFacade as WordPress;
$media = WordPress::postCall('/wp-json/wp/v2/media', [
'multipart' => [
[
'name' => 'file',
'contents' => Storage::disk('local')->get($fileLocation),
'filename' => 'filename.jpg',
],
[
'name' => 'title',
'contents' => 'Title of attachment',
],
[
'name' => 'alt_text',
'contents' => 'Alt text',
],
],
]);
Execute any request
Read more about the WordPress rest API: https://developer.wordpress.org/rest-api/
Get
$url = "";
$result = WordPress::getCall('/wp-json'.$url);
Put
$result = WordPress::putCall('/wp-json'.$url, $data);
Post
$result = WordPress::postCall('/wp-json'.$url, $data);
Delete
$result = WordPress::deleteCall('/wp-json'.$url);
The complete documentation can be found at: https://www.tpweb.org/my-projects/wordpress-php-sdk/
Support
Support github or mail: tjebbe.lievens@madeit.be
Contributing
Please try to follow the psr-2 coding style guide. http://www.php-fig.org/psr/psr-2/
License
This package is licensed under LGPL. You are free to use it in personal and commercial projects. The code can be forked and modified, but the original copyright author should always be included!
fastwhale/wordpress-php-sdk 适用场景与选型建议
fastwhale/wordpress-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「wordpress」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fastwhale/wordpress-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fastwhale/wordpress-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fastwhale/wordpress-php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Must-use plugin integrating WordPress with the Upsun platform: environment awareness, router-cache friendliness, safe preview clones, deploy migrations, Site Health checks, and a wp upsun CLI command.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
bughq error tracking - PHP SDK
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2024-12-11