annotation/larscan
Composer 安装命令:
composer require annotation/larscan
包简介
Implement a Laravel scanner that can scan by namespace or path and instantiate classes annotated with specific annotations based on PHP 8.0's annotation feature.
README 文档
README
Implement a Laravel scanner that can scan by namespace or path and instantiate classes annotated with specific annotations based on PHP 8.0's annotation feature.
Installation
You can install the package via Composer:
composer require annotation/larscan
Usage
Instantiation method
use Annotation\Scannable\Attributes\Scan; use Annotation\Scannable\Attributes\ScanFile; use Annotation\Scannable\Attributes\ScanNamespace; use Annotation\Scannable\Attributes\ScanPath; use Annotation\Scannable\Attributes\ScanPackageNamespace; public function scan(): void { // ScanPackageNamespace $scan = new ScanPackageNamespace(['GuzzleHttp']); // ScanNamespace $scan = new ScanNamespace(['Illuminate\Support\Arr']); $scan = new ScanNamespace(['Illuminate\Support*']); // ScanPath $scan = new ScanPath(__DIR__.'/../Http/'); $scan = new ScanPath(new \RecursiveDirectoryIterator(__DIR__.'/../Http/Controllers')); // ScanFile $scan = new ScanFile(__FILE__); $scan = new ScanFile(new \SplFileInfo(__DIR__ . '/AppServiceProvider.php')); // Scan $scan = new Scan('Illuminate\Support\Arr'); $scan = new Scan(['Illuminate\Support\Arr']); $scan = new Scan(new \ReflectionClass('Illuminate\Support\Arr')); }
Annotation method
Only supports Laravel framework
use Annotation\Scannable\Attributes\Scan; use Annotation\Scannable\Attributes\ScanFile; use Annotation\Scannable\Attributes\ScanNamespace; use Annotation\Scannable\Attributes\ScanPath; use Annotation\Scannable\Attributes\ScanPackageNamespace; use Rfc\Scannable\Contracts\Scannable; #[ScanPackageNamespace(['GuzzleHttp'])] #[ScanNamespace(['Illuminate\Support\Arr'])] #[ScanNamespace(['Illuminate\Support*'])] #[ScanPath(__DIR__.'/../Http/')] #[ScanPath(new \RecursiveDirectoryIterator(__DIR__.'/../Http/Controllers'))] #[ScanFile(__FILE__)] #[ScanFile(new \SplFileInfo(__DIR__ . '/AppServiceProvider.php'))] #[Scan('Illuminate\Support\Arr')] #[Scan(['Illuminate\Support\Arr'])] #[Scan(new \ReflectionClass('Illuminate\Support\Arr'))] class AppServiceProvider extends ServiceProvider implements Scannable { // }
use Annotation\Scannable\Attributes\ScanNamespace; use Annotation\Scannable\Attributes\ScanPackageNamespace; use Annotation\Scannable\Contracts\Scanner; use Annotation\Scannable\Facades\Scan; public function scan(Scanner $scan): void { $namespace = $scan->using(ScanPackageNamespace::class, function (ScanPackageNamespace $scanNamespace) { return $scanNamespace->getReflectionClass(); }); //dump($namespace); $namespace = Scan::using(ScanNamespace::class, function (ScanNamespace $namespace) { return $namespace->getNamespace(); }); //dump($namespace); }
License
Nacosvel Contracts is made available under the MIT License (MIT). Please see License File for more information.
annotation/larscan 适用场景与选型建议
annotation/larscan 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「annotation」 「attributes」 「laravel」 「scanner」 「scan」 「Scannable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 annotation/larscan 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 annotation/larscan 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 annotation/larscan 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle to add arbitrary metadata to classes and their constants by annotation
A library that allows you to easily use the PHP-VCR library in your PHPUnit tests.
This Package provides some usefully console features like the attribute syntax for arguments and options, validation, auto ask and casting.
The last validation library you will ever need!
A PHPDoc docblock interpreter that is simple, easy to use, and provides Attribute alternatives.
Module with SP files for attribute_check
统计信息
- 总下载量: 2.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-15