Giter Site home page Giter Site logo

cabinet's Introduction

Cabinet - Laravel 4 File Upload Package (Version 0.1.6)

Cabinet is a file upload package for Laravel 4.

Cabinet Poster

Cabinet is a package that allows easy upload of files and images.

Features

  • File Upload
  • Image Processing for display
  • Configurable Image options
  • Route, Controller, Model cli generators
  • Configurable

Quick start

Required setup

In the require key of composer.json file add the following

"andrew13/cabinet": "0.1.x"

Run the Composer update command

$ composer update

In your config/app.php add 'Andrew13\Cabinet\CabinetServiceProvider' to the end of the $providers array

'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'Andrew13\Cabinet\CabinetServiceProvider',

),

At the end of config/app.php add 'Cabinet' => 'Andrew13\Cabinet\CabinetFacade' to the $aliases array

'aliases' => array(

    'App'        => 'Illuminate\Support\Facades\App',
    'Artisan'    => 'Illuminate\Support\Facades\Artisan',
    ...
    'Cabinet'    => 'Andrew13\Cabinet\CabinetFacade',

),

Upload model

Now generate the Cabinet migration:

$ php artisan cabinet:migration

It will generate the <timestamp>_cabinet_setup_uploads_table.php migration. You may now run it with the artisan migrate command:

$ php artisan migrate

It will setup a table containing filename, directory_path, extension, user_id and deleted_at fields, which are the default fields needed for Cabinet use.

Create an upload model in app/models/Upload.php:

<?php

use Andrew13\Cabinet\CabinetUpload;

class Upload extends CabinetUpload {

    protected $softDelete = true;

}

CabinetUpload class will take care of all the default upload behavior. This can be extended in your Upload model.

Dump the default assessors

Least, you can dump a default controller and the default routes for Cabinet.

$ php artisan cabinet:controller
$ php artisan cabinet:routes

Don't forget to dump composer autoload

$ composer dump-autoload

Publish public assets

In order to use the js/css/images you'll need to publish the assets.

php artisan asset:publish andrew13/cabinet

And you are ready to go. Access http://localhost/upload to upload a file. It is highly suggested to put some auth protection on the uploads.

Advanced

Using custom table / model name

To change the controller name when dumping the default controller template you can use the --name option.

$ php artisan cabinet:controller --name Uploader

Will result in UploaderController

Then, when dumping the routes, you should use the --controller option to match the existing controller.

$ php artisan confide:routes --controller Uploader

Using custom form for upload and other configuration options.

First, publish the config files:

$ php artisan config:publish andrew13/cabinet

Then edit the view names in app/config/packages/andrew13/confide/config.php.

Further, you can change the location of the uploads, type of upload files, and many more options!

RESTful controller

If you want to generate a RESTful controller you can use the additional --restful or -r option.

$ php artisan cabinet:controller --restful

Will result in a RESTful controller

Then, when dumping the routes, you should use the --restful option to match the existing controller.

$ php artisan cabinet:routes --restful

License

This is free software distributed under the terms of the MIT license

Special Thanks

Generator code uses code from the Confide package. It is then modified to fit this application. Thanks goes out to @Zizaco for that code.

Workbench tutorial by Jason Lewis was excellent in getting up and running with workbench.

Image upload tutorial from Phil Sturgeon which inspired me to create this package.

Additional information

Any questions, feel free to contact me.

cabinet's People

Contributors

andrew13 avatar

Watchers

 avatar

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.