1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    3
    Vote Rating
    0
    FlorianX is on a distinguished road

      0  

    Default Unanswered: ExtJS API for PHP

    Unanswered: ExtJS API for PHP


    Hi,

    i want to write an PHP Application with ExtJS.
    The PHP should generate some ExtJS JSON and here is my problem.
    All Examples create the JSON as strings and not from a standard way e.g. some classes.

    So my idea was to have the ExtJS API as PHP classes. Than i could create an object and set some properties and than call toJSON().
    With this way i have in every place i use a panel the same class (api) and not only a string or an array.

    Knows someone, if and where i could find something like this, or if i had to do that by myself.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,217
    Answers
    3519
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    So you want Ext.data.Store as a PHP class?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    May 2011
    Posts
    3
    Vote Rating
    0
    FlorianX is on a distinguished road

      0  

    Default


    Thanks for your answer.

    I want e.g. Ext.panel as a PHP class or better the needed structure to create a panel.

    Now i have to write somthing like this:
    Code:
    $panel = "Ext.create('Ext.panel.Panel', {
        title: 'Hello',
        width: 200,
        html: '<p>World!</p>',
        renderTo: Ext.getBody()
    });";
    -> or an associative array...

    This will be returned from my php zend action to the browser which runs the code.

    I want to write in the action something like this:
    Code:
    $panel = new PhpExtPanel();
    $panel->title = 'hello';
    ...
    return $panel.toJSON();
    So i have a standard class which i could use in every action in need it.
    And i haven't in all actions stings or arrays.

    I hope this explanation is better to understand

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    53
    Answers
    2
    Vote Rating
    1
    Erikvip is on a distinguished road

      0  

    Default


    This does what you're after -
    http://php-ext.quimera-solutions.com/

    Although, I wouldn't recommend it's usage. You'll never have the latest and greatest ExtJS features, and this seems like it would limit the flexibility of ExtJS.

    My recommendation - read up on MVC architecture and use Ext.Direct.

    Oh and - that project hasn't been updated since 2008, so I wouldn't expect much from it...

  5. #5
    Sencha User
    Join Date
    May 2011
    Posts
    3
    Vote Rating
    0
    FlorianX is on a distinguished road

      0  

    Default


    Thanks Erikvip, I agree with you:
    2008 that's not good :-)

    Ext.direct is good to get data from DB or something. But could i do the following with it:
    The Plan:
    - it's a complete ExtJS builded website

    1. User logs in.
    2. He sees the "desktop" with a menu. This menu is loaded from DB (works)
    3. Now he want to start an applikation/modul he clicks on "user administration"
    4. Then opens a window with a grid.

    ----
    - here is the problem, every user could have other privileges
    - e.g. he may not see the column: age or he has other limitations
    - so the idea was to create the views, panels and whatever by php dynamically

    Because this, i want to build @ php window with a grid and submit this to the browser.
    Now the grid has the limitations and it knows where to finde the needed grid data.

    This window could be used in "thousands" of modules and I will not have the configuration json string/array in any module , as this error could occur.

  6. #6
    Sencha User
    Join Date
    Aug 2011
    Posts
    53
    Answers
    2
    Vote Rating
    1
    Erikvip is on a distinguished road

      0  

    Default


    Normally for doing that, I create separate permissions as bit fields in the database, then check them when the view is being rendered & hide/show components in JS. Of course, you'll still need to verify permissions on the PHP controller, but that will give you dynamic views.

    So i.e., I make a table with permissions like, perm_view_users, perm_edit_users, perm_admin, etc. When the user logs in, I store this in a session & setup a user.permissions object.

    Then, when building the view, you can do things like:

    Code:
    Ext.create('Ext.Panel', {
        hidden : ( !user.permissions.perm_edit_users == '1' )
    });
    
    //or
    
    if ( user.permissions.perm_edit_users == '1') {
        Ext.create( ...
    }
    So the view is only visible to users with certain permissions. Then of course on the back end:

    Code:
    public function update_user($args) {
       if ( !$this->has_permission('perm_edit_users') )
        throw new Exception('access denied');
    }
    Notice that you'll need to perform this check in both places for security (client and server side).


    I would recommend using pure ExtJS instead of a PHP wrapper though. You'll find better help online & can use all the latest features.

Thread Participants: 2

Tags for this Thread