跳转到主内容
趣航编程网 - 趣学编程,启航技术之路!

快看!这个Laravel World扩展支持中文!

下面由 laravel 教程栏目带大家推荐介绍关于 laravel world的扩展,希望对大家有所帮助! Laravel World —— 自带数据库的国家以及城市数据(支持中文) Laravel World (https://github.com/nnjeim/world)是一个提供国家、州、城市、货币和时区列表的包。 World 通过数据库将数据与 Eloquent 模型集成,并提供 Facades、helper 和 API 路由:
use Nnjeim\World\World; $action = World::countries(); /* { "success": true, "message": "countries", "data": [ { "id": 1, "name": "Afghanistan" }, { "id": 2, "name": "Åland Islands" }, ... ], } */
这是 readme 中的另一个示例,使用过滤器来获取国家/地区和该国家/地区内的城市:
// 获取国家和城市 $action = World::countries([ 'fields' => 'states,cities', 'filters' => [ 'iso2' => 'FR', ] ]); /* { "success": true, "message": "countries", "data": [ "id": 77, "name": "France", "states": [ { "id": 1271, "name": "Alo" }, { "id": 1272, "name": "Alsace" }, ], "cities": [ { "id": 25148, "name": "Abondance" }, { "id": 25149, "name": "Abrest" }, ... ] ], } */
此包还支持本地化(请参阅 readme 以了解支持的语言环境),为所有数据提供 API,并具有辅助函数,如格式化电话号码等 Laravel 13.2.0 PHP中文网提供Laravel 13.2.0版本下载,Laravel框架 是基于 PHP 8.3+ 的高性能框架,官方推荐通过 Composer 安装。它内置 AI SDK、JSON:API Resources 及原生向量搜索,支持属性驱动开发与队列路由,大幅提升开发效率。相比旧版,13.2.0 优化了缓存 TTL 管理与实时通信,无需 Redis 即可横向扩展。作为现代 Web 开发首选,它兼顾安全与极速体验,助您快速构建企业级应用。 下载 您可以了解有关此软件包的更多信息、获取完整的安装说明并查看 GitHub 上的 源代码。(https://github.com/nnjeim/world) 此包已提交到我们的 Laravel 新闻链接 部分。 链接是社区可以围绕 Laravel 生态系统发布软件包和教程的地方。 在 Twitter 上关注 @LaravelLinks 原文地址:https://laravel-news.com/laravel-world 译文地址:https://learnku.com/laravel/t/62354

相关文章