laragear/meta
Composer 安装命令:
composer require laragear/meta
包简介
A Laravel Package helper for Laravel Packages
README 文档
README
A Laravel Package helper for Laravel Packages.
public function boot() { $this->withPublishableMigrations(__DIR__.'/../migrations'); $this->withSchedule(fn($schedule) => $schedule->command('inspire')->hourly()); }
Become a sponsor
Your support allows me to keep this package free, up-to-date and maintainable. Alternatively, you can spread the word in social media.
Requirements
- PHP 8.3 or later
- Laravel 12 or later.
Installation
Require this package into your project using Composer:
composer require laragear/meta
Package testers
You may additionally install testing helpers for your package. These should be installed in your require-dev arm of your composer so these are not shipped in the production version of your package.
composer require --dev laragear/meta-testing
Discoverer
The Discover class is a builder that allows discovering classes under a given path. It contains various fluent methods to filter the classes to discover, like methods, properties, interfaces and traits, among others.
composer require laragear/discover
Middleware declaration
When using withMiddleware() you will receive a MiddlewareDeclaration object with convenient methods to register the middleware globally or inside a group, set it as first/last in the global priority stack, and register an alias for it.
public function boot() { $declaration = $this->withMiddleware(OnlyAdults::class); // Make it a shared instance. $declaration->shared(); // Set an alias $declaration->as('adults'); // Puts it inside a middleware group. $declaration->inGroup('web'); // Sets the middleware in the global stack. $declaration->globally(); // Makes the middleware run first or last in the priority stack. $declaration->first(); $declaration->last(); }
Builder extender
The ExtendsBuilder trait allows a Global Scope to extend the instance of the Eloquent Builder with new methods. Simply start your builder methods extend, no matter wich visibility scope or if the method is static or not.
use Illuminate\Database\Eloquent\Scope; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; use Laragear\Meta\Database\Eloquent\ExtendsBuilder; class Cars implements Scope { use ExtendsBuilder; public function apply(Builder $builder, Model $model) { // ... } private function extendWhereAvailable($builder) { return $builder->where('available_at', '>', now()); } protected static function extendWhereColor($builder, string $color) { return $builder->where('base_color', $color); } }
Tip
If you need the model being queried, you can always use getModel() over the Eloquent Builder instance.
Command Helpers
This meta-package includes the WithEnvironmentFile helper trait to modify the environment file keys and values.
use Illuminate\Console\Command; use Laragear\Meta\Console\Commands\WithEnvironmentFile; class AddServiceKey extends Command { use WithEnvironmentFile; public function handle() { // ... $this->putEnvKey('AWESOME_SERVICE', $this->argument('service_key')) } }
Attribute extractor
The package contains the Attr helper that receives a target class, object, function, and allows to retrieve all or one attribute. Better yet, you can directly call a method or retrieve an attribute property.
use Laragear\Meta\Attr;use Vendor\Package\Attributes\MyCustomAttribute; #[MyCustomAttribute(color: 'blue')] class Car { // } $car = new Car; echo Attr::of($car)->get(MyCustomAttribute::class, 'color'); // "blue"
Laravel Octane compatibility
- There are no singletons using a stale application instance.
- There are no singletons using a stale config instance.
- There are no singletons using a stale request instance.
ExtendsBuilderonly initializes its static property once per Scope.
There should be no problems using this package with Laravel Octane.
Security
If you discover any security related issues, please email darkghosthunter@gmail.com instead of using the issue tracker.
License
This specific package version is licensed under the terms of the MIT License, at time of publishing.
Laravel is a Trademark of Taylor Otwell. Copyright © 2011-2025 Laravel LLC.
laragear/meta 适用场景与选型建议
laragear/meta 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 948.49k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2022 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laragear/meta 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laragear/meta 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laragear/meta 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple ASCII output of array data
Alfabank REST API integration
Package for view storage in laravel
User Approval Laravel Package
PHPUnit Pretty Result Printer
统计信息
- 总下载量: 948.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 16
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-22
