atomicptr/laravel-github-storage

基于 GitHub 的 Laravel 文件系统

v0.1.1 2024-03-18 22:14 UTC

This package is auto-updated.

Last update: 2024-09-18 23:21:30 UTC


README

基于 GitHub 的 Laravel 文件系统,由 php-github-api 提供。

注意:请记住,GitHub 有速率限制,因此如果您需要大量文件操作,可能需要其他东西。

安装

composer require atomicptr/laravel-github-storage

将新的磁盘添加到您的 filesystems.php 配置文件中

'github' => [
    'driver' => 'github',
    'token' => env('GITHUB_STORAGE_TOKEN', ''),
    'username' => env('GITHUB_STORAGE_USERNAME', ''),
    'repository' => env('GITHUB_STORAGE_REPOSITORY', ''),
    'branch' => env('GITHUB_STORAGE_BRANCH', 'master'),
    'prefix' => env("GITHUB_STORAGE_PREFIX", ''),
],

同时将服务提供者添加到您的 bootstrap/providers.php 文件中

<?php

return [
    App\Providers\AppServiceProvider::class,
    // This line:
    Atomicptr\LaravelGithubStorage\GithubStorageServiceProvider::class,
];

用法

<?php

$storage = Storage::disk('github');

if (! $storage->exists('assets/image.jpg')) {
    $storage->put('assets/', $imageFileContent);
}

// See https://laravel.net.cn/docs/filesystem

许可

MIT