New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

jeffersongoncalves/laravel-topic-normalizer

A tiny Laravel helper that merges raw topic/keyword lists (GitHub topics, composer.json + package.json keywords, Packagist keywords, …) into one slugged, deduplicated, length-filtered and capped list.
1,014 1
Install
composer require jeffersongoncalves/laravel-topic-normalizer
Latest Version:v1.0.0
PHP:^8.2
Laravel:11 · 12 · 13
License:MIT
Last Updated:Oct 19, 2026
Links: GitHub  ·  Packagist
Maintainer: jeffersongoncalves

Laravel Topic Normalizer

Laravel Topic Normalizer

Buy Me A Coffee

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Merge raw topic / keyword lists from several sources — GitHub topics, composer.json + package.json keywords, Packagist keywords — into one clean list: slugged, deduplicated, length-filtered and capped.

Installation

composer require jeffersongoncalves/laravel-topic-normalizer

Usage

use JeffersonGoncalves\TopicNormalizer\TopicNormalizer;

$topics = TopicNormalizer::normalize(
    $repo['topics'] ?? [],          // GitHub topics
    $composer['keywords'] ?? [],    // composer.json
    $packageJson['keywords'] ?? [], // package.json
);
// => ['laravel', 'filament', 'php-package', …]  (slugged, unique, max 20)

Pass any number of lists. Non-strings are skipped; values are Str::slug()-ed, empties and out-of-range slugs dropped, duplicates removed (first occurrence wins, order preserved), and the result capped.

Per-call overrides

The config defaults can be overridden per call with named arguments (each falls back to its config value):

$topics = TopicNormalizer::normalize(
    $repo['topics'] ?? [],
    $composer['keywords'] ?? [],
    max: 10,        // cap this call at 10
    maxLength: 30,  // drop slugs longer than 30 chars
    minLength: 2,   // drop single-character noise
);

max_length / min_length are accepted as snake_case aliases. A max of 0 (or less) returns an empty list.

Configuration

php artisan vendor:publish --tag="topic-normalizer-config"
Key Default Description
max 20 Maximum number of topics returned (0 or less returns nothing).
max_length 50 Slugs longer than this are dropped as junk.
min_length 0 Slugs shorter than this are dropped as junk (0 disables the check).

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

jeffersongoncalves/laravel-cookie-consent

This Laravel package provides a simple and elegant way to implement cookie conse...

18,107 5
jeffersongoncalves/laravel-gtm

This plugin seamlessly integrates Google Tag Manager (GTM) into your website, en...

6,920 4
jeffersongoncalves/laravel-cep

A simple and efficient PHP package for querying Brazilian postal codes (CEP). Th...

6,525 3
jeffersongoncalves/laravel-pwa-favicon

This Laravel package serves a spec-shaped PWA `manifest.json` (with Android dens...

5,222 3
jeffersongoncalves/laravel-favicon

This Laravel package serves a favicon.ico route, a browserconfig.xml for Windows...

4,205 2

Version History

Version Released PHP Laravel License
v1.0.0 ^8.2 ^11.0|^12.0|^13.0 MIT