2017 © Pedro Peláez
 

library laravel-pjax

A pjax middleware for Laravel 5

image

spatie/laravel-pjax

A pjax middleware for Laravel 5

  • Thursday, June 7, 2018
  • by Spatie
  • Repository
  • 17 Watchers
  • 377 Stars
  • 93,878 Installations
  • PHP
  • 5 Dependents
  • 1 Suggesters
  • 30 Forks
  • 0 Open issues
  • 11 Versions
  • 7 % Grown

The README.md

A pjax middleware for Laravel

Latest Version on Packagist Software License GitHub Workflow Status Total Downloads, (*1)

Pjax is a jQuery plugin that leverages ajax to speed up the loading time of your pages. It works by only fetching specific html fragments from the server, and client-side updating only happens on certain parts of the page., (*2)

The package provides a middleware that can return the response that the jQuery plugin expects., (*3)

There's a Vue-PJAX Adapter equivalent by @barnabaskecskes which doesn't require jQuery., (*4)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website., (*5)

Support us

, (*6)

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products., (*7)

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall., (*8)

Installation

You can install the package via composer: ``` bash $ composer require spatie/laravel-pjax, (*9)


Next you must add the `\Spatie\Pjax\Middleware\FilterIfPjax`-middleware to the kernel. ```php // app/Http/Kernel.php ... protected $middleware = [ ... \Spatie\Pjax\Middleware\FilterIfPjax::class, ];

Usage

The provided middleware provides the behaviour that the pjax plugin expects of the server:, (*10)

An X-PJAX request header is set to differentiate a pjax request from normal XHR requests. In this case, if the request is pjax, we skip the layout html and just render the inner contents of the container., (*11)

Laravel cache busting tip

When using Laravel Mix to manage your frontend cache busting, you can use it to your advantage to bust pjax's cache. Simply include the mix method as the content of the x-pjax-version meta tag:, (*12)

<meta http-equiv="x-pjax-version" content="{{ mix('/css/app.css') }}">

Multiple files:, (*13)

<meta http-equiv="x-pjax-version" content="{{ mix('/css/app.css') . mix('/css/app2.css') }}">

This way, anytime your frontend's cache gets busted, pjax's cache gets automatically busted as well!, (*14)

Changelog

Please see CHANGELOG for more information what has changed recently., (*15)

Testing

bash $ composer test, (*16)

Contributing

Please see CONTRIBUTING for details., (*17)

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker., (*18)

Credits

The middleware in this package was originally written by Jeffrey Way for the Laracasts-lesson on pjax. His original code can be found in this repo on GitHub., (*19)

License

The MIT License (MIT). Please see License File for more information., (*20)

The Versions

16/10 2015
16/10 2015

1.0.0

1.0.0.0 https://github.com/spatie/laravel-pjax

A pjax middleware for Laravel 5freek@spatie.be

  Sources   Download

MIT

The Requires

 

The Development Requires

spatie laravel-pjax

16/10 2015