Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经创建了我的框架的 phar 文件。在框架中运行 cron-jobs 的方式是在命令行调用执行 pharfile:
php path/to/archive.phar cron -r /path/to/site
存档中的引导文件用于比较_FILE_的路径和执行命令的解析路径,以确定它已被直接执行。
问题是:是否可以从 phar 文件中获取 phar 文件的文件名,以及如何获取?
那就是:phar文件中_FILE_的替代品是什么?
你可以使用它:
<?php $a = Phar::running(); // $a is "phar:///path/to/my.phar"
就像在docs中一样。
我已经对此事进行了一些研究,似乎不可能不产生太多开销。
我发现的唯一可行的方法是打开从 $argv[0] 获得的“嫌疑人”并通过检查内容进行检查 - 但是,这涉及大量额外的磁盘 IO。