PHP code example of saeedvir / laravel-gist-storage

1. Go to this page and download the library: Download saeedvir/laravel-gist-storage library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

saeedvir / laravel-gist-storage example snippets


Storage::disk('gist')->put('file.txt', 'content');
$content = Storage::disk('gist')->get('file.txt');

'disks' => [
    'gist' => [
        'driver' => 'gist',
        'token' => env('GIST_TOKEN'),
        'gist_id' => env('GIST_ID'),  // Optional if auto_create is true
        'auto_create' => env('GIST_AUTO_CREATE', false),
        'public' => false,
        'description' => 'Laravel Gist Storage',
    ],
],

use Illuminate\Support\Facades\Storage;

// Write a file
Storage::disk('gist')->put('hello.txt', 'Hello from Laravel!');

// Read a file
$content = Storage::disk('gist')->get('hello.txt');

// Check if file exists
if (Storage::disk('gist')->exists('hello.txt')) {
    echo 'File exists!';
}

// Get file size
$size = Storage::disk('gist')->size('hello.txt');

// List all files
$files = Storage::disk('gist')->files();

// Delete a file
Storage::disk('gist')->delete('hello.txt');

// Get the auto-created gist ID
$gistId = Storage::disk('gist')->getAdapter()->getGistId();

use Livewire\Component;
use Livewire\WithFileUploads;

class FileUploader extends Component
{
    use WithFileUploads;
    
    public $file;
    
    public function save()
    {
        $this->validate(['file' => '

$data = ['users' => 1000, 'status' => 'active'];
Storage::disk('gist')->put('stats.json', json_encode($data));

// Retrieve and decode
$stats = json_decode(Storage::disk('gist')->get('stats.json'), true);

$stream = fopen('large-file.txt', 'r');
Storage::disk('gist')->writeStream('backup.txt', $stream);
fclose($stream);