Download the PHP package webstronauts/unpoly without Composer
On this page you can find all versions of the php package webstronauts/unpoly. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webstronauts/unpoly
More information about webstronauts/unpoly
Files in webstronauts/unpoly
Package unpoly
Short Description Stack middleware for handling Javascript Unpoly Framework requests
License MIT
Homepage https://github.com/webstronauts/php-unpoly
Informations about the package unpoly
Unpoly
Stack middleware for handling Javascript Unpoly Framework requests.
Installation
You can install the package via Composer.
Usage
You can manually decorate the response with the Unpoly
object.
Stack Middleware
You can decorate the response using the supplied Stack middleware.
Laravel
To use the package with Laravel, you'll have to wrap it around a middleware instance.
Now use this middleware as described by the Laravel documentation.
Validation Errors
Whenever a form is submitted through Unpoly, the response is returned as JSON by default. This is because Laravel returns JSON formatted response for any request with the header X-Requested-With
set to XMLHttpRequest
. To make sure the application returns an HTML response for any validation errors, overwrite the convertValidationExceptionToResponse
method in your App\Exceptions\Handler
class.
Other HTTP Errors
If your Laravel session expires and a user attempts to navigate or perform an operating on the page using Unpoly, an abrupt JSON error response will be displayed to the user:
To prevent this, create your own Request
and extend Laravel's built-in Illuminate\Http\Request
, and override the expectsJson
method:
Then, navigate to your public/index.php
file, and update the usage:
Now when a user session expires, the <body>
of your page will be replaced with your login page, allowing users to sign back in without refreshing the page.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
As it's just a simple port of Ruby to PHP code. All credits should go to the Unpoly team and their unpoly gem.
- Robin van der Vleuten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of unpoly with dependencies
symfony/http-foundation Version ^4.4|^5.4|^6.0
symfony/http-kernel Version ^4.4|^5.4|^6.0