承接 sulimanbenhalim/route-hints 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sulimanbenhalim/route-hints

Composer 安装命令:

composer require sulimanbenhalim/route-hints

包简介

Intelligent 'did you mean?' route suggestions for Laravel 404 errors

README 文档

README

GitHub License PHP Version Support Laravel Version Support

Laravel 404 errors → intelligent route suggestions

Install

composer require sulimanbenhalim/route-hints

Usage

Routes Control

All routes discoverable by default

Route::get('/users', UserController::class);                    // ✓ Suggested  
Route::get('/posts', PostController::class)->discoverable();    // ✓ Explicitly suggested
Route::get('/admin', AdminController::class)->hidden();         // ✗ Never suggested

Custom Keywords

Route::get('/dashboard', HomeController::class)
    ->withHints(['home', 'control-panel']);

/home → suggests /dashboard

Parameterized Routes

Route::get('/posts/{post}', PostController::class)
    ->includeParameterized(['post' => 'welcome']);

/post → suggests /posts/welcome

Programmatic Access

$suggestions = app('route-hints')->findSuggestions(request());
$suggestions = RouteHints::findSuggestions(request());

Responses

Request Type Response
HTML Default Laravel 404 view with clickable suggestions
JSON {"suggestions": [{"url": "http://app.test/users"}]}
Auto-redirect Direct redirect when similarity > threshold

Auto-Redirect Setup

Required for session-based auto-redirect

Add to bootstrap/app.php:

->withMiddleware(function (Middleware $middleware): void {
    $middleware->prepend(\Illuminate\Session\Middleware\StartSession::class);
})

// Or running this command, mentioned blow in the docs
// php artisan route-hints:setup-session

Auto-redirect Data:

// Query method adds URL parameters:
// /users?route_corrected_from=%2Fuser&similarity=90.5&route_name=users.index

// Session method stores structured data:
session('route_hints_correction') = [
    'original_path' => '/user',
    'corrected_path' => '/users', 
    'similarity_percentage' => 90.5,
    'route_name' => 'users.index',
    'corrected_at' => '2024-01-15T...'
];

Configuration

php artisan vendor:publish --tag=route-hints-config
All Settings
Setting Default Description
enabled true Enable/disable route hints
max_distance 5 Levenshtein distance limit
max_suggestions 3 How many to show
default_discoverable true Routes discoverable by default
excluded_patterns [] Never suggest these routes
cache_ttl 3600 Cache discoverable routes (seconds)
show_similarity_percentage false Show similarity % in responses
show_route_names_json false Include route names in JSON
show_route_names_view false Show route names in HTML
auto_redirect.enabled false Auto-redirect feature
auto_redirect.threshold 80 Similarity % needed for redirect
auto_redirect.method session How to pass correction info
auto_redirect.query_param route_corrected_from Query parameter name
auto_redirect.session_key route_hints_correction Session key name

Commands

php artisan route-hints:analyze [path]    # Test route suggestions for any path
php artisan route-hints:cache build       # Build route cache for performance
php artisan route-hints:cache status      # Check cache status and info
php artisan route-hints:cache clear       # Clear route cache
php artisan route-hints:setup-session     # Configure auto-redirect session

Examples

User Types Gets Suggested Why
/user /users Typo correction
/dashbord /dashboard Spelling mistake
/home /dashboard Custom hint
/product-categories /categories/electronics Parameterized with default

Testing

The package includes a comprehensive test suite:

composer test

Laravel Version Compatibility

Laravel Version Package Version
11.x 1.x
12.x 1.x

Security

If you discover any security issues, please email soliman.benhalim@gmail.com instead of using the issue tracker.

License

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

sulimanbenhalim/route-hints 适用场景与选型建议

sulimanbenhalim/route-hints 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「routing」 「laravel」 「404」 「ux」 「suggestions」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sulimanbenhalim/route-hints 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sulimanbenhalim/route-hints 我们能提供哪些服务?
定制开发 / 二次开发

基于 sulimanbenhalim/route-hints 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-18