Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Assets

A easy integration for handling files with Laravel.

Total downloads Monthly downloads Latest release Open issues License Star repository on GitHub Watch repository on GitHub Fork repository on GitHub Travis tests StyleCI Code Climate

📝 Introduction

One thing we at Nodes have been missing in Laravel is a fast easy file storage integration system.

The Storage facade made it easier, but we still need the option to upload from differente formats and store to a very specific folder structure, retrieve a path and be able to create urls to serve api and sites.

📦 Installation

To install this package you will need:

  • Laravel 5.1+
  • PHP 5.5.9+

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

"require": {
    "nodes/assets": "^1.1"
}

Or you can run the composer require command from your terminal.

composer require nodes/assets:^1.1

🔧 Setup

Setup service provider in config/app.php

Nodes\Assets\ServiceProvider::class

Setup alias in config/app.php

'Assets' => Nodes\Assets\Support\Facades\Assets::class

Publish config files

php artisan vendor:publish --provider="Nodes\Assets\ServiceProvider"

If you want to overwrite any existing config files use the --force parameter

php artisan vendor:publish --provider="Nodes\Assets\ServiceProvider" --force

S3 + ImgIX

In general.php config

'upload' => [
        'provider' => function () {
            $s3Config = config('filesystems.disks.s3');
            $awsS3Config = config('nodes.assets.provider.aws-s3');
            return new \Nodes\Assets\Upload\Providers\AmazonS3($awsS3Config, $s3Config);
        },
    ],   
    'url'    => [
        'provider' => function () {
            $imgIxConfig = config('nodes.assets.providers.imgix');

            return new \Nodes\Assets\Url\Providers\ImgIX($imgIxConfig);
        },
    ],

Make sure to have .env setup

AMAZON_BUCKET=bucket
AMAZON_KEY=key
AMAZON_SECRET=secret
AMAZON_REGION=eu-west-1
CDN_BASE_URL=nodes-cdn-development.imgix.net

Vapor Cloud

In general.php config

<?php

return [
   
    'upload' => [
        'provider' => function () {
            $s3Config = config('filesystems.disks.s3');
            $vaporCloudConfig = config('nodes.assets.providers.vapor-cloud');

            return new \Nodes\Assets\Upload\Providers\VaporCloud($s3Config, $vaporCloudConfig);
        },
    ],

    'url'    => [
        'provider' => function () {
            $vaporCloudConfig = config('nodes.assets.providers.vapor-cloud');

            return new \Nodes\Assets\Url\Providers\VaporCloud($vaporCloudConfig);
        },
    ],
];

Make sure to have .env setup

AMAZON_BUCKET=bucket
AMAZON_KEY=key
AMAZON_SECRET=secret
AMAZON_REGION=eu-west-1
AMAZON_CLOUDFRONT_URL={insert imgix base url here locally}
AMAZON_CLOUDFRONT_URL_DATA={insert imgix base url here locally}

Public Folder

Public folder method can resize images. To setup, you need Intervention image lib. To install run

composer require intervention/image

Then add the following to app.php

providers array

Intervention\Image\ImageServiceProvider::class

aliases array

'Image' => Intervention\Image\Facades\Image::class

finally run

php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"

Configure for public folder

Modify the configuration in config/nodes/assets/general.php

return [
    'upload' => [
        'provider' => function () {
            return new \Nodes\Assets\Upload\Providers\PublicFolder();
        },
    ],
    'url'    => [
        'provider' => function () {
            return new \Nodes\Assets\Url\Providers\PublicFolder();
        },
    ],
];

Usage

Global methods

function assets_add($file, $folder = null, UploadSettings $settings = null)
function assets_add_uploaded_file(UploadedFile $file, $folder = null, UploadSettings $settings = null)
function assets_add_url($url, $folder = null, UploadSettings $settings = null)
function assets_add_data_uri($dataUri, $folder = null, UploadSettings $settings = null)
function assets_get($path, UrlSettings $settings = null)

Facade methods

Assets::add($file, $folder = null, UploadSettings $settings = null)
Assets::addFromUploadedFile(UploadedFile $file, $folder = null, UploadSettings $settings = null)
Assets::addFromUrl($url, $folder = null, UploadSettings $settings = null)
Assets::addFromDataUri($dataUri, $folder = null, UploadSettings $settings = null)
Assets::get($path)

🏆 Credits

This package is developed and maintained by the PHP team at Nodes

Follow Nodes PHP on Twitter Tweet Nodes PHP

📄 License

This package is open-sourced software licensed under the MIT license

About

Assets made for Laravel. Support for multiple storage and CDN services.

Resources

License

Packages

No packages published

Languages

You can’t perform that action at this time.