PHP code example of superbalist / laravel4-storage

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

    

superbalist / laravel4-storage example snippets


'providers' => array(
    'Superbalist\Storage\StorageServiceProvider',
)

'aliases' => array(
    'Storage' => 'Superbalist\Storage\StorageFacade',
)



return array(

    /*
    |--------------------------------------------------------------------------
    | Default Connection
    |--------------------------------------------------------------------------
    |
    | The default file system connection to use.
    |
    | A non-default connection can also be specified by using \Storage::connection('name')->put(...)
    |
    */

    'default' => 'local',

    /*
    |--------------------------------------------------------------------------
    | Connections
    |--------------------------------------------------------------------------
    |
    | The various connection configs.
    |
    */

    'connections' => array(
        'local' => array(
            'adapter' => 'local',
            'root_path' => storage_path(),
            'public_url_base' => '[[http://a.public.url.to.your.service/storage]]',
        ),

        'rackspace' => array(
            'adapter' => 'rackspace',
            'store' => 'cloudFiles',
            'region' => 'LON',
            'container' => '[[insert your cdn container name]]',
        ),

        'gcloud' => array(
            'adapter' => 'gcloud',
            'bucket' => '[[insert your bucket name]]',
        ),
    ),

);



return array(

    /*
    |--------------------------------------------------------------------------
    | AWS
    |--------------------------------------------------------------------------
    |
    */

    'aws' => array(
        'access_key' => '[[your aws key]]',
        'secret_key' => '[[your aws secret]]',
        'region' => '[[your aws region]]',
    ),

    /*
    |--------------------------------------------------------------------------
    | Google Cloud
    |--------------------------------------------------------------------------
    |
    */

    'google_cloud' => array(
        'service_account' => '[[your service account]',
        'key_file' => '[[path to the p12 key file]]',
        'secret' => '[[your secret]]',
        'developer_key' => '[[your developer key]]',
    ),

    /*
    |--------------------------------------------------------------------------
    | Rackspace
    |--------------------------------------------------------------------------
    |
    */

    'rackspace' => array(
        'username' => '[[your username]]',
        'tenant_name' => '[[your tenant name]]',
        'api_key' => '[[your api key]]',
        'api_endpoint' => \OpenCloud\Rackspace::UK_IDENTITY_ENDPOINT,
    ),

);

use Storage;

// write to a file
Storage::write('path/to/file.txt', 'contents');

// update a file
Storage::update('path/to/file.txt', 'new contents');

// read a file
$contents = Storage::read('path/to/file.txt');

// check if a file exists
$exists = Storage::has('path/to/file.txt');

// delete a file
Storage::delete('path/to/file.txt');

// rename a file
Storage::rename('filename.txt', 'newname.txt');

// copy a file
Storage::copy('filename.txt', 'duplicate.txt');

// specify the storage connection to use
$contents = Storage::connection('rackspace')->listContents();

// get a public url to a file
// this is currently only supported by the local and google cloud adapters
$url = Storage::getPublicUrl('path/to/file.txt');