1. Go to this page and download the library: Download multimedia-street/common library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
multimedia-street / common example snippets
php
Mmstreet\Common\ServiceProvider::class,
php
protected $except = [
'api/*'
];
bash
php artisan vendor:publish
php
namespace App\Exceptions;
use Mmstreet\Common\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
protected $corsUris = [
'api/*', // default
'auth/*',
'logout'
];
}
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);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.