PHP Implementation of Pjaxr

How to install php-pjaxr?

There are just two steps needed to install php-pjaxr:

  1. Add php-pjaxr to your composer.json:

        "require": {
        "iekadou/php_pjaxr": ">=0.1.1",
  2. Set the current Pjaxr namespace in your View or anywhere before your templates get rendered:

    use Iekadou\Pjaxr\Pjaxr as Pjaxr;
    use Iekadou\TwigPjaxr\Twig_Pjaxr_TokenParser_PjaxrExtends;

How do i use php-pjaxr?

This example seems to show a huge overhead, actually only the if-else tags make it that big.

// View:
if (!Pjaxr::matches('Pjaxr')) {
    // Do everything you need only for the whole site.
if (!Pjaxr::matches('Pjaxr.Home')) {
    // Do everything you need to handle the home page.

// Head-Template:
if (!Pjaxr::matches('Pjaxr')) {
            // Scripts and Stylesheets could be loaded here, no need to reload them when changing the page
<?php } else { ?>
<?php }
if (!Pjaxr::matches('Pjaxr')) {
<?php } else { ?>
<?php }

// Body-Template:
if (!Pjaxr::matches('Pjaxr')) {
        <div id="site">
            <div id="page">
<?php } else { ?>
<?php }

// Render everything you need in the page container.

if (!Pjaxr::matches('Pjaxr')) { ?>
            ...//site content could still be here
<?php } else { ?>
<?php } ?>

If this seems to be too complex for you, try twig in combination with twig-pjaxr for templating.

What do you need for php-pjaxr?

  1. PHP >= 5.3.29
  2. jquery-pjaxr

Projects using php-pjaxr


If you are using twig-pjaxr, please contact me, and tell me in which projects you are using it. Thank you!

Happy speeding up your php project!