Skip to content

Latest commit

 

History

History
73 lines (53 loc) · 1.47 KB

HOWTO.md

File metadata and controls

73 lines (53 loc) · 1.47 KB

Jaxon 3.x :: Quick start

Import the functions

use Jaxon\jaxon;
use Jaxon\rq;

Register a single class

jaxon()->register(Jaxon::CALLABLE_CLASS, 'HelloWorld');

Register all classes in a directory

jaxon()->register(Jaxon::CALLABLE_DIR, '/full/path/to/dir');

Register all classes in a namespace

jaxon()->register(Jaxon::CALLABLE_DIR, '/full/path/to/dir', [
    'namespace' => '\Path\To\Namespace',
]);

Register a function

jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'sayHello');

Register a method as a function

// The corresponding javascript function name is 'setColor'
jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'setColor', [
    'class' => 'HelloWorld',
]);

Register a method as a function with an alias

// The corresponding javascript function name is 'helloWorld'
jaxon()->register(Jaxon::CALLABLE_FUNCTION, 'sayHello', [
    'class' => 'HelloWorld',
    'alias' => 'helloWorld',
]);

Call a registered class

<button onclick="<?php echo rq('HelloWorld')->sayHello() ?>" >Click Me</button>

Call a registered class with a parameter

<button onclick="<?php echo rq('HelloWorld')->sayHello(0) ?>" >Click Me</button>
<button onclick="<?php echo rq('HelloWorld')->setColor(pm()->select('color')) ?>" >Click Me</button>

Call a registered function

<button onclick="<?php echo rq()->sayHello() ?>" >Click Me</button>