2017 © Pedro Peláez
 

library laravel-pjax

Laravel middleware for pjax. Use ajax and pushState to deliver a fast & seemless browsing experience

image

timgws/laravel-pjax

Laravel middleware for pjax. Use ajax and pushState to deliver a fast & seemless browsing experience

  • Tuesday, June 7, 2016
  • by timgws
  • Repository
  • 1 Watchers
  • 1 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

laravel-pjax

laravel-pjax is a pjax middleware for Laravel >5.1., (*1)

By adding pjax & jQuery to your web application, ajax and pushState can be used to deliver a fast browsing experience with real permalinks, page titles, and a working back button., (*2)

This middleware adds some functionality that other middleware (at the time of writing) did not provide, such as container whitelists and faster page filtering., (*3)

I wanted to have some additional functionality for loading "pjax" AJAX requests, so I quickly threw together this package., (*4)

Setting up the middleware

Install the package:, (*5)

# composer require timgws/laravel-pjax

Add the middleware to your app's kernel configuration. The higher the better!, (*6)

// app/Http/Kernel.php

// ...
protected $middleware = [
    // ...
    \timgws\pjax\Middleware::class,
];

Add the service provider:, (*7)

// config/app.php

// ...
    'providers' => [
        // ... Laravel providers

        timgws\pjax\ServiceProvider::class,

        // ... app providers ...
    ],

Publish the config file:, (*8)

php artisan vendor:publish --provider="timgws\pjax\ServiceProvider" --tag="config"

and test!, (*9)

Limiting containers that can be requested

One major difference between this module and other Laravel pjax middleware is that you can limit which containers can be requested via HTTP headers., (*10)

You may wish to edit the pjax.php config file to limit valid_containers, (*11)

return [
    'valid_containers' => [
        '#pjax-container', '.content'
    ]
];

See https://github.com/defunkt/jquery-pjax#usage for further information., (*12)

Force reload of page when version changes

Inside config.php, set the layout version to force a hard reload of the requested page when a client is on an old version of the layout., (*13)

Bumping the version will force clients to do a full reload the next request getting the new layout and assets, (*14)

Set the version to something like 'v1'. Also, you will need to add a meta tag like this to the base layout:, (*15)

      <meta http-equiv="x-pjax-version" content="v1">
      return [
          'layout_version' => 'v1'
      ];

See https://github.com/defunkt/jquery-pjax#usage for further information., (*16)

Contributors

Contributors on GitHub

License

TODO

  • Build test suite

The Versions

07/06 2016

dev-master

9999999-dev https://github.com/timgws/laravel-pjax

Laravel middleware for pjax. Use ajax and pushState to deliver a fast & seemless browsing experience

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware jquery ajax request pjax pushstate