1. #1
    Sencha User
    Join Date
    Apr 2009
    Location
    Bulgaria
    Posts
    21
    Vote Rating
    1
    ficeto is on a distinguished road

      0  

    Default Another Codeigniter Direct implementation

    Another Codeigniter Direct implementation


    Hi folks, I saw the other thread for a direct codeigniter implementation but I think my approach is a bit different.
    You can grab the code from http://github.com/ficeto/direct-igniter
    The classes that Direct calls in my case are regular Controller classes, just like those that are in the application/controllers folder but the ones for Direct stay in applications/direct folder.
    Going this way lets you use the same models libraries and syntax as in codeigniter.
    I'm running this same code in an application that is build on direct and features all kinds of grids, trees, forms and such.
    I have a basic test build in, so some of the files are purely for example.
    The files that you need to worry are:

    application/config/direct.php
    application/controllers/direct.php <- you can change the index and deploy login checks if needed
    application/libraries/Direct_api.php
    application/libraries/Direct_cache_provider.php
    and the application/direct folder for your controller classes

    enjoy, I hope you like it.

    NOTE: If you are using Codeigniter 2, you will need to change the model class in the example to extend CI_Model (don't forget to also reflect that in the constructor function)
    Last edited by ficeto; 5 Oct 2010 at 9:53 AM. Reason: added note about CI2

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    Hi,

    i try this with codeigniter 2 but everytime i get follwing error:

    Code:
    {"type":"exception","tid":2,"message":"Call to undefined class: Direct_controller","where":"#0 D:\\PhpStorm-Projects\\iknow6\\application\\controllers\\direct.php(105): Direct->_rpc(Object(stdClass))\n#1 D:\\PhpStorm-Projects\\iknow6\\application\\controllers\\direct.php(68): Direct->_dispatch()\n#2 [internal function]: Direct->router()\n#3 D:\\PhpStorm-Projects\\iknow6\\system\\core\\CodeIgniter.php(311): call_user_func_array(Array, Array)\n#4 D:\\PhpStorm-Projects\\iknow6\\index.php(163): require_once('D:\\PhpStorm-Pro...')\n#5 {main}"}
    Any idea?

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    it seems that on windows the following will not work. I don´t know why...

    Code:
    $apiState = $this->session->userdata('ext-direct-state');

  4. #4
    Sencha User
    Join Date
    Apr 2009
    Location
    Bulgaria
    Posts
    21
    Vote Rating
    1
    ficeto is on a distinguished road

      0  

    Default


    it uses codeigniter session to store the API state. Maybe nothing was saved there to begin with... can you check that please?

  5. #5
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    i debug this with firebug. Inside the api() function the session will be correct set, but is not available inside the router function.

    Here runs windows with a local Apache Server . The same behaviour is inside the other codeigniter implementation from goachka. It seems that the router function can not access the original sessions-data an create a new one every direct call.
    So, every call the api will be recreated :-(

    Currently i have no idea why the sessions will be recreated...

  6. #6
    Sencha User
    Join Date
    Apr 2009
    Location
    Bulgaria
    Posts
    21
    Vote Rating
    1
    ficeto is on a distinguished road

      0  

    Default


    can you otherwise confirm that your codeigniter sessions are working at all?

  7. #7
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    no i can´t. I test a little bit... PHP-Sessions working well but the CodeIgniter-Sessions will always create a new id on every call.
    Can you test your direct implementation against CodeIgniter 2 (http://bitbucket.org/ellislab/codeigniter/)?
    That will help me to find the reasion for this strange behaviour. What enviroment you use?

    [EDIT]
    After some debugging i found the reason for this behaviour. It´s a bug inside PHP (perhaps only the Windows-Version) in the unserialize() function.

    I found this blog entry (http://www.backwardcompatible.net/ph...nd-codeigniter) and replace the unserialize function().
    And now it works like a charm...

    Bye, Dumbledore...
    Last edited by Dumbledore; 5 Oct 2010 at 3:53 AM. Reason: found Solution

  8. #8
    Sencha User
    Join Date
    Apr 2009
    Location
    Bulgaria
    Posts
    21
    Vote Rating
    1
    ficeto is on a distinguished road

      0  

    Default


    I experience no such issues on OS X or Debian using Codeigniter 2 from the link you posted. Probably you should submit it as a bug to codeigniter?

  9. #9
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    yes - i will do that...

  10. #10
    Ext JS Premium Member
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    673
    Vote Rating
    10
    Dumbledore will become famous soon enough

      0  

    Default


    again, with the same problem

    How did you setup your CodeIgniter? Did your store the sessions in a database table? When i store my session data in a database it runs, when i use the following _serialize function()
    PHP Code:
        function _unserialize($data)
        {

            
    $out preg_replace('!s:(\d+):"(.*?)";!se',
            
    "'s:'.strlen('$2').':\"$2\";'"$data );
            return @
    unserialize($out);
        } 
    when i try to use cookie based sessions your code will not run. It seems there is a problem with unserialize the api. It is not a bug from CodeIgniter (http://bitbucket.org/ellislab/codeig...-a-new-session) and the solution with json_encode() will not work.

    So it seems, that storing the session in a database is a _must_ for this code.

Similar Threads

  1. Ext.Direct for CodeIgniter
    By goachka in forum Ext.Direct
    Replies: 46
    Last Post: 9 Feb 2013, 5:03 PM
  2. Ext.Direct implementation gotchas
    By meercat in forum Ext.Direct
    Replies: 0
    Last Post: 17 Sep 2010, 7:01 AM
  3. ext.direct and codeigniter
    By Boon in forum Ext.Direct
    Replies: 3
    Last Post: 31 Aug 2009, 12:24 PM
  4. Alternative Ext Direct Java Implementation
    By rastafarra in forum Ext.Direct
    Replies: 0
    Last Post: 8 Jun 2009, 12:06 AM

Thread Participants: 1

Tags for this Thread