PHP code example of antennaio / laravel-clyde

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

    

antennaio / laravel-clyde example snippets


use Antennaio\Clyde\ClydeUpload;

...

protected $uploads;

public function __construct(ClydeUpload $uploads)
{
    $this->uploads = $uploads;
}

public function upload(Request $request)
{
    if ($request->hasFile('image')) {
        $filename = $this->uploads->upload($request->file('image'));
    }
}

use Antennaio\Clyde\Facades\ClydeUpload;

...

public function upload(Request $request)
{
    if ($request->hasFile('image')) {
        $filename = ClydeUpload::upload($request->file('image'));
    }
}

ClydeUpload::upload($request->file('image'), $request->file('image')->getClientOriginalName());

ClydeUpload::upload($request->file('image'), function ($filename) {
    return 'profile-images'.DIRECTORY_SEPARATOR.$filename;
});

// returns true or false
ClydeUpload::exists('image.jpg');

ClydeUpload::delete('image.jpg');

<img src="{{ ClydeImage::url('56a1472beca5d.jpg') }}">

<img src="{{ ClydeImage::url('56a1472beca5d.jpg', ['w' => 800, 'h' => 600, 'fit' => 'crop']) }}">

// config/app.php
'provider' => [
    ...
    Antennaio\Clyde\ClydeServiceProvider::class,
    ...
];

// config/app.php
'aliases' => [
    ...
    'ClydeUpload' => Antennaio\Clyde\Facades\ClydeUpload::class,
    'ClydeImage' => Antennaio\Clyde\Facades\ClydeImage::class,
    ...
];

php artisan vendor:publish --provider="Antennaio\Clyde\ClydeServiceProvider"

// config/clyde.php
'presets' => [
    [
        'thumbnail' => [
            'w' => 100,
            'h' => 100,
            'fit' => 'crop'
        ]
    ]
],