Threaded View

  1. #1
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    105
    Vote Rating
    7
    j.bruni is on a distinguished road

      4  

    Wink Extremely Easy Ext.Direct integration with PHP

    Extremely Easy Ext.Direct integration with PHP


    *** Compatible with ExtJS 4 ***

    This is an updated / refactored version of "Easy Ext.Direct integration with PHP"


    How to use:

    1) PHP

    PHP Code:
    <?php

    require 'ExtDirect.php';

    class 
    Server
    {
        public function 
    date$format )
        {
            return 
    date$format );
        }
    }

    ExtDirect::provide'Server' );

    ?>
    Here, "Server" is the PHP class that we want to provide access from the JavaScript code. It could be any other class.

    2) HTML:

    Code:
    <script type="text/javascript" src="ext-direct.php?javascript"></script>
    Here, "ext-direct.php" points to the PHP file shown on item 1. The "?javascript" query string is necessary, because the default output is on JSON format (good for Ext Designer).

    3) JavaScript:

    Code:
    Ext.php.Server.date( 'Y-m-d', function(result){ alert( 'Server date is ' + result ); } );
    Here, to call the "date" method from PHP "Server" class, we prepended the default namespace Ext.php. The first parameter is the $format parameter. The second parameter is the JavaScript callback function that will be executed after the AJAX call has been completed. Here, an alert box shows the result.



    What are you waiting for the download?

    It includes:

    ExtDirect.php - This is the file you include in your PHP script.
    example.php - This is a working sample (PHP part).
    example.html - The HTML and JavaScript parts of the working sample.

    In the next post, I tell you about the features and configuration options.

    Thanks.



    The current latest version is ExtDirect_2011-11-08.zip, which you can download below:
    Attached Files
    Last edited by j.bruni; 8 Nov 2011 at 5:31 PM. Reason: New version available (November 8, 2011)