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).

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: