- 134-tool registry with programmatic SEO (unique titles/H1/descriptions, JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter) - DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD), Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG) - Security: SSRF guard, MIME validation, rate limits, API-key auth, bcrypt admin login, security headers - Admin panel: dashboard, tools/categories/guides CRUD, SEO audit, analytics, job inspector with retry, system health, feature flags - Docker deployment (nginx + web/api FPM pools + scalable workers), PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controllers\Api;
|
|
|
|
use App\Libraries\ToolSearch;
|
|
use CodeIgniter\Controller;
|
|
|
|
/** Typeahead suggestions for the global search box. */
|
|
final class SearchApi extends Controller
|
|
{
|
|
public function suggest(): \CodeIgniter\HTTP\ResponseInterface
|
|
{
|
|
$q = trim((string) $this->request->getGet('q'));
|
|
if (mb_strlen($q) < 2) {
|
|
return response()->setJSON(['ok' => true, 'results' => []]);
|
|
}
|
|
|
|
$hits = (new ToolSearch())->find($q, 6);
|
|
$out = [];
|
|
foreach ($hits as $tool) {
|
|
$out[] = [
|
|
'slug' => $tool['slug'],
|
|
'name' => $tool['name'],
|
|
'url' => '/' . $tool['slug'],
|
|
'icon' => $tool['icon'],
|
|
];
|
|
}
|
|
|
|
if ($out !== []) {
|
|
service('analytics')->track('search', ['meta' => ['term' => mb_substr($q, 0, 60), 'scope' => 'suggest']]);
|
|
}
|
|
|
|
return response()->setJSON(['ok' => true, 'results' => $out]);
|
|
}
|
|
}
|