PHPackages                             silvertipsoftware/auto-responds - 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. [Templating &amp; Views](/categories/templating)
4. /
5. silvertipsoftware/auto-responds

ActiveLibrary[Templating &amp; Views](/categories/templating)

silvertipsoftware/auto-responds
===============================

Opinionated view responses for Laravel

v0.1(5y ago)07MITPHP

Since Oct 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/SilvertipSoftware/auto-responds)[ Packagist](https://packagist.org/packages/silvertipsoftware/auto-responds)[ Docs](https://github.com/SilvertipSoftware/auto-responds)[ RSS](/packages/silvertipsoftware-auto-responds/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

AutoResponds
============

[](#autoresponds)

Opinionated response discovery for Laravel.

About
-----

[](#about)

Rather than specifically return views or objects from each of your controller methods, the `AutoResponds` trait determines and automatically creates responses based on the route, controller, and desired response format. In most cases, this means your controller methods become query-only.

Importantly, however, returns from controller methods are handled the same way they would be natively (mostly), so if granular control is needed, you can have that too.

Caveats
-------

[](#caveats)

- you have to return the correct namespace in the `controllerRootNamespace()` function of your controller. We provide the correct default, but you may have to change it, depending on your configuration. Laravel does not seem to provide access to this parameter.
- this only works for controller-based routes.

Installation
------------

[](#installation)

- Require the `silvertipsoftware/auto-responds` package in your `composer.json` and update your dependencies:

```
$ composer require silvertipsoftware/auto-responds
```

- Add `use AutoResponds` in your base `Controller`, or anywhere you want it.
- If you're using a non-standard setup, implement `controllerRootNamespace()` in the same controller.

View-Based Responses and Naming
-------------------------------

[](#view-based-responses-and-naming)

By default, views are discovered based on the controller action being called, and prefixed by any intermediate namespaces. For example, for HTML format, based on the default root controller namespace:

Controller Action......Maps to viewUsersController@showusers.showAccountsController@indexaccounts.indexAdmin\\InvitesController@newadmin.invites.newIf you're using Javascript request/response (eg. UJS, or some other on-the-fly-js library):

Controller Action......Maps to viewUsersController@editusers.js.editAccountsController@updateaccounts.js.updateAdmin\\InvitesController@newadmin.invites.js.newUsing the Route Name
--------------------

[](#using-the-route-name)

If you prefer, view names can be based off of the route name (defined using `'as'` in your routes file, for example). To your base controller, add:

```
    protected $useActionForViewName = false;
```

Now a route named `users.index` will map to a view called `users.index` (or `users.js.index` for the JS format).

Overriding Detection
--------------------

[](#overriding-detection)

In some cases, you may want to use a specific view for a specific action. In that case, set the `viewNameForResponse`property in your action. For example:

```
    public function index($request) {
        if (!\Auth::user()) {
            $this->viewNameForResponse = 'need_to_login';
        }
    }
```

You may also return any standard response from Laravel, from strings, to views, to model instances. The `AutoResponds`functionality is bypassed in these cases.

The exception is for Javascript formats, where a specific view response is used. By default, `AutoResponds` looks for a view called `js_redirect`, and passes it the target location for the redirect as a `redirectToUrl` variable. Typically, this just looks like:

```
window.location.href = '{{ $redirectToUrl }}';
```

but you're free to do whatever you need to.

Format-Specific Notes
---------------------

[](#format-specific-notes)

### Javascript

[](#javascript)

Javascript responses are all automatically wrapped as a Immediately Invoked Function Expression (or Self Executing Anonymous Function) to encapsulate variables, etc. Your js views do not need to include this.

### JSON

[](#json)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

2081d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/181c1808871c0b143792e2a5db97971850429ff960d46ffa821a954a9aeed745?d=identicon)[info@silvertipsoftware.com](/maintainers/info@silvertipsoftware.com)

---

Top Contributors

[![aksonnic](https://avatars.githubusercontent.com/u/1252956?v=4)](https://github.com/aksonnic "aksonnic (3 commits)")

---

Tags

responselaravelview

### Embed Badge

![Health badge](/badges/silvertipsoftware-auto-responds/health.svg)

```
[![Health](https://phpackages.com/badges/silvertipsoftware-auto-responds/health.svg)](https://phpackages.com/packages/silvertipsoftware-auto-responds)
```

###  Alternatives

[itstructure/laravel-grid-view

Grid view for laravel framework

2448.7k4](/packages/itstructure-laravel-grid-view)[delatbabel/viewpages

Support rendering/view of Laravel pages and templates from a database.

121.4k](/packages/delatbabel-viewpages)

PHPackages © 2026

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