PHP code example of henrotaym / laravel-temporary-files

1. Go to this page and download the library: Download henrotaym/laravel-temporary-files 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/ */

    

henrotaym / laravel-temporary-files example snippets


return [
];

    use Henrotaym\LaravelTemporaryFiles\Facades\LaravelTemporaryFiles;
    use Henrotaym\LaravelTemporaryFiles\Factories\Services\TemporaryFiles\TemporaryFileServiceFactory;
    use Henrotaym\LaravelTemporaryFiles\Services\TemporaryFiles\TemporaryFileService;

    // SERVICE CREATION

    // USING FACTORY
    $service = app(TemporaryFileServiceFactory::class)->create();
    // USING FACADE
    $service = LaravelTemporaryFiles::factory()->create();

    // STORE SERVICE
    $content = 'test';
    $contentPath = $service->store()->content($content, 'txt');
    $base64ContentPath = $service->store()->base64(base64_encode($content), 'txt');
    $urlContentPath = $service->store()->url('https://avatars.githubusercontent.com/u/24230736?v=4');

    // PATH SERVICE
    $filePath = $service->path()->name('test.php');
    $filePath = $service->path()->extension('php');

    // DELETE SERVICE
    $service->delete()->directory();
bash
php artisan laravel-temporary-files:install
bash
php artisan vendor:publish --tag="laravel-temporary-files-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-temporary-files-config"
bash
php artisan vendor:publish --tag="laravel-temporary-files-views"