delaneymethod/craft-meilisearch-editor
Composer 安装命令:
composer require delaneymethod/craft-meilisearch-editor
包简介
Manage your Meilisearch content without a developer.
README 文档
README
Manage your Meilisearch content without a developer.
Install
From the Plugin Store
Go to the Plugin Store in your project's Control Panel and search for "meilisearch editor". Then press "Install".
With Composer
Add the repo to your project and install via Composer:
cd /path/to/project composer require delaneymethod/meilisearch-editor && php craft plugin/install meilisearch-editor
Console commands (useful in CI)
php craft meilisearch-editor/index/delete --handle=my-index --dryRun=0 // Deletes index. php craft meilisearch-editor/index/flush --handle=my-index --dryRun=0 // Flushes index documents. php craft meilisearch-editor/index/reindex --handle=my-index --dryRun=0 // Rebuilds index.
Frontend: minimal example
{% set siteId = craft.app.sites.currentSite.id %}
{% set index = craft.meilisearchEditor.getIndex('devices') %}
{% set filters = craft.meilisearchEditor.getFilters(index.handle) %}
{% set sortables = craft.meilisearchEditor.getSortables(index.handle) %}
<h1>Meilisearch Demo – {{ index.label }}</h1>
<form style="display: grid; gap: 0.75rem; grid-template-columns: 1fr 1fr 1fr; max-width: 980px; margin: 1rem 0;">
<label style="display: flex; flex-direction: column; gap: 0.25rem;">
<span>Search</span>
<input type="search" id="query" name="query" placeholder="Search..." value="" />
</label>
{% if filters|length %}
{% for filter in filters %}
<label style="display:flex; flex-direction:column; gap:.25rem;">
<span>{{ filter.name }}</span>
<select id="{{ 'filter-' ~ filter.id }}" data-attribute="{{ filter.id }}">
<option value="">All</option>
{% for option in filter.options %}
<option value="{{ option.label }}">{{ option.label }}</option>
{% endfor %}
</select>
</label>
{% endfor %}
{% endif %}
<label style="display:flex; flex-direction:column; gap:.25rem;">
<span>Sort</span>
<select id="{{ 'sort-' ~ index.handle }}">
<option value="">Relevance</option>
{% for sortable in sortables %}
<option value="{{ sortable.value }}">{{ sortable.label }}</option>
{% endfor %}
</select>
</label>
</form>
<pre id="results" style="background: #f2f2f2; color: #9f9f9f; padding: 1rem; border-radius: 8px; max-width: 980px; overflow: auto;"></pre>
<script>
(async () => {
// Get a short-lived search key
const response = await fetch('{{ url("meilisearch-editor/keys/issue") }}', {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"X-CSRF-Token": "{{ craft.app.request.csrfToken }}",
},
body: JSON.stringify({
name: "Demo Search Key",
handle: "{{ index.handle }}",
actions: ["search"],
ttl: 900,
})
});
const json = await response.json();
if (!response.ok || !json.key) {
console.error("Key issue failed:", json);
return;
}
const { key, indexes } = json;
const indexUid = indexes[0];
const base = "{{ url("meilisearch") }}";
const searchUrl = `${base}/indexes/${encodeURIComponent(indexUid)}/search`;
const headers = {
"Accept": "application/json",
"Authorization": `Bearer ${key}`,
"Content-Type": "application/json",
};
const debounce = (fn, ms = 200) => {
let t;
return (...args) => {
clearTimeout(t);
t = setTimeout(() => fn(...args), ms);
};
};
const results = document.querySelector("#results");
const queryInput = document.querySelector("#query");
const sortSelect = document.querySelector("#{{ 'sort-' ~ index.handle }}");
const filterSelects = Array.from(document.querySelectorAll('select[id^="filter-"]'));
function buildFilters() {
const filters = [];
filterSelects.forEach(select => {
const attribute = select.dataset.attribute;
const value = select.value;
if (!attribute || !value) {
return;
}
const safeValue = value.replace(/"/g, '\\"');
filters.push(`${attribute} = '${safeValue}'`);
});
return filters;
}
async function doSearch() {
const q = queryInput ? (queryInput.value || "") : "";
const filters = buildFilters();
const sortValue = sortSelect && sortSelect.value ? [sortSelect.value] : undefined;
const payload = {
q,
limit: 10,
...(filters.length ? { filter: filters } : {}),
...(sortValue ? { sort: sortValue } : {}),
};
const response = await fetch(searchUrl, {
method: "POST",
headers,
body: JSON.stringify(payload),
});
const json = await response.json();
results.textContent = JSON.stringify(json.hits ?? json, null, 2);
}
if (queryInput) {
queryInput.addEventListener("input", debounce(doSearch, 200));
}
filterSelects.forEach(select => select.addEventListener("change", doSearch));
if (sortSelect) {
sortSelect.addEventListener("change", doSearch);
}
await doSearch();
})();
</script>
delaneymethod/craft-meilisearch-editor 适用场景与选型建议
delaneymethod/craft-meilisearch-editor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「editor」 「Craft」 「craftcms」 「craft-plugin」 「content editor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 delaneymethod/craft-meilisearch-editor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 delaneymethod/craft-meilisearch-editor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 delaneymethod/craft-meilisearch-editor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Adds more BBCode
Integrate with Snipcart.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-28