atomicptr / laravel-github-storage
A GitHub based filesystem for Laravel
v0.1.1
2024-03-18 22:14 UTC
Requires
Requires (Dev)
- laravel/pint: ^1.14
This package is auto-updated.
Last update: 2024-12-19 00:08:33 UTC
README
A GitHub based filesystem for Laravel, powered by php-github-api.
Note: Keep in mind that GitHub has a rate limit, so if you need a lot of file operations you might need something else.
Installation
composer require atomicptr/laravel-github-storage
Add a new disk to your filesystems.php configuration file
'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", ''), ],
also add the service provider to your bootstrap/providers.php file
<?php return [ App\Providers\AppServiceProvider::class, // This line: Atomicptr\LaravelGithubStorage\GithubStorageServiceProvider::class, ];
Usage
<?php $storage = Storage::disk('github'); if (! $storage->exists('assets/image.jpg')) { $storage->put('assets/', $imageFileContent); } // See https://laravel.com/docs/filesystem
License
MIT