achyutn/laravel-news-sdk
Composer 安装命令:
composer require achyutn/laravel-news-sdk
包简介
A simple PHP SDK for submitting links to Laravel News.
README 文档
README
A simple PHP SDK for submitting links to Laravel News using their API.
Requirements
- PHP 8.1 or higher
- Laravel 10.0 or higher
Installation
You can install the package via Composer:
composer require achyutn/laravel-news-sdk
Configuration
After installing, publish the configuration file:
php artisan vendor:publish --tag="laravel-news"
This will create a config/laravel-news.php file.
Next, set your Laravel News API token in your .env file:
LARAVEL_NEWS_TOKEN=your-api-token-here
You can obtain an API token from Laravel News.
Usage
Using the Facade
use AchyutN\LaravelNews\Facades\LaravelNews; use AchyutN\LaravelNews\Data\Link; use AchyutN\LaravelNews\Enums\LinkCategory; $link = new Link( title: 'Filament Log Viewer', url: 'https://packagist.org/packages/achyutn/filament-log-viewer', category: LinkCategory::Package ); $item = LaravelNews::post($link); // The item is a Link DTO populated with server-side data echo $item->id; echo $item->createdAt;
Using Dependency Injection
use AchyutN\LaravelNews\LaravelNews; class SomeController { public function __construct( private LaravelNews $laravelNews ) {} public function submitLink() { $link = new Link( title: 'Cool Tutorial', url: 'https://example.com/tutorial' ); $item = $this->laravelNews->post($link); } }
API Reference
LaravelNews
The main class for interacting with the Laravel News API.
post(Link $link): Link
Submits a link and returns a populated Link instance.
- Throws:
AchyutN\LaravelNews\Exceptions\LaravelNewsExceptionif the API returns an error or the token is missing.
Link
The core Data Transfer Object for submitting links.
Properties:
string $title(Required, max 100 chars)string $url(Required, valid URL)LinkCategory|null $categoryint|null $id(Populated after response)int|null $userId(Populated after response)Carbon|null $createdAtCarbon|null $updatedAt
toPostArray(): array
Converts the DTO into the format expected by the Laravel News API for submission.
fromArray(array $data): self
Creates a Link item from API response data.
LinkCategory
Enum for link categories.
LinkCategory::TutorialLinkCategory::Package
Contributing
Contributions are welcome! Please create a pull request or open an issue if you find any bugs or have feature requests.
License
This package is open-sourced software licensed under the MIT license.
Support
If you find this package useful, please consider starring the repository on GitHub to show your support.
achyutn/laravel-news-sdk 适用场景与选型建议
achyutn/laravel-news-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 354 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「sdk」 「news」 「laravel」 「links」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 achyutn/laravel-news-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 achyutn/laravel-news-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 achyutn/laravel-news-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Extend news to use them also as event
This TYPO3 distribution provides a sample website using bootstrap and the extensions pizpalue and container_elements. The distribution tailors Swiss market featuring German as default language and additional translations to French, English and Finnish.
PHP unofficial client to cryptopanic.com API
News feature for Clara.
Extend news by a sub headline
统计信息
- 总下载量: 354
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-07