static includes issue - bug?

Discussion about the open-source Phalanger [?] project.

static includes issue - bug?

Postby jfburns@codeplex » September 10th, 2006, 8:01 pm

I'm trying to convert my PHP5 CLI script (which is quite complex and includes MANY classes) to an EXE. Since I'm running on the Console and not from the web, I need to statically load my includes. Here is the issue I'm having:

THIS WORKS:

include('data/project/config/constants.php');

constants.php is included during compilation.

THIS DOES NOT WORK:

$data_dir = 'data/project';
include($data_dir.'/config/constants.php');

constants.php is NOT included during compilation.

COMPILATION COMMAND:

phpc /config:bin\project.config /target:exe /lang:PHP5 cli/project.php

PROJECT.CONFIG PERTINENT LINES:

<set name="EnableStaticInclusions" value="true" scope="Any" />

<set name="StaticIncludePaths" value=".;..\..\xampp\xampp\php\pear" />

Thanks!
Jack
jfburns@codeplex
 
Posts: 15
Joined: January 7th, 2012, 8:57 pm

RE: static includes issue - bug?

Postby Lada Prosek » September 11th, 2006, 11:31 am

Hello Jack,

The problem with a statement like

include($data_dir.'/config/constants.php');

is that in general the compiler is unable to determine the actual file that is included. If you want your exe to contain the file without making changes to your source code, you have to do one of the following:

1) Append all potential included files to the phpc command line.

phpc /config:bin\project.config /target:exe /lang:PHP5 cli/project.php data/project/config/constants.php ...

2) Add an inclusion mapping to your project.config file. If the expression denoting the included file matches the given pattern, it is replaced by the given value (.NET regular expressions). The include will be consequently turned into a static include.

<set name="InclusionMappings" >
<add pattern="\$data_dir\s\.\s'(^'$+)'" value="data/project//$1" />
</set>

We are currently investigating an issue with 2) so I would recommend appending all potentially included sources to the command line.
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: static includes issue - bug?

Postby Lada Prosek » September 11th, 2006, 3:12 pm

Confirming that there's a bug in static includes. Thanks for reporting this!
BTW, there should be start signs after \s in the pattern. There seems to be no way how to escape wiki markup here. Let's try this:

		<compiler>			<set name="EnableStaticInclusions" value="true" scope="Any" />			<set name="InclusionMappings" >			    <add pattern="\$data_dir\s*\.\s*'([^'$]+)'" value="data/project//$1" />			</set>		</compiler>
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: static includes issue - bug?

Postby Lada Prosek » September 11th, 2006, 3:13 pm

Yup, the magic's in double curly open CODE double curly close :)
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: static includes issue - bug?

Postby Lada Prosek » September 11th, 2006, 3:17 pm

This discussion has been copied to Work Item 3122. You may wish to continue further discussion there.
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 22 guests

cron

User Control Panel

Login

Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 5 minutes)
Most users ever online was 227 on March 28th, 2024, 9:13 am

Users browsing this forum: No registered users and 22 guests