Note that there are some explanatory texts on larger screens.

plurals
  1. POPreprocessing PHP to remove functionality from built files
    primarykey
    data
    text
    <p>I've been reading about Phing and Ant and I'm not sure which, if either, of these tools are most useful for this scenario.</p> <p>It could easily be debug statements etc, but I'll give you our literal scanario.</p> <p>We have a free and premium version of a downloadable PHP app, and rather than including just a variable hidden somewhere and then doing:</p> <pre><code>if($premium == true) { echo 'some additional functionality'; } else { echo 'basic functionality'; } </code></pre> <p>Obviously someone could then take the source and change that variable, and bang - they've stolen our code. And something like Ioncube etc is just totally unwieldy in my experience and support on hosting companies is just not good enough.</p> <p>I would prefer something.. perhaps similar to this:</p> <pre><code>## if premium ## echo 'some additional functionality'; ## else ## echo 'basic functionality'; ## endif ## </code></pre> <p>And then I would run two builds, one setting the premium to true and one to false, which would generate two files of simply:</p> <pre><code>echo 'some additional functionality'; </code></pre> <p>and</p> <pre><code>echo 'basic functionality'; </code></pre> <p>It would also be very helpful to be able to only include entire files based on this same condition passed to the build app.</p> <p>I can't find a way to do this but I am open to any alternative ideas if possible.</p> <p>Help would be outstanding,</p> <p><strong>UPDATE</strong></p> <p>Using the C preprocessor is great and looks like it does everything I need. However, I can't find how to do the following 3 things.</p> <p><strong>#1</strong> I need to remove the comments generated into the output files. Below is an example of those.</p> <pre><code># 1 "./index.php" # 1 "&lt;built-in&gt;" # 1 "&lt;command-line&gt;" # 1 "./index.php" </code></pre> <p>I haven't found an example of how to do this in the manual page you linked me to.</p> <p><strong>#2</strong> I need to make it recursively go through every discovered file. When I run my current code I get an error: <code>../target/./folder/test.php: No such file or directory</code></p> <p>So basically I have my 'source' folder which I'm in, which contains a subfolder called 'folder' and it doesn't recreate that, nor the files inside it (test.php)</p> <p><strong>#3</strong> I'm sure this one is easy - how can I get it to process .js files and probably .html just to be safe as well? In one call, I mean. I assume running it on .jpg etc etc files is a bad idea..</p> <p>Thanks again!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload