faintshadow/routehelper
最新稳定版本:1.0.2
Composer 安装命令:
composer require faintshadow/routehelper
包简介
Generate a URL pattern for a named route with placeholder support.
README 文档
README
Generate a URL pattern for a named route with placeholder support.
This helper creates route URLs with placeholder templates that can be used
for frontend JavaScript route generation. Placeholders MUST follow the
format {name} where 'name' matches the route parameter name.
Examples:
Basic usage with placeholder:
$pattern = routeTemplate('company.item.destroy', [
'company' => $company->id,
'item' => '{item}' // MUST use {item} format
]);
// Returns: "https://example.com/companies/123/items/{item}"
Usage with multiple placeholders:
$pattern = routeTemplate('company.department.employee.show', [
'company' => '{company}', // MUST use {company} format
'department' => '{department}', // MUST use {department} format
'employee' => '{employee}' // MUST use {employee} format
]);
Mixed actual values and placeholders:
$pattern = routeTemplate('company.item.edit', [
'company' => 456, // Actual value
'item' => '{item}' // Placeholder - MUST use {item} format
]);
// Returns: "https://example.com/companies/456/items/{item}/edit"
Important:
All placeholder templates MUST follow the exact format {parameterName} where parameterName matches the route parameter. Incorrect formats like {{item}}, <item>, or ITEM_ID will not work.
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2025-10-03