graham-campbell / gitlab
GitLab 是 Laravel 的 GitLab 桥接器
Requires
- php: ^7.4.15 || ^8.0.2
- graham-campbell/bounded-cache: ^1.2 || ^2.2
- graham-campbell/manager: ^5.1
- guzzlehttp/guzzle: ^7.8.1
- guzzlehttp/psr7: ^2.6.2
- illuminate/contracts: ^8.75 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^8.75 || ^9.0 || ^10.0 || ^11.0
- m4tthumphrey/php-gitlab-api: 11.13.*
- symfony/cache: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- graham-campbell/analyzer: ^4.1
- graham-campbell/testbench: ^6.1
- mockery/mockery: ^1.6.6
- phpunit/phpunit: ^9.6.17 || ^10.5.13
- 7.5.x-dev
- v7.5.0
- 7.4.x-dev
- v7.4.0
- 7.3.x-dev
- v7.3.0
- 7.2.x-dev
- v7.2.0
- 7.1.x-dev
- v7.1.0
- 7.0.x-dev
- v7.0.0
- 6.0.x-dev
- v6.0.0
- 5.6.x-dev
- v5.6.0
- 5.5.x-dev
- v5.5.0
- 5.4.x-dev
- v5.4.1
- v5.4.0
- 5.3.x-dev
- v5.3.0
- 5.2.x-dev
- v5.2.0
- 5.1.x-dev
- v5.1.0
- 5.0.x-dev
- v5.0.0
- 4.4.x-dev
- v4.4.0
- 4.3.x-dev
- v4.3.0
- 4.2.x-dev
- v4.2.0
- 4.1.x-dev
- v4.1.0
- 4.0.x-dev
- v4.0.0
- 3.3.x-dev
- v3.3.0
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.0
- 2.7.x-dev
- v2.7.0
- v2.6.1
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- 1.10.x-dev
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-logging
This package is auto-updated.
Last update: 2024-09-17 23:27:34 UTC
README
Laravel GitLab 由 Graham Campbell 创建并维护,是一个为 Laravel 提供的 GitLab PHP API 客户端 桥接器。它使用了我的 Laravel Manager 包。您可以自由查看变更日志、发布版本、安全策略、许可、行为准则和贡献指南。
安装
此版本需要 PHP 7.4-8.3 并支持 Laravel 8-11。
要获取最新版本,只需使用 Composer 引入项目。
$ composer require "graham-campbell/gitlab:^7.5"
安装完成后,如果您未使用自动包发现,则需要将 GrahamCampbell\GitLab\GitLabServiceProvider
服务提供者在您的 config/app.php
中注册。
您还可以选择性地对 facade 进行别名设置
'GitLab' => GrahamCampbell\GitLab\Facades\GitLab::class,
配置
Laravel GitLab 需要连接配置。
要开始,您需要发布所有供应商资产
$ php artisan vendor:publish
这将在您的应用程序中创建一个 config/gitlab.php
文件,您可以根据需要修改此配置。同时,请确保检查本包发布版本之间的原始配置文件的变化。
有两种配置选项
默认连接名称
此选项('default'
)用于指定以下连接中您希望用作所有工作的默认连接。当然,您可以使用管理器类同时使用多个连接。此设置的默认值为 'main'
。
GitLab 连接
此选项('connections'
)用于为您的应用程序设置每个连接。已包含示例配置,但您可以添加任意数量的连接。请注意,支持的四种认证方法为:"none"
、"oauth"
、"job_token"
和 "token"
。
HTTP 缓存
此选项('cache'
)用于为您的应用程序设置每个缓存配置。默认提供 "illuminate" 驱动。已包含示例配置。
用法
GitLabManager
这是最感兴趣的类。它绑定到'gitlab'
,可以通过Facades\GitLab
外观来访问。该类通过扩展AbstractManager
实现了ManagerInterface
。接口和抽象类都是我Laravel Manager包的一部分,因此您可能想查看该仓库中的文档以了解如何使用管理器类。请注意,返回的连接类始终是Gitlab\Client
的一个实例。
Facades\GitLab
此外观将动态地将静态方法调用传递给'gitlab'
对象,默认情况下是GitLabManager
类。
GitLabServiceProvider
此类不包含任何感兴趣的公开方法。应将此类添加到config/app.php
中的提供者数组中。此类将设置ioc绑定。
真实示例
在这里,您可以看到一个使用此包的示例有多么简单。开箱即用,默认适配器是main
。在您在配置文件中输入认证详情后,它就会正常工作
use GrahamCampbell\GitLab\Facades\GitLab; // you can alias this in config/app.php if you like GitLab::groups()->all(); // we're done here - how easy was that, it just works!
gitlab管理器将表现得像是一个Gitlab\Client
类。如果您想调用特定的连接,可以使用connection
方法
use GrahamCampbell\GitLab\Facades\GitLab; // writing this: GitLab::connection('main')->groups()->all(); // is identical to writing this: GitLab::groups()->all(); // and is also identical to writing this: GitLab::connection()->groups()->all(); // this is because the main connection is configured to be the default GitLab::getDefaultConnection(); // this will return main // we can change the default connection GitLab::setDefaultConnection('alternative'); // the default is now alternative
如果您像我一样喜欢使用依赖注入而不是外观,则可以轻松地以以下方式注入管理器
use GrahamCampbell\GitLab\GitLabManager; class Foo { private GitLabManager $gitlab; public function __construct(GitLabManager $gitlab) { $this->gitlab = $gitlab; } public function bar() { $this->gitlab->groups()->all(); } } app(Foo::class)->bar();
有关如何使用我们背后调用的Gitlab\Client
类的更多信息,请参阅https://github.com/GitLabPHP/Client/tree/11.13.0#general-api-usage和https://github.com/GrahamCampbell/Laravel-Manager#usage中的文档。
更多信息
此包中还有其他未在此处文档化的类。这是因为它们不是为了公开使用而设计的,而是由此包内部使用。
安全性
如果您在此包中发现安全漏洞,请向security@tidelift.com发送电子邮件。所有安全漏洞都将得到及时解决。您可以在此处查看我们的完整安全策略https://github.com/GrahamCampbell/Laravel-GitLab/security/policy。
许可
Laravel GitLab在MIT许可(MIT)下授权。
企业版
作为Tidelift订阅的一部分提供
graham-campbell/gitlab
的维护者以及成千上万的其他包维护者正在与Tidelift合作,为构建应用程序时使用的开源依赖项提供商业支持和维护。节省时间,降低风险,并提高代码健康度,同时支付您使用的确切依赖项的维护者。了解更多。