在什麼我this similar question發現的基礎上,我終於解決了這個辦法:
我安裝Phing,PHP項目構建系統或建立基於Apache Ant工具。
2.我創建了一個build.xml
文件,其中包括我這個目標:
<target name="preprocess" depends="prepare">
<foreach param="fname" absparam="abs-fname" target="preprocessfile">
<fileset dir="${build.dir}">
<patternset>
<include name="**/*.php"/>
</patternset>
</fileset>
</foreach>
</target>
<target name="preprocessfile">
<exec command="gcc -E -x c -P -C -D PREMIUM ${abs-fname} -Wno-invalid-pp-token -o ${abs-fname}"
escape="false"
checkreturn="true"
passthru="true" />
</target>
在實踐中,我啓動了GCC預處理器在每個PHP文件,我趁它做的正是我需要的。它工作得很好!
不僅:通過Phing,我創建了一些目標來進行PHP驗證,JavaScript縮小,創建要部署的歸檔等。
來源
2015-04-10 13:13:41
Dev
您是否需要爲lite組件提供公共代碼庫? –
如果您可以乾淨地將您的功能分成不同的文件,例如通過插件系統或類繼承,您可以使用任何要生成包含全部或僅包含文件子集的最終「二進制」的構建系統。 – deceze
您所需要的只是一種自動化的方式,如您所描述的那樣從完整源創建兩個「目標」。 我的建議是使用[Grunt] [1]。 PHP有很多包,我相信你可以用它們來構建你想要的東西。例如: - PHP CodeSniffer(https://npmjs.org/package/grunt-phpcs) - PHP掉毛 (https://npmjs.org/package/grunt-phplint) - PHPUnit的 (HTTPS: // npmjs。org/package/grunt-phpunit) - PHP分析器 (https://npmjs.org/package/grunt-php-analyzer) - PHP的內置 網絡服務器(https://npmjs.org/package/grunt -php) [1]:http://gruntjs.com – gbuzogany