synergitech/laravel-typesense-tools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

synergitech/laravel-typesense-tools

Composer 安装命令:

composer require synergitech/laravel-typesense-tools

包简介

This library adds tools for Typesense within Laravel

README 文档

README

This package adds Artisan commands that help manage Typesense Collections and Collection Aliases in Laravel applications using Laravel Scout.

Using Typesense with Scout requires you to define the schema in the Scout config file so we change the expected functions to static to reduce duplication. This means that the functions cannot reference app() or config() because they're executed too early in the booting process.

We make use of Typesense Collection Aliases so that schema changes can be gracefully deployed to our frontends without causing issues.

See the full examples in examples/models/User.php and examples/config/scout.php.

Requirements

  • PHP ^8.2
  • Laravel Framework >=10.0
  • Laravel Scout >=10.0
  • Typesense PHP client >=5.1

Installation

composer require synergitech/laravel-typesense-tools

Usage

Our environments typically have separated application/frontend and worker contexts and we also usually run a separate CLI context. The deployment runbook is usually as follows.

  1. deploy new code to the CLI and run any migrations
  2. deploy new code to the workers with an updated TYPESENSE_VERSION_SUFFIX. We typically use a date for the suffix for easy versioning, i.e. 20260325.
  3. run php artisan search:setup to populate the new collections
  4. when the queue is empty, the new collection schema fields are now available as search:switch-alias is run as the final queue job
  5. deploy the new code to the frontend so the new fields are in use
  6. (optional) run php artisan search:cleanup to remove the now unused collections and get some memory back

Development

As the frontend is powered by Aliases, you can save yourself a little bit of effort by adding the following to the bottom of your DatabaseSeeder class.

\Illuminate\Support\Facades\Artisan::call(
    command: 'search:switch-alias',
    outputBuffer: $this->command->getOutput()->getOutput(),
);

This means that every time you or a colleague are starting from scratch, the Aliases will be created. Scout will automatically create the Collections as part of the new data being added.

If you aren't implicitly creating every Collection during your seeding process, you can swap in search:setup instead and that will make sure all the Collections exist and the Aliases are created.

Command reference

  • search:setup to ensure collections exist and (optionally) import data.
  • search:switch-alias to point aliases at the current index collections.
  • search:delete-suffix {suffix} to remove old suffixed collections.
  • search:cleanup to remove collections that are not referenced by an alias.

search:setup

Populates all known collections and dispatches a search:switch-alias at the end. If --only-index is provided, it checks each Collection/Alias exists. The check is useful for confirming your schema works and there aren't any errors.

Options:

  • --only-index: only verify/create collections.
  • --flush: flush each model before importing.

Examples:

php artisan search:setup --only-index
php artisan search:setup --flush

search:switch-alias

Upserts each model's alias (searchableAs) to target the active collection (indexableAs). This is used automatically after a call to search:setup

php artisan search:switch-alias

search:delete-suffix {suffix}

Deletes old collections named as:

  • <searchableAs>_<suffix>

Example:

php artisan search:delete-suffix 20260325

search:cleanup

Finds and optionally deletes collections not currently referenced by any alias.

php artisan search:cleanup

synergitech/laravel-typesense-tools 适用场景与选型建议

synergitech/laravel-typesense-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 117 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「scout」 「typesense」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 synergitech/laravel-typesense-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 synergitech/laravel-typesense-tools 我们能提供哪些服务?
定制开发 / 二次开发

基于 synergitech/laravel-typesense-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 117
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-26