2017 © Pedro Peláez

library common

Common usage for Multimedia Street Projects



Common usage for Multimedia Street Projects

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown



Latest Version on Packagist ![Software License][ico-license] ![Laravel][ico-laravel] Total Downloads, (*1)

Some boilerplate for most of the Multimedia Street projects., (*2)

Table of Contents

Included Packages

  • Image - PHP Image Manipulation
  • Image (Cache) - Caching extension for the Intervention Image Class
  • iSeed - Inverse seed generator
  • Whoops - PHP errors for cool kids
  • Clockwork - Chrome extension for PHP development
  • DOMPDF - DOMPDF Wrapper for Laravel 5
  • Excel - Laravel Excel v2.1.* for Laravel 5
  • CORS - CORS in Laravel 5


Via Composer

Require the multimedia-street/common package in your composer.json and update your dependencies., (*3)

``` bash $ composer require multimedia-street/common, (*4)

#### Add Service Provider Include the Service Provider to your `config/app.php` in providers array ``` php Mmstreet\Common\ServiceProvider::class,

Add Package Facades

Include Facades to your config/app.php in aliases array, (*5)

``` php 'Excel' => Maatwebsite\Excel\Facades\Excel::class, 'PDF' => Barryvdh\DomPDF\Facade::class, 'Image' => Intervention\Image\Facades\Image::class,, (*6)

#### Disabling CSRF protection for your API To use the CORS properly, [as stated in the documentation](https://github.com/barryvdh/laravel-cors#disabling-csrf-protection-for-your-api), in `App\Http\Middleware\VerifyCsrfToken`, add your routes to the exceptions: ``` php protected $except = [ 'api/*' ];

Post Install

Publish Packages Configurations

After the installation is completed, publish the vendor publish by running:, (*7)

``` bash php artisan vendor:publish, (*8)

#### Extend Exception Handler You can use the Exception handler specially for developing. This includes the [Whoops](https://github.com/filp/whoops). You can extend your `app/Exceptions/Handler.php` with `Mmstreet\Common\Exceptions\Handler`. Also add your uris using the `$corsUris` property to be used in [CORS](https://github.com/barryvdh/laravel-cors). See example below. ``` php namespace App\Exceptions; use Mmstreet\Common\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { protected $corsUris = [ 'api/*', // default 'auth/*', 'logout' ]; }

Response Trait

You can use the Mmstreet\Common\Traits\ResponseTrait to your App\Http\Controllers\Controller for easy returning response either Json or in View. See example below., (*9)

``` php namespace App\Http\Controllers;, (*10)

use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Mmstreet\Common\Traits\ResponseTrait;, (*11)

abstract class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests, ResponseTrait; }, (*12)

Example usage: ``` php namespace App\Http\Controllers; use App\Post; class PostController extends Controller { public function index() { $posts = Post::all(); if ($posts->isEmpty()) { // {The message}, {The data}, {status code}, {view name}, {response headers}, {Json callback} return $this->errorResponse('No Posts as of the moment', $posts, 404, 404, [], 'callback'); } return $this->successResponse('Successfully get all posts', $posts); } public function all() { $posts = Post::all(); if ($post->isEmpty()) { // You can also use Closure. return $this->errorResponse(function() { return response('No POSTS'); } } return $this->successResponse('Successfully get all posts', $posts); } }

Change log

Please see CHANGELOG for more information what has changed recently., (*13)


bash $ composer test, (*14)


Please see CONTRIBUTING and CONDUCT for details., (*15)


If you discover any security related issues, please email :author_email instead of using the issue tracker., (*16)



The MIT License (MIT). Please see License File for more information., (*17)

The Versions