承接 paulhenri-l/laravel-route-helpers 相关项目开发

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

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

paulhenri-l/laravel-route-helpers

Composer 安装命令:

composer require paulhenri-l/laravel-route-helpers

包简介

Rails like route helpers to easily generate paths to your laravel controllers

README 文档

README

Build Status

Route helpers are simple function that will generate paths to your application resources.

For instance if you have a PostsController you'll get these helpers:

  • posts_path()
  • post_path()
  • new_post_path()
  • edit_post_path()

Which can in turn be used in your views/app like so:

<a href="{{ posts_path() }}">Posts</a>
<a href="{{ new_post_path() }}">Got to the post creation form</a>
<a href="{{ post_path($post) }}">Show the given post</a>
<a href="{{ edit_post_path($post) }}">Edit the given post</a>

<form method="POST" action="{{ posts_path() }}">
    <!-- Form to create a new post -->
</form>

<form method="POST" action="{{ post_path($post) }}">
    <!-- Form to edit the given post -->
</form>
redirect()->to(posts_path()); // Redirect to posts.index

The end goal is to leverage autocompletion in order to rapidly create path to our resources while not having to remember the exact route name.

Installation

You can install this package using composer

composer require paulhenri-l/laravel-route-helpers

Usage

Register your routes just as usual but give them names. On the next application boot the helpers will be generated and loaded.

Your route names should be one of the 7 restful names used by laravel (*.index, *.create, *.store, *.show, *.edit, *.update and *.destroy)

Your route names should only contain alpha numeric characters, dots and underscores any route that does not comply to this pattern will not get helpers generated for it.

Route::resource('comments', 'CommentsController');

This will generate these helpers:

comments_path();
comment_path();
create_comment_path();
edit_comment_path();

Nested resources

If you are nesting your resources the generated helpers will keep the nesting.

Route::resource('posts.comments', 'PostsCommentsController');
post_comments_path();
post_comment_path();
create_post_comment_path();
edit_post_comment_path();

Irregular names

If you are using irregular names for your resources, the correct singular form will be used for the helpers.

Route::resource('people', 'PeopleController');
people_path();
person_path();
create_person_path();
edit_person_path();

If this tool cannot guess the correct singular form for your route name you'll have to configure it: https://stackoverflow.com/questions/25646229/laravel-custom-inflection

Singular resources

If you have singular resources you cannot use the index function as it would create conflicts between the plural and singular helpers.

Route::resource('account', 'AccountController')->except('index');

Helpers works just like the route function

<?php

posts_path();
posts_path(['query' => 'param']);
posts_path(['query' => 'param'], true);
post_path($post);
post_comment_path([$post, $comment]);

Compile the helpers file manually

When you run your application using the local environement the helpers file will get recompiled whenever you change your routes file.

In any other environment the helpers file if not present will be generated on the first boot of your application.

You can also manually launch the generation of the helpers file by calling this artisan command.

php artisan route:compile-helpers

Contributing

If you have any questions about how to use this library feel free to open an issue.

If you think that the documentation or the code could be improved in any way open a PR and I'll happily review it!

paulhenri-l/laravel-route-helpers 适用场景与选型建议

paulhenri-l/laravel-route-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 9, 最近一次更新时间为 2019 年 12 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 paulhenri-l/laravel-route-helpers 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 9
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-27