Toolvana: production-ready media tools platform (CodeIgniter 4)
- 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
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
/**
|
||||
* Category landing pages: /youtube-tools, /video-tools, ...
|
||||
*/
|
||||
final class Categories extends BaseController
|
||||
{
|
||||
public function show(string $slug): string
|
||||
{
|
||||
$finder = service('finder');
|
||||
$category = $finder->category($slug);
|
||||
|
||||
if ($category === null) {
|
||||
return (new Errors())->notFound();
|
||||
}
|
||||
|
||||
$tools = $finder->toolsInCategory($slug);
|
||||
$guides = model(\App\Models\GuideModel::class)->published(50);
|
||||
// guides touching this category's tools
|
||||
$catToolSlugs = array_column($tools, 'slug');
|
||||
$relatedGuides = array_values(array_filter($guides, static function (array $g) use ($catToolSlugs): bool {
|
||||
$linked = json_decode((string) ($g['tool_slugs'] ?? '[]'), true) ?: [];
|
||||
|
||||
return count(array_intersect($linked, $catToolSlugs)) > 0;
|
||||
}));
|
||||
|
||||
$this->seo->title($category['seo_title'] ?: ($category['name'] . ' – Free Online'))
|
||||
->description($category['seo_description'] ?? (string) $category['tagline'])
|
||||
->canonical('/' . $category['slug'])
|
||||
->breadcrumbs([['label' => $category['name']]])
|
||||
->webApplication($category['name'], (string) ($category['tagline'] ?? ''))
|
||||
->faqPage(is_array($category['faqs']) ? $category['faqs'] : [])
|
||||
->ogImage('/og/' . $category['slug'] . '.png');
|
||||
|
||||
$this->trackToolView($category['slug']);
|
||||
|
||||
return $this->render('category', [
|
||||
'category' => $category,
|
||||
'tools' => $tools,
|
||||
'featured' => array_slice(array_filter($tools, static fn ($t) => (int) $t['is_featured'] === 1), 0, 4),
|
||||
'guides' => array_slice($relatedGuides, 0, 3),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user