PHPackages                             mlk9/dual-response - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mlk9/dual-response

ActiveLibrary[API Development](/categories/api)

mlk9/dual-response
==================

With this package, you can operate your API and web in a single controller. (Laravel 6&gt;=)

v1.0.3(3y ago)010MITPHPPHP &gt;=8.0.0

Since Mar 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mlk9/dual-response)[ Packagist](https://packagist.org/packages/mlk9/dual-response)[ RSS](/packages/mlk9-dual-response/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (3)Dependencies (1)Versions (7)Used By (0)

[![](https://repository-images.githubusercontent.com/468599015/5e6fd72f-0043-44c2-b968-12717fb40bf7)](https://repository-images.githubusercontent.com/468599015/5e6fd72f-0043-44c2-b968-12717fb40bf7)

Dual Response
=============

[](#dual-response)

With this package, you can operate your API and web in a single controller. (Laravel 6&gt;=)
--------------------------------------------------------------------------------------------

[](#with-this-package-you-can-operate-your-api-and-web-in-a-single-controller-laravel-6)

با این پکیج می توانید پاسخ های متفاوتی هنگامی که در روت api یا web می فرستید دریافت کنید.

Installation via composer
=========================

[](#installation-via-composer)

```
$ composer require mlk9/dual-response
```

then publish vendor

```
$ php artisan vendor:publish --tag=dual-response
```

Documents
=========

[](#documents)

Example for usage
-----------------

[](#example-for-usage)

response($webRoute //your response, $apiRoute //your json response)

BookController.php

```
use Mlk9\DualResponse\Facades\DualRes;
...

/**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
  $books = Book::paginate(40);
  return DualRes::response(view('book.index',compact('books')),['data' => $books]);
}

```

You can change default values with pass array

Default Response Api
--------------------

[](#default-response-api)

```
'status_result' => true,
'status_code' => 200,
'message' => __('dualres.request_successful'),
'errors' => null, //removes when don't have any errors
'data' => null, //removes when don't have any data
'current_time' => now()->timestamp,
```

Default Response When you pass to key `error`
---------------------------------------------

[](#default-response-when-you-pass-to-key-error)

In api routes :

```
'status_result' => false,
'status_code' => 400,
'message' => __('dualres.request_not_valid'),
'errors' => [//your errors],
'current_time' => now()->timestamp,
```

In web routes return your response.

Default Response When you pass to key `data`
--------------------------------------------

[](#default-response-when-you-pass-to-key-data)

In api routes :

```
'status_result' => true,
'status_code' => 200,
'message' => __('dualres.request_successful'),
'data' => [//your data],
'current_time' => now()->timestamp,
```

In web routes return your response.

Default Response When you pass null to key `data` (not found - 404)
-------------------------------------------------------------------

[](#default-response-when-you-pass-null-to-key-data-not-found---404)

In api routes :

```
'status_result' => false,
'status_code' => 404,
'message' => __('dualres.not_found'),
'current_time' => now()->timestamp,
```

In web routes abort 404 error.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~29 days

Recently: every ~36 days

Total

6

Last Release

1380d ago

Major Versions

v0.0.1 → v1.0.02022-03-11

v0.0.2 → v1.0.12022-03-12

PHP version history (2 changes)v0.0.1PHP &gt;=7.1.3

v1.0.1PHP &gt;=8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/47969c40b1af83e611719436b9e4f12fe5f4af154191dd73e2ccd921f4e8e114?d=identicon)[mlk9](/maintainers/mlk9)

---

Top Contributors

[![mlk9](https://avatars.githubusercontent.com/u/68475615?v=4)](https://github.com/mlk9 "mlk9 (41 commits)")

---

Tags

api-restcontrollerslaravellaravel-package

### Embed Badge

![Health badge](/badges/mlk9-dual-response/health.svg)

```
[![Health](https://phpackages.com/badges/mlk9-dual-response/health.svg)](https://phpackages.com/packages/mlk9-dual-response)
```

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
