PHP code example of kohana-modules / phery

1. Go to this page and download the library: Download kohana-modules/phery library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kohana-modules / phery example snippets


class Controller_Index extends Phery_Template {

    /* This will be available for action_index only */
    public function ajax_index_edit()
    {
        return PheryResponse::factory()->alert('works for index!');
    }

    public function action_index()
    {
        $form = array(Phery::form_for('', 'edit'));
        $form[] = Form::input('id', 1, array('type' => 'hidden'));
        $form[] = Form::submit('submit', 'Send');
        $form[] = Form::close();
        $this->template->content = join('', $form);
    }

    public function action_view()
    {
        // calling phery.remote('edit') from the page won't call the phery_index_edit function
    }
}

class Controller_Index extends Phery_Template {

    /* This will be available for action_index and action_view */
    public function ajax_edit()
    {
        $r = new PheryResponse;
        /* If you must, check which action the current call should deal */

        switch ($this->request->action()):
            case 'index':
                // do according to index
                $r->alert('its for index!');
                break;
            case 'view':
                // do according to view
                $r->alert('its for view!');
                break;
        endswitch;

        return $r;
    }

    public function action_index()
    {
        $form = array(Phery::form_for('', 'edit'));
        $form[] = Form::input('id', 1, array('type' => 'hidden'));
        $form[] = Form::submit('submit', 'Send');
        $form[] = Form::close();
        $this->template->content = join('', $form);
    }

    public function action_view()
    {
        $this->template->content = Phery::link_to('Click me', 'edit', array('args' => array('id' => 1)));
    }
}

class Controller_Index extends Phery_Controller {

    public function ajax()
    {
        return array(
            'error_reporting' => E_ALL
        );
    }

    public function action_index()
    {
    }
}

class Controller_Index extends Phery_Controller {

    function action_index()
    {
        $this->ajax->set(array(
            'edit' => 'Helper::staticAjaxMethod',
            'load' => array(new Model_User, 'load')
        ));
    }
}
 echo HTML::script('phery.js'); 
 echo $ajax->csrf;