Download the PHP package linfly/annotation without Composer

On this page you can find all versions of the php package linfly/annotation. 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 annotation

webman annotation 注解插件

本插件使用 doctrine/annotation 对注释解析

PHP版本要求 >= 8.0

支持注释注解 和 PHP8注解方式

目前支持的功能

安装

配置

配置文件路径:/plugin/linfly/annotation/annotation.php

使用

注解路由

支持的注解方式: @Route @GetRoute @PostRoute @PutRoute @DeleteRoute @PatchRoute @HeadRoute @OptionsRoute

@Route注解外,其他注解都是v1.0.5版本开始支持

@Route注解外,其他注解都是@Route的别名,使用方式一致

注解中间件

注解验证器

验证器注解需要配合验证器扩展包使用,目前只支持 think-validate 验证器验证成功会继续执行,验证失败则调用配置的 fail_handle 方法终止执行

绑定原生路由

绑定Webman原生路由后,在不使用注解路由的情况下,也能使用注解中间件、验证器等功能

注解类 @BindRoute

绑定原生路由 v1.0.7 版本开始支持

注解继承

注解继承可以让你的注解更加简洁,减少重复代码

参数说明

使用例子

父类:UserAuthController.php

子类:TestController.php

根据命名空间注解

根据命名空间的名称自动设置控制器路径,配合"注解继承"来使用更方便。

注解类 @NamespaceController

绑定原生路由 v1.0.7 版本开始支持

参数说明

使用例子

依赖注入

配置

修改config/container.php文件,修改后内容如下:

参数说明

使用例子

需要注入的类:TestService.php

调用类:TestController.php

实验性功能

1. 循环依赖

依赖注入支持循环依赖,即A依赖B,B依赖A,但是需要注意的是,依赖注入的类必须是单例模式,否则会报错。

构造函数支持注入自身实例,注入自身的实例是单例实例,不会重复创建。

自定义注解类

第一步:创建注解类

注解类需要继承 LinFly\Annotation\Annotation\Annotation

注解类需要声明 @Annotation@Target#[\Attribute()] 注解

测试代码:annotation-example

控制器注解类

方法注解类

第二步:使用注解类

第三步:获取注解类的参数

方法一:通过 LinFly\Annotation\Annotation\Annotation::yieldParseClassAnnotations() 方法获取

方法二:通过 AnnotationHandle 获取

程序启动时会扫描所有的注解类,扫描完成后会调用已绑定注解类的回调事件

  1. 新建Handle类 注意:Handle类需要继承 LinFly\Annotation\Handle\Handle

  2. 新建Bootstrap类 参考资料:webman业务初始化

  3. 配置随进程启动

打开config/bootstrap.phpCreateAnnotationHandle类加入到启动项中。

更新日志

v1.0.9

  1. 新增根据命名空间自动设置控制器路径的注解

v1.0.8

  1. 新增绑定原生路由注解支持绑定路由参数和路由命名

v1.0.7

  1. 新增依赖注入功能
  2. 新增绑定原生路由注解

v1.0.6

  1. 修复部署模式调用STDOUT报错。

v1.0.5

  1. 修正注解路由请求方法大小写问题。
  2. 新增注解继承功能。
  3. 新增 @GetRoute @PostRoute 等注解路由类。
  4. 新增 include_paths 注解扫描路径参数支持通配符。
  5. 新增支持扫描单个文件中写入多个类的文件。

v1.0.4

  1. 修复注解路由可选参数解析问题。

v1.0.3

  1. 修复中间件注解和验证器注解执行顺序问题。
  2. 新增中间件only和except参数, 用于指定中间件只在指定的方法执行。
  3. 新增在控制器上使用验证器注解。

All versions of annotation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
php-di/php-di Version ^7.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 linfly/annotation contains the following files

Loading the files please wait ....