whereof / laravel-filesystem-github
A GitHub storage filesystem for Laravel.
Installs: 1 767
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- whereof/flysystem-github: ^1.0
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
- After installing the library, register the
whereof\laravel\filesystem\github\GithubStorageServiceProvider
in yourconfig/app.php
file:
'providers' => [
// Other service providers...
whereof\laravel\filesystem\github\GithubStorageServiceProvider::class,
],
- 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');