Laravel API Toolkit(laravel接口工具包)
Laravel  /  管理员 发布于 1个月前   70
Laravel API Toolkit(应用程序接口工具包)通过标准化响应、动态分页等功能为你的应用程序接口开发增色不少。
目前,它支持以下功能:
模式支持
分页助手
API 生成器命令
API 过滤
操作
媒体助手
还有更多...
使用提供的 api:generate Artisan 命令,
您可以轻松生成所需的所有关键文件,包括控制器、请求、资源、模型、迁移等:
php artisan api:generate Customer \
"username:string|age:integer:nullable|company_id:foreignId|status:enum(new,old)" \
--all
运行上述命令后,将创建以下文件,为您提供开始构建客户 API 所需的一切:
过滤是该软件包的另一个有用功能,它可以让你定义哪些字段可以进行过滤。
以汽车模型为例,过滤器配置如下:
namespace App\Models;
use Essa\APIToolKit\Filters\Filterable;
class Car extends Model
{
use Filterable;
protected string $default_filters = CarFilters::class;
// Other model code...
}
而 CarFilters 类可能是这样的:
namespace App\Filters;
use Essa\APIToolKit\Filters\QueryFilters;
class CarFilters extends QueryFilters
{
protected array $allowedFilters = ['color', 'model_id'];
protected array $columnSearch = [];
}
// GET /cars?color=red
操作是该软件包的另一项功能,您可以使用它将业务逻辑封装在不同的类中,并用这些类来组成
namespace App\Actions;
class CreateCar
{
public function execute($data)
{
// ...
}
}
// usage example in a controller
public function store(Request $request)
{
$this->createCar->execute($request->all());
}
要开始使用此软件包,请查看官方文档。
https://laravelapitoolkit.com/
您可以在GitHub上了解有关此软件包的更多信息、获得完整的安装说明并查看源代码。
https://github.com/ahmedesa/laravel-api-tool-kit
路人 在
php中使用hyperf框架调用讯飞星火大模型实现国内版chatgpt功能示例中评论 教程很详细,如果加个前端chatgpt对话页面就完美了..博主 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 @ mashrdn 多切换几个节点测试,免费ssr是没那么稳..mashrdn 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 V2rayn免费节点添加上去了,youtobe无法打开网页,是怎么回事..张伟 在
科学上网翻墙之v2rayN-Core客户端免费公益节点使用教程中评论 3q!有用,不过免费节点隔天就要去git上复制新的导进去..博主 在
科学上网翻墙访问Google , 上外网神器佛跳墙VPN(永久免费)使用流程步骤中评论 该篇教程已不能用了,告知大家,免的老有老铁问我!..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号