1. #1
    Sencha User Izhaki's Avatar
    Join Date
    Apr 2009
    Location
    London
    Posts
    118
    Vote Rating
    13
    Izhaki will become famous soon enough

      0  

    Default Sencha compile with direct/api.php

    Sencha compile with direct/api.php


    There are a few similar questions on this forum, but none seems to provide a solid answer.

    I'm using direct, and my head block looks like this:

    Code:
    <head>
        <title>Submission System</title>
            
        <!-- <x-compile> -->
            <!-- <x-bootstrap> -->
                <script type="text/javascript" src="../extjs/ext-all-dev.js"></script>
            <!-- </x-bootstrap> -->
    
            <link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all-gray.css">
    
            <script type="text/javascript" src="server/direct/api.php"></script>    
                
            <script type="text/javascript" src="app.js"></script>
        <!-- </x-compile> -->
    </head>
    There is an importance to the way the scripts are included as:
    • api.php requires the extjs lib to come before it for Ext to be in scope.
    • As my app controllers/stores/models are loaded upon onLaunch, api.php has to come before app.js
    The dev (non-compiled) version works fine, but when trying to compile (Sencha Cmd v3.0.2.288):

    Code:
    sencha -sdk ../ext-4.1.1a compile -debug -classpath=./ page -in index.php -out build/index.php
    I get an error:

    Code:
    C2000: YUI Compressor Error (illegally formed XML syntax => echo ';';) -- /SomePath/direct/api.php:3767
    I need my api.php to come between the ext lib and my app.js - thus I can't move it outside the x-compile block; but the compiler doesn't seem to be able to process it.

    I can omit api.php from the head block, take its output and provide it manually to Ext.direct.Manager.addProvider. But then I have redundancy where I need to maintain both this code and that of config.php (which is needed for router.php).

    Is there a way to compile api.php?

  2. #2
    Sencha User Izhaki's Avatar
    Join Date
    Apr 2009
    Location
    London
    Posts
    118
    Vote Rating
    13
    Izhaki will become famous soon enough

      0  

    Default


    Ok, turns out I can include api.php after the x-compile block, so long I add the provider in Ext.onReady...

  3. #3
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    33
    Vote Rating
    0
    ffanf is on a distinguished road

      0  

    Default


    Hi Izhaki,

    I think I'm having the same difficulty than you do, my app work fine in development, I can build it with no errors, but it does not load.

    Could you post a few more details about how you managed to get it working.

    My index.html looks like this:
    Code:
        <!-- <x-compile> -->
            <!-- <x-bootstrap> -->
                <script src="../ext/ext-dev.js"></script>
                <script src="bootstrap.js"></script>
            <!-- </x-bootstrap> -->
           <script src="app/app.js"></script>
        <!-- </x-compile> -->
    	<script type="text/javascript" src="direct/api.php"></script>
    My app.js, like this:
    Code:
    Ext.onReady(function(){
    	// Register a remoting api to this application.
    	Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    .....
    And the output of direct/api.php looks like this:
    Code:
    Ext.ns("Ext.app"); 
    Ext.app.REMOTING_API = {
    	"url":"direct\/router.php",
    	"type":"remoting",
    	"actions":{
    		"NavigationTree":[
    			{"name":"getResults","len":1},
    			{"name":"createRecord","len":1},
    			{"name":"updateRecords","len":1},
    			{"name":"destroyRecord","len":1}
    		]
    	}
    };
    Using Sencha Cmd v3.0.2.288 => sencha app build testing

    I get the following error:
    Code:
    Uncaught ReferenceError: NavigationTree is not defined
    Then looking into the corresponding section of all-classes.js file:
    Code:
    	proxy:{ 
    		type: 'direct',		
    		api:{ 
    			create:	NavigationTree.createRecord,Uncaught ReferenceError: NavigationTree is not defined
    
    
    
    			read: 		NavigationTree.getResults,			update:	NavigationTree.updateRecords,			destroy: 	NavigationTree.destroyRecord		}	}
    Output of direct/api.php does not get inserted into all-classes.js (I cannot find
    Ext.app.REMOTING_API other than in the declaration of app.js).

    Any help or suggestion would be greatly appreciated.

  4. #4
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    33
    Vote Rating
    0
    ffanf is on a distinguished road

      0  

    Default


    Does someone know how to use sencha app build with ext.direct ?

    Thanks

  5. #5
    Sencha User Izhaki's Avatar
    Join Date
    Apr 2009
    Location
    London
    Posts
    118
    Vote Rating
    13
    Izhaki will become famous soon enough

      2  

    Default


    To begin with, direct/api.php shouldn't be inserted to your all-classes.js - that's how it should be.

    The only issue I can see with your code is that the CRUD methods are object, so when the script is being interpreted that object is not in scope. I had the same issue and what solved it for me was providing the methods as strings. So:

    Code:
    read: 'NavigationTree.getResults'
    My index.html looks like this:

    Code:
        <!-- <x-compile> -->
            <!-- <x-bootstrap> -->
                <script type="text/javascript" src="../extjs/lib/ext-all-debug.js"></script>
            <!-- </x-bootstrap> -->
        
            <script type="text/javascript" src="../extjs/mods.js"></script>    
                
            <script type="text/javascript" src="client/app.js"></script>
        <!-- </x-compile> -->
    
    
        <script type="text/javascript" src="server/direct/api.php"></script>
    Then my app.js:

    Code:
    Ext.require([
        'Ext.direct.*',
    ]);
    
    
    Ext.onReady(function() {
        Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    
    
    });
    
    
    Ext.application({
        ...
    });
    
    Do you need anything else?

  6. #6
    Sencha Premium Member
    Join Date
    Jun 2012
    Posts
    33
    Vote Rating
    0
    ffanf is on a distinguished road

      0  

    Default


    Hi Izhaki,

    Sorry for the late answer, I could not test this before today.

    Your suggestion worked like a charm, and providing the method as string solved my issue.

    Thanks a lot !

Thread Participants: 1