1. Go to this page and download the library: Download nekoos/lumen-response-trick 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/ */
nekoos / lumen-response-trick example snippets
use Illuminate\Http\Response;
class MyOverrideResponse extends Response { ... }
use Illuminate\Http\JsonResponse;
class MyOverrideJsonResponse extends Response { ... }
# path: bootstrap/app
use NekoOs\Override\Laravel\Lumen\Http\ResponseFactory;
ResponseFactory::use(MyOverrideResponse::class);
ResponseFactory::use(MyOverrideJsonResponse::class);
response('common messaje') # return instance of MyOverrideResponse
response()->json('common messaje') # return instance of MyOverrideJsonResponse
# path: app/Providers/MyResponseServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Laravel\Lumen\Http\ResponseFactory;
use MyOverrideResponse;
class MyResponseServiceProvider extends ServiceProvider
{
/**
* register()
*/
public function register()
{
$view = $this->app->make('view');
$this->app->singleton(ResponseFactory::class, function () use ($view) {
return new MyOverrideResponse($view);
});
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.