Coder Social home page Coder Social logo

laravel-filesystem-url's Introduction

Laravel Filesystem Url

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version License

Provides a url generation service for your configured filesystems

This extends from laravel's filesystem config.

Installation

Composer

Simply add a dependency on benrowe/laravel-filesystem-url to your project's composer.json file if you use Composer to manage the dependencies of your project.

{
    "require-dev": {
         "benrowe/laravel-filesystem-url": "*"
    }
}

You can also install this package via the composer command:

composer require 'benrowe/laravel-filesystem-url=*'

Configuration

Service Provider + Facade

Once you've installed the package via composer, you need to register the provided service provider into laravel's provider stack.

Benrowe\Laravel\Url\ServiceProvider::class

Optionally you can register the facade:

'Url' => Benrowe\Laravel\Url\Facade::class,

Filesystem

The url builder uses the existing filesystem config, by extending it with some additional details.

Each disk thats configured can have a url key + associated settings

'local' => [
    'url' => [
        'base' => 'http://localhost',
        'baseSecure' => 'https://localhost', // optional
        'prefix' => 'assets', // optional
        'enabled' => true, //optional
    ]
]

Any filesystems that don't have the url key won't allow a url to be generated (throws an exception).

Usage

The primary method is the url($path, $disk = null, $secure = false)

It can be accessed in the following ways:

Facade

Url::url('path/to/file.jpg', 'local', $forceSecure);
// outputs as http://localhost/assets/path/to/file.jpg

Blade Directive

The package provides a convenient blade directive

@url('path/to/file.jpg', 'diskname')
// the blade directive will trap exceptions if the disk doesn't exist, or is not configured correctly.

Todo

  • Dynamic config - ability to get the config for s3 buckets based on other config, api, etc.

laravel-filesystem-url's People

Contributors

benrowe avatar tfbenrowe avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

benrowe-chuffed

laravel-filesystem-url's Issues

not compatible with Laravel 5.2

PHP Fatal error:  Call to undefined method Illuminate\Foundation\Application::bindShared() in vendor/benrowe/laravel-filesystem-url/src/ServiceProvider.php on line 47
PHP Stack trace:
PHP   1. {main}() artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() artisan:36
PHP   3. Illuminate\Foundation\Console\Kernel->bootstrap() vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:105
PHP   4. Illuminate\Foundation\Application->bootstrapWith() vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:219
PHP   5. Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap() vendor/laravel/framework/src/Illuminate/Foundation/Application.php:203
PHP   6. Illuminate\Foundation\Application->registerConfiguredProviders() vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:17
PHP   7. Illuminate\Foundation\ProviderRepository->load() vendor/laravel/framework/src/Illuminate/Foundation/Application.php:530
PHP   8. Illuminate\Foundation\Application->register() vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:74
PHP   9. Benrowe\Laravel\Url\ServiceProvider->register() vendor/laravel/framework/src/Illuminate/Foundation/Application.php:554


  [Symfony\Component\Debug\Exception\FatalErrorException]                   
  Call to undefined method Illuminate\Foundation\Application::bindShared()  

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.