I read about Phing and Ant, and I'm not sure which of these tools are most useful for this scenario.
These can be easily debug statements, etc., but I will give you our literal scanario.
We have a free and high-quality version of a downloadable PHP application, and instead of just including some kind of variable hidden somewhere, and then doing:
if($premium == true) { echo 'some additional functionality'; } else { echo 'basic functionality'; }
Obviously, someone could take the source code and change this variable, and hit - they stole our code. And something like Ioncube, etc. Just awesome in my experience, and hosting company support is just not good enough.
I would prefer something ... maybe it looks like this:
## if premium ## echo 'some additional functionality'; ## else ## echo 'basic functionality'; ## endif ##
And then I would run two assemblies, one set the premium to true and one to false, which would generate two files simply:
echo 'some additional functionality';
and
echo 'basic functionality';
It would be very useful to be able to include only whole files based on the same condition passed to the build application.
I cannot find a way to do this, but I am open to any alternative ideas, if possible.
Help will be outstanding,
UPDATE
Using the C preprocessor is great and looks like it does everything I need. However, I cannot find how to do the following 3 things.
# 1 I need to delete comments generated in the output files. Below is an example of these.
# 1 "./index.php" # 1 "<built-in>" # 1 "<command-line>" # 1 "./index.php"
I did not find an example of how to do this on the manual page with which you linked me.
# 2 I need it to recursively scan each detected file. When I run my current code, I get an error message: ../target/./folder/test.php: No such file or directory
So basically I have my “source” folder in which I was located, which contains a subfolder called “folder”, and it does not recreate this, nor the files inside it (test.php)
# 3 I'm sure this is easy - how can I get it to handle .js files and possibly .html to be safe? In one call, I mean. I assume I ran it on .jpg, etc. Files are a bad idea.
Thanks again!