Welcome Guest, Not a member yet? Register   Sign In
Trying to write a Library for the new Xajax
#1

(This post was last modified: 04-25-2016, 11:26 PM by jasonzig.)

Hello All,

I'm trying to write a library for the newly resurrected Xajax project (from Thierry Feuzeu)...

and I'm coming up short due to my inexperience in writing CodeIgniter Libraries and with PHP namespacing.

Could anyone offer some thoughts on how to make this work? (see's Thierry's example code: https://github.com/lagdo/xajax-examples/.../hello.php)

Here's what I've got so far, and it definitely instantiates an xajax object, of which I can access at least the getVersion() method from inside a CodeIgniter controller method, but I can't figure out how to write the Library to access other basics (see errors in __construct() ):
( output: http://triv.ath.cx/ci3/ )

So, I'm at a loss as to what to do next... any advice?

CodeIgniter 3 Library:
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

require (
APPPATH '../vendor/autoload.php');

use 
Xajax\Xajax;
use 
Xajax\Response\Response;
use 
Xajax\Request\Factory as xr;

class 
CI_Xajax {

 
 public $xajax '';

 
   public function __construct()
 
   {

 
   $this->xajax Xajax::getInstance();
//        $this->_ci   =& get_instance();
 
       
    $this
->xajax->setOption('core.debug.on'true);
 
   $this->xajax->setOption('core.prefix.function''xajax_');
 
       
    
}


CodeIgniter 3 Welcome Controller:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

 
   public function __construct()
 
   {
 
       parent::__construct();

 
       $this->load->library(array('CI_Xajax''session'));

//    $this->ci_xajax->xajax->register(Xajax::USER_FUNCTION, 'hello');
//    Fatal error: Class 'Xajax' not found in /var/www/html/ci3/application/controllers/Welcome.php on line 12

//    $this->ci_xajax->xajax->register(CI_Xajax::USER_FUNCTION, 'hello');
//    Fatal error: Undefined class constant 'USER_FUNCTION' in /var/www/html/ci3/application/controllers/Welcome.php on line 15

 
   }

 
   public function index()
 
   {
 
   $viewData '';
 
   $viewData['XjxVersion'] = $this->ci_xajax->xajax->getVersion();

 
       $this->load->view('welcome_message',$viewData);
 
       
    
}
 
   
    public 
function hello() {
 
       $this->load->view('welcome_message',$viewData);
 
   }


(Using CodeIgniter since 1.x)
Reply


Messages In This Thread
Trying to write a Library for the new Xajax - by jasonzig - 04-25-2016, 11:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB