Download the PHP package lovefc/laravel-route-notes without Composer

On this page you can find all versions of the php package lovefc/laravel-route-notes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-route-notes

laravel-route-notes

laravel框架扩展,原生注解生成路由 优点是直接生成路由文件,不在运行中解析路由,提升效率

中文介绍 | English

使用环境

如何安装

直接使用composer进行安装:

命令使用

-p 要生成的控制器目录名称,默认为app/Http/Controllers/

-f 生成的路由文件地址,默认为route/date("Y-m-d-His").php

如果不指定控制器目录,默认会扫描app/Http/Controllers/下的所有控制器文件进行生成

注解使用

首先要先在控制器类中标记开启注释功能,这样运行命令才会生成路由

上面是一个常规的控制器,必须在声明类的上面加上#[annotate('true')],这样才会生成注解。 可以在类的注解上声明全局的属性,比如:

#[annotate('true'),prefix('/user')]

这样下面方法注解就会自动带上前缀,当然你也可以在方法上改变这个前缀。

注解方法的属性跟路由使用基本上一样。

比如:

#[get('show'),prefix('/user'),middleware('myauth')]

上面声明的注解最终会生成以下的路由:

Route::prefix("/user")->post("all",[userController::class,"show"])->middleware("myauth");

除此之外,也支持where正则验证:

#[get('show/{name}'),where(['name'=>'[a-z]+'])]

又或者这样:

#[get('show/{name}'),where('name','[a-z]+')]

另外你可以在类注解上面声明全局的where属性: `

[annotate('true'),prefix('/user'),where(['name'=>'[a-z]+'])]`

重定向路由注解案例:

分组注解

laravel-route-notes扩展新增了分组路由支持,先看下面两个控制器

MyController控制器的类注解上加上了一个group(['prefix' => '/home','middleware'=>'auth'])

My2Controller控制器的方法show2上的注解上,同样也有个group(['prefix' => '/home','middleware'=>'auth'])

那么我们看一下最后生成的路由是什么样子的:

大家可以看到,对于相同命名的路由都会归类到一起。

关于路由分组,其实限制又有不少,因为如果命名了group(['属性'=>'属性值']),那么最好不要再去单独声明相同的属性了。

另外,如果你类注解声明了group(['prefix' => '/home'],那么方法注解里,在声明prefix('/home2'),将不会起作用,相同的属性,在分组里面声明并不会生效。

类注解属性

关于类注解和方法注解的属性名称如以下所示:

类注解的都是会自动注册到方法注解里面,也可以在方法注解里面覆盖

注解类属性(全局属性) 方法属性
prefix,name,where,domain,middleware,group prefix,name,where,domain,middleware,group,post,get,any,match,options,patch,view,redirect,put,delete

属性都要小写,并没有去判断大小写混用

LICENSE

Laravel-route-notes is released under the MIT license


All versions of laravel-route-notes with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0.0
laravel/framework Version >=9.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lovefc/laravel-route-notes contains the following files

Loading the files please wait ....