简体   繁体   中英

Calling fcsh from PHP script

My question is whether or not Flex's fcsh can be called from within a PHP script. Here is the background:

I have been created a simple process that creates a simple quiz/tutorial by converting a text file into a .mxml file and compiling to a .swf file using the mxmlc compiler. This works well from the command line, but I wanted to make the process easier by creating a web-interface to do this. My initial attempts with PHP's exec() function have not worked. The Python scripts I use to create the .mxml file work fine (using exec()), but I have not been able to get the mxmlc compiler to work.

After searching on the Web and on this site, I believe that using fcsh (instead of mxmlc) may be the way to go. Using fcsh would certainly compile the .mxml file faster (after the first run), and I think that fcsh can be launched as a service that might be able to be called from PHP.

On the other hand, maybe I am approaching this the wrong way. Would it be better to write a Flex application that calls fcsh and avoid using PHP?

Edit: Using fcshctl as hasseg suggested in his answer below worked very well. Thanks Ali.

The problem with calling fcsh from within scripts is that it works as an interactive shell instead of taking command-line arguments, compiling, and returning an exit status. There are different ways to get around this, which I've listed in this blog post of mine , where I mainly talk about fcshctl (which is my own solution for this,) but at the bottom of the post I've also listed other similar solutions to get fcsh integrated into nonstandard build workflows.

There are a few other ways in php to execute an external script. They are exec(), passthru(), system(), and backticks ie the key to the left of the 1 key. Each one has a different purpose and return mechanism.

You may have to put the command that executes your executable into a script and call that script via one of these functions.

Is there a particular reason why you can't use mxmlc directly? It seems like it would be easier to call than fcsh . Just specify all your compiler options in a XML file run it like mxmlc -load-config path/to/config.xml . You can find an example of the XML configuration format in FLEX_HOME/frameworks/flex-config.xml .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM