PHPackages                             bertvthul/simplexhr - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. bertvthul/simplexhr

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bertvthul/simplexhr
===================

Simple xhr requests for Laravel

01.3kJavaScript

Since Sep 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bertvthul/simplexhr)[ Packagist](https://packagist.org/packages/bertvthul/simplexhr)[ RSS](/packages/bertvthul-simplexhr/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Make XHR Requests simple for Laravel
====================================

[](#make-xhr-requests-simple-for-laravel)

This package provides a way to make XHR requests simple for your Laravel app.

```
Order
```

In `data-simplexhr` in the example code, provide the controllername and the functionname to call. The `data-values` can be used to provide values in the request. When added to a form, all the values in the form are automatically send.

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

[](#installation)

You can install the package via composer:

```
composer require bertvthul/simplexhr
```

Add the service provider to the providers array in `config\app.php`;

```
Bertvthul\Simplexhr\SimplexhrServiceProvider::class,
```

And make sure the js is loaded by adding the following to your app.js;

```
require('./../../vendor/bertvthul/simplexhr/src/js/simplexhr.js');
```

Usage
-----

[](#usage)

In your blade files add `data-simplexhr="Controller.function"` to an element that is clickable or to a form. You'll need to provide a controller and a function, separated by a dot.

```
Order
```

Use the `data-values` to send variables in the request.

You can also add it to a form:

```

```

You can use hidden fields to provide extra data. The `onchange` means the form is submitted on any change. Remove `onchange` to only send the form on a submit.

In the function in your controller you could do the following;

```
public function addToCart(Request $request)
{
    session(['Product.cart.'.$request->input('object') => $request->input('count')]);
    $response = [
    	'msg' => 'Item added to your cart!',
        'html' => [
            '#book-btn'     => view('product.bookbutton')->render(),
            '#cart-items'   => view('cart.items')->render(),
        ],
    ];

    return response()->json($response);
}
```

The html response is handled by the package. The keys are the html elements to replace, the values the content to replace them with. You can also use :append or :prepend on the keys:

```
'html' => [
    '#blog-items:append' => view('blog.items')->withItems($items)->render(),
],
```

You can return whatever you like. The script calls the js function `xhrCustomCallback` when it exists. You can handle the other json response, like a message to show after the response:

```
$.xhrCustomCallback = function(data) {
	if ('msg' in data) {
		$('#toast').find('.toast-body').html(data.msg);
		$('#toast').toast('show');
	}
}
```

Config
------

[](#config)

Publish the config to make local changes:

```
php artisan vendor:publish --provider=Bertvthul\Simplexhr\SimplexhrServiceProvider
```

The config has the following settings:

- middleware: default is "web"

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/78cc1b2a38a163e940efcbceac68e6b90912f4652b475dc877fb8faf506d6914?d=identicon)[bertvthul](/maintainers/bertvthul)

---

Top Contributors

[![bertvthul](https://avatars.githubusercontent.com/u/1345057?v=4)](https://github.com/bertvthul "bertvthul (12 commits)")

### Embed Badge

![Health badge](/badges/bertvthul-simplexhr/health.svg)

```
[![Health](https://phpackages.com/badges/bertvthul-simplexhr/health.svg)](https://phpackages.com/packages/bertvthul-simplexhr)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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