whereof/laravel-filesystem-github

This package is abandoned and no longer maintained. The author suggests using the pkg6/flysystem-github package instead.

A GitHub storage filesystem for Laravel.

1.0.0 2022-03-19 13:04 UTC

This package is auto-updated.

Last update: 2023-03-07 07:58:35 UTC


README

Github storage for Laravel based on whereof/flysystem-github.

Requirement

  • PHP >= 7.2

Installation

composer require whereof/laravel-filesystem-github -vvv

Configuration

  1. After installing the library, register the whereof\laravel\filesystem\github\GithubStorageServiceProvider in your config/app.php file:
'providers' => [
    // Other service providers...
    whereof\laravel\filesystem\github\GithubStorageServiceProvider::class,
],
  1. Add a new disk to your config/filesystems.php config:
<?php

return [
    'disks' => [
        //...
        'github' => [
            'driver'     => 'github',
            'token'      => env('GITHUB_TOKEN', 'xxxxxxxxxxxxxxxx'),
            'username'   => env('GITHUB_USERNAME', 'xxxxxxxxxxxxxxxx'),
            'repository' => env('GITHUB_REPOSITORY', 'test'),
        ],
        //...
    ]
];

Usage

$disk = Storage::disk('qiniu');

// create a file
$disk->put('avatars/filename.jpg', $fileContents);

// check if a file exists
$exists = $disk->has('file.jpg');

// copy a file
$disk->copy('old/file1.jpg', 'new/file1.jpg');

// move a file
$disk->move('old/file1.jpg', 'new/file1.jpg');

// get file contents
$contents = $disk->read('folder/my_file.txt');

// get file url
$url = $disk->getUrl('folder/my_file.txt');

Full API documentation.