-
Notifications
You must be signed in to change notification settings - Fork 36
Description
The README's Documentation section starts with:
It's really simple as:
<?php require_once 'vendor/autoload.php'; use Phery\Phery; Phery::instance() ->set(array( 'function_name' => function($data){ return PheryResponse::factory() ->jquery('<div/>', array('text' => 'text content')) ->appendTo('body') ->call('func', 'list', true); } ))->process(); ?> <!doctype html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="phery.js"></script> <script> function func(name, override){ /* function */ } </script> </head> <body> <?php echo Phery::link_to('Click me', 'function_name'); ?> </body> </html>When clicking a link with data-phery-remote, it will automatically call the "function_name" callback, that will return a response and apply everything automagically
I suppose "It's really simple as:" is supposed to read "It's really as simple as:". If so, considering that the README seems to be targeting new users, this is quite misleading. The example refers to 2 previously undiscussed classes and 8 previously undiscussed methods. It contains a statement which chains 3 methods, which embeds a statement which chains 4 different methods.
Someone who doesn't master jQuery would have a hard time understanding what the above is meant to do. Someone who doesn't know what autoloading is would notice that vendor/autoload.php does not exist and have trouble getting the code to work.
The explanation paragraph refers to data-phery-remote, which has not been defined before. It is also incorrect; only links with a data-phery-remote attribute set to "function_name" will call the function-name callback.
If "It" refers to Phery, I do not think Phery.js - with its PHP API having tens of functions, its JavaScript API and a DOM interface - will be considered simple by many. If "It" means accomplishing what the example does using Phery.js, then it may look simple for someone who masters Phery.js indeed, but that is a minority of the audience.
I recommend to avoid suggesting that Phery is simple. I also recommend to keep the example as simple as possible. And finally I recommend to explain what the example is meant to do.