Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I've been working on this library for 2 years now and using on many websites with great success. And I decided to make it public, I can assure this is the best jQuery <=> PHP bridge library there is for PHP 5.3 at the moment. I've created the documentation using phpDocumentor 2, but people are shy and never leave any constructive criticism or areas that could be made differently/better, so I think the best would be in CodeReview I guess. It can submit complex forms with infinite nesting, can have nested JSON responses, can access the calling DOM element, can access any object in the browser or set any var or call any function in any global object.

The docs are here http://phery-php-ajax.net/docs

The demo is here http://phery-php-ajax.net/demo.php

The github rep is here https://github.com/pocesar/phery

Some sample code:

function data($ajax_data, $callback_data, Phery $phery)
{
    return
        PheryResponse::factory($callback_data['submit_id']) // submit_id will have #special2
        ->merge('scrollTop')
        ->data('testing', array('nice' => 'awesome'))
        ->jquery('div.test2')
        ->css(array('backgroundColor' => '#f5a'))
        ->animate(array(
                'width' => "70%",
                'opacity' => 0.8,
                'marginLeft' => "0.6in",
                'fontSize' => "1em",
                'borderWidth' => "10px"
            ), 1500, 'linear', PheryFunction::factory(
<<<JSON
function(){
    $(this).append("<br>yes Ive finished animating and fired from inside PHP as an animate() completion callback using PheryFunction rawr!");
}
JSON
    ));
}

Phery::instance()->set(array('remote' => 'data'))->process();

this function would be called from Javascript

phery.remote('remote');

Pub/Sub example:

Server:

<?php 

Phery::instance()->set(array(
  'echo' => function($data){
    return PheryResponse::factory()->publish('transfer', array($data));
  } 
))->process();

Browser:

var el = phery.element('echo');     

el.phery('subscribe', {
  'transfer': function(){
     console.log(arguments); // displays [{transfer: 'back'}]
  }
});

el.phery('remote', {transfer: 'back'}); // call the remote function "echo"

Access the main site for the github repo. Thanks!

share|improve this question

closed as unclear what you're asking by konijn, Malachi, rolfl, 200_success, codesparkle Dec 26 '13 at 22:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Those "are you sure" prompts on the demo site are super annoying. One of the demos also returns a PHP parse error message. –  ThiefMaster Nov 17 '12 at 12:49
1  
As a reference to a similar project, take a look at now.js where you can call server-side JS from client-side JS and vice versa. Basically bridging two separate worlds. –  Joseph the Dreamer Nov 17 '12 at 23:20
1  
I think the site/demo could use some work, if you're really interested in adoption. Look at sass/less, haml, bootstrap websites. Show a small amount at a time. –  Sam Selikoff May 10 '13 at 14:15
1  
@pocesar honestly I wasn't waiting for this. Not because it isn't good, but personally I think it is not easy to use. I've played around with it and it is well written. But using it is non-intuitive. –  Pinoniq Aug 7 '13 at 7:42
5  
I have been starting at this question for a couple of weeks, there really is nothing much to review inside this question. if the author wants us to review specific parts, then those parts should be inside the question. Voting to close this question. –  konijn Dec 26 '13 at 21:20

Browse other questions tagged or ask your own question.