Giter Site home page Giter Site logo

laravel4-storage's Introduction

laravel4-storage

A filesystem abstraction library for Laravel 4

Author StyleCI Software License Packagist Version Total Downloads

This package brings a filesystem abstraction layer to Laravel 4. This is an organic feature of Laravel 5 which uses the flysystem package under the hood. Please note that this is not a like-for-like version of the Laravel 5 package and that there may be suttle differences in configuration and method names. We're looking to make this package identical in a future major version to make the Laravel 4 -> 5 upgrade less painful.

Supported Adapters

  • Local
  • Rackspace (Cloud Files)
  • Amazon Web Services (S3)
  • Google Cloud

Installation

composer require superbalist/laravel4-storage

Register the service provider in app.php

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

Register the facade in app.php

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

Create a storage.php config file.

<?php

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]]',
        ),
    ),

);

Create a services.php config file.

<?php

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,
    ),

);

Usage

Please see http://flysystem.thephpleague.com/api/ for full documentation on the core API.

All functions provided by the core API are available behind the Storage facade in Laravel.

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');

laravel4-storage's People

Contributors

johnmarkmassey avatar matthewgoslett avatar shad0wfir3 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel4-storage's Issues

Google_Auth_AssertionCredentials class not found

Getting this error after installation on Laravel 4.2 when using gcloud storage:

PHP Fatal error: Uncaught Error: Class 'Google_Auth_AssertionCredentials' not found in /[...]/vendor/superbalist/laravel4-storage/src/StorageAdapterFactory.php:75
Stack trace:
#0 /[...]/vendor/superbalist/laravel4-storage/src/StorageAdapterFactory.php(103): Superbalist\Storage\StorageAdapterFactory::make('gcloud')
#1 /[...]/vendor/superbalist/laravel4-storage/src/StorageServiceProvider.php(16): Superbalist\Storage\StorageAdapterFactory::makeCached('gcloud')
#2 /[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php(501): Superbalist\Storage\StorageServiceProvider->Superbalist\Storage{closure}(Object(Illuminate\Foundation\Application), Array)
#3 /[...]/vendor/laravel/framework/src/Illuminate/Container/Container.php(428): Illuminate\Container\Container->build(Object(Closure), Array)
#4 /[...]/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(462): Illuminate\Container\Con in /Users/lppapillon/dev/proxi/vendor/superbalist/laravel4-storage/src/StorageAdapterFactory.php on line 75

This is an update made on the google/auth package, I have tracked back to this issue here:
Superbalist/flysystem-google-cloud-storage#26
However this doesn't work in the laravel4-storage version. Could it be made to use a newer version of flysystem-google-storage, or an older version of google/auth perhaps?
Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.