pm-connect / laravel-param-converter
该包已被弃用且不再维护。未建议替代包。
在 Laravel 中工作的 Symfony 参数转换器。
1.1.6
2021-04-12 06:59 UTC
Requires
- php: ~7|~8
- doctrine/annotations: ~1
- illuminate/config: 5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0
- illuminate/container: 5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0
- illuminate/http: 5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0
- illuminate/routing: 5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0
- illuminate/support: 5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0|^8.0
- laravel/helpers: ^1.0
- sensio/framework-extra-bundle: ~3.0|~4.0|~5.0
README
使 Symfony 的 @ParamConverter
注解在 Laravel 5.3+ 中正常工作。
安装
使用 composer 安装。
composer require pm-connect/laravel-param-converter
设置
设置非常简单,只需将服务提供者添加到您的 app.php
配置文件中。
\PmConnect\LaravelParamConverter\ServiceProvider::class,
您还可以发布配置,以便添加自己的参数转换器。
php artisan vendor:publish --provider="\PmConnect\LaravelParamConverter\ServiceProvider"
注解注册加载器
根据您的设置,您可能需要设置 doctrines 的 AnnotationRegistry
类,并告知它如何自动加载类。
这可以通过将以下内容添加到服务提供者的 boot
方法中实现。
AnnotationRegistry::registerLoader('class_exists');
自定义转换器
有关如何创建自定义转换器的说明,请参阅 Symfony 文档 此处。
创建后,只需将类添加到 param-converter.php
配置文件中(只要您已发布配置!),然后就可以使用了。