psvneo/typo3-extension-meilisearch
Composer 安装命令:
composer require psvneo/typo3-extension-meilisearch
包简介
This extension integrates "meilisearch" into your TYPO3.
README 文档
README
Please note that this extension is still in the alpha phase! Until version 1.0, there will be fundamental changes even with minor updates and patch updates. If you really want to use this extension, you should pin the version at patch level.
This extension integrates meilisearch into your TYPO3.
Requirements
- TYPO3 ^14.1
- PHP ^8.2
Installation
Use composer to add the extension to your project.
composer require psvneo/typo3-extension-meilisearch
You can also download the extension from the TER here.
Setup / Configuration
Add the following to the site settings.yaml where you want to use meilisearch.
meilisearch:
searchResult:
# Search result - Attributes to highlight.
attributesToHighlight: [ '*' ]
# Search result - Attributes to crop.
attributesToCrop: [ 'title:1', 'searchContent:5' ]
api:
# URL to your meilisearch service.
serviceUrl: http://localhost:7700
# Search API Key. Please use a readonly key here!
searchApiKey: '%env(MEILISEARCH_SEARCH_APIKEY)%'
# Admin API Key. This key is used to index yur data.
adminApiKey: '%env(MEILISEARCH_ADMIN_APIKEY)%'
pageIndexer:
# Define the index columns for pages.
pageIndexColumns:
- title
- seo_title
- keywords
- abstract
- description
# Define the index columns for tt_content.
contentIndexColumns:
- header
- bodytext
- subheader
How to index
This command will execute every indexer found by the system.
vendor/bin/typo3 meilisearch:index MY_SITE_IDENTIFIER
To also flush the index before indexing new run:
vendor/bin/typo3 meilisearch:index MY_SITE_IDENTIFIER -f
How to create your own indexer
Indexers are automatically collected via dependency injection. The extension uses a CompilerPass to automatically register indexers, so you don't need to register them manually. You only need to ensure your indexer is available as a service.
To create an indexer you can:
- implement
\PSVNEO\Meilisearch\Domain\Indexer\IndexerInterfaceor - extend from
\PSVNEO\Meilisearch\Domain\Indexer\AbstractIndexer(recommended).
Create your own indexer extending the AbstractIndexer class (recommended)
declare(strict_types=1);
namespace Vendor\ExtensionName\Domain\Indexer;
use PSVNEO\Meilisearch\Domain\Indexer\AbstractIndexer;
use TYPO3\CMS\Core\Site\Entity\Site;
final class XyzIndexer extends AbstractIndexer
{
public function getType(): string
{
return 'tx_myextension_xyz';
}
public function collectDocuments(Site $site): array
{
$rows = $this->getQueryBuilder('tx_myextension_domain_model_xyz')
->select('*')
->from('tx_myextension_domain_model_xyz')
->executeQuery()
->fetchAllAssociative();
// We need to add a prefix to the uid field to make sure we have a unique uids among the other types.
return array_map(fn($row) => array_merge($row, ['uid' => $this->prefixUid((string) $row['uid'])]), $rows);
}
}
The
AbstractIndexerprovides sensible defaults forgetPrimaryKeyName(),getFilterableAttributes(), andgetFacetingAttributes()methods, as well as thegetQueryBuilder()method for database queries andprefixUid()for creating unique document identifiers.
Available CLI Commands
# Indexing
vendor/bin/typo3 meilisearch:index SITE_IDENTIFIER [-f|--flush-index]
# Index management
vendor/bin/typo3 meilisearch:indexes SITE_IDENTIFIER [-l|--list-indexes]
vendor/bin/typo3 meilisearch:indexes SITE_IDENTIFIER [-g|--get-index=INDEX_UID]
vendor/bin/typo3 meilisearch:indexes SITE_IDENTIFIER [-d|--delete-index=INDEX_UID]
vendor/bin/typo3 meilisearch:indexes SITE_IDENTIFIER [--delete-all-indexes]
# Document management
vendor/bin/typo3 meilisearch:documents SITE_IDENTIFIER [-a|--action=GET|DELETE] [-i|--index=INDEX_UID] [-d|--document=DOC_ID] [-o|--offset=N] [-l|--limit=N]
# Search testing
vendor/bin/typo3 meilisearch:search SITE_IDENTIFIER SEARCHTERM [-i|--index=INDEX_UID]
# Service information
vendor/bin/typo3 meilisearch:version SITE_IDENTIFIER
vendor/bin/typo3 meilisearch:stats SITE_IDENTIFIER
vendor/bin/typo3 meilisearch:keys SITE_IDENTIFIER
Frontend Integration
The extension provides JavaScript components for frontend search:
- InstantSearch.js: Ready-to-use search widgets
- Vue.js components: For Vue-based applications
- Search widget: Configurable search component
Templates are located in Resources/Private/Templates/Search/.
Proxy Architecture
The frontend communicates with Meilisearch through a backend proxy (MeilisearchProxyMiddleware) to avoid exposing API keys in the browser.
This middleware intercepts requests to/meilisearch-proxy and forwards them to your Meilisearch instance with proper authentication.
Middleware Registration
The proxy middleware is automatically registered in Configuration/RequestMiddlewares.php:
<?php
declare(strict_types=1);
use PSVNEO\Meilisearch\Middleware\MeilisearchProxyMiddleware;
return [
'frontend' => [
MeilisearchProxyMiddleware::IDENTIFIER => [
'target' => MeilisearchProxyMiddleware::class,
'before' => ['typo3/cms-frontend/timetracker'],
],
],
];
Development
Use the provided composer scripts for development:
# Install dependencies
composer install
# Linting (individual commands)
composer lint:php # Lint PHP code using phplint
composer lint:cs # Lint code style using php-cs-fixer
composer lint:ec # Lint editorconfig using editorconfig-cli
composer lint:t3s # Scan for TYPO3 compatibility issues
composer lint:typoscript # Lint TypoScript code
composer lint:debug # Search for debug statements
composer lint:yaml # Lint YAML files
composer lint # Run all linting checks
# Code fixing
composer fix:cs # Fix code style using php-cs-fixer
composer fix:ec # Fix editorconfig issues
composer fix # Run all fixing commands
# Quality analysis
composer qa:analyze # Run PHPStan analysis
composer qa:phpmd # Run PHPMD analysis
composer qa # Run all quality analysis
# Refactoring
composer refactoring:rector # Refactor using Rector
composer refactoring:fractor # Refactor using Fractor
composer refactoring # Run all refactoring tools
# Testing
composer test:unit # Run unit tests
composer test:functional # Run functional tests
composer test:e2e # Run end-to-end tests with Cypress
# Building
composer build # Build extension using Docker container
License
This extension is licensed under GPL-2.0-or-later.
psvneo/typo3-extension-meilisearch 适用场景与选型建议
psvneo/typo3-extension-meilisearch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 708 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「search」 「extension」 「typo3」 「meilisearch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 psvneo/typo3-extension-meilisearch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 psvneo/typo3-extension-meilisearch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 psvneo/typo3-extension-meilisearch 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to retrieve data from Google Search Console
A custom URL rule class for Yii 2 which allows to create translated URL rules
Set Links with a specific language parameter
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Abstraction Layer to index and search entities
统计信息
- 总下载量: 708
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2023-11-15