| Package Data | |
|---|---|
| Maintainer Username: | Fabrizio Cafolla | 
| Maintainer Contact: | developer@fabriziocafolla.com (Fabrizio Cafolla) | 
| Package Create Date: | 2019-06-18 | 
| Package Last Update: | 2019-08-24 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-11-03 15:19:42 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 92 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 0 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
Composer
composer require kosmosx/laravel-response
Laravel / Lumen register providers
Kosmosx\Response\Laravel\ResponseServiceProvider
Register handler Execptions (LaravelHandler or LumenHandler)
$this->app->singleton(
    \Illuminate\Contracts\Debug\ExceptionHandler::class,
    \Kosmosx\Response\Laravel\Exceptions\.....::class
);
Use
use Kosmosx\Response\RestResponse;
use RestResponse; //Facade alias 
use FactoryResponse; //Or use factory class
Same PC hardware (RAM: 16GB (2x8 GB) DDR4 2133 MHz, CPU: Intel Core i5 7400 Quad Core & 4 Thread 3.0GHz)
Illuminate/Response
Response weight 4.26Mb in 158~161ms
$app = array();
for ($x = 0; $x <= 1000; $x++) {
    $app[$x] = new JsonResponse(array('data'=>[true,false], "message" => 'Microservice Lumen work', "state" => "OK"));
}
return var_dump($app);
Kosmosx/Response
Response weight 3.6Mb in 148~151ms
$app = array();
for ($x = 0; $x <= 1000; $x++) {
    $app[$x] = new RestResponse(array('data'=>[true,false], "message" => 'Microservice Lumen work', "state" => "OK"));
}
return var_dump($app);
Response weight 3.6Mb in 220~223ms
$app = array();
for ($x = 0; $x <= 1000; $x++) {
    $app[$x] = $this->response->success()
        ->withMessage('Microservice Lumen work')
        ->withData(true)
        ->withData(false)
        ->withState();
}
return var_dump($app);
Results
Kosmosx/Response it is 15.50% smaller than Illuminate
Kosmosx/Response it is 6.3% faster than Illuminate (if use constructor)
en: documentation
it: documentazione
If you find a bug or want to contribute, write to developer@fabriziocafolla.com