-
15 Jan 2013 3:06 AM #1
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:
There is an importance to the way the scripts are included as: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>- 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
I get an error:Code:sencha -sdk ../ext-4.1.1a compile -debug -classpath=./ page -in index.php -out build/index.php
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.Code:C2000: YUI Compressor Error (illegally formed XML syntax => echo ';';) -- /SomePath/direct/api.php:3767
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?
-
15 Jan 2013 4:21 AM #2
Ok, turns out I can include api.php after the x-compile block, so long I add the provider in Ext.onReady...
-
15 Feb 2013 2:53 PM #3
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:
My app.js, 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>
And the output of direct/api.php looks like this:Code:Ext.onReady(function(){ // Register a remoting api to this application. Ext.direct.Manager.addProvider(Ext.app.REMOTING_API); .....
Using Sencha Cmd v3.0.2.288 => sencha app build testingCode: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} ] } };
I get the following error:
Then looking into the corresponding section of all-classes.js file:Code:Uncaught ReferenceError: NavigationTree is not defined
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).Code:proxy:{ type: 'direct', api:{ create: NavigationTree.createRecord,
Uncaught ReferenceError: NavigationTree is not defined
read: NavigationTree.getResults, update: NavigationTree.updateRecords, destroy: NavigationTree.destroyRecord } }
Any help or suggestion would be greatly appreciated.
-
28 Feb 2013 4:01 PM #4
Does someone know how to use sencha app build with ext.direct ?
Thanks
-
4 Mar 2013 9:41 AM #5
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:
My index.html looks like this:Code:read: 'NavigationTree.getResults'
Then my app.js: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>
Code:Ext.require([ 'Ext.direct.*', ]); Ext.onReady(function() { Ext.direct.Manager.addProvider(Ext.app.REMOTING_API); }); Ext.application({ ... }); Do you need anything else?
-
12 Mar 2013 8:37 AM #6
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 !
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote