View Full Version : Includes

02-17-2010, 06:30 PM
Hi to all,
My java project uses Quercus to run some php applications, and actually i need to find a way to autoresolve includes in the php sources, by handling the "require" "require_once" and "include" keywords.
I have coded the following function to do so, but i wonder if there is an easy way already implemented in Quercus.

public static List<String> resoveIncludes(QuercusProgram phpProgram)
throws IOException {
List<String> list = new LinkedList<String>();
if (phpProgram.getStatement() instanceof BlockStatement) {
BlockStatement blockStatement = (BlockStatement) phpProgram
Statement[] statements = blockStatement.getStatements();
for (Statement s : statements) {
if (s instanceof ExprStatement) {
Expr expr = ((ExprStatement) s).getExpr();
if (expr instanceof IncludeOnceExpr
|| (expr instanceof IncludeExpr)) {
list.add(StringUtils.substringBetween(expr.toStrin g(), "\""));
return list;

Thanks in advance

02-21-2010, 03:10 AM
I'm not sure what u mean by "autoresolve". If you want the list of included files, I believe there is a function to get it in com.caucho.quercus.env.Env.java