简体   繁体   English

我可以将PHPUnit打包为phar吗?

[英]Can I package PHPUnit as a phar?

I would like to package PHPUnit and various other test dependencies into a phar and put that into svn. 我想将PHPUnit和各种其他测试依赖项打包成一个phar并将其放入svn。 This way I can run phpunit on any client machine without needing pear. 这样我就可以在任何客户端机器上运行phpunit而无需使用pear。 Can this be done? 可以这样做吗?

Current status: 当前状态:

Work on a phpunit.phar has started in the phpunit repo but the generated phar is not stable and not feature complete. 关于phpunit.phar的工作已在phpunit repo启动,但生成的phar不稳定且功能不完整。

If it gets there there will be official releases 如果它到达那里将有官方发布


Original answer: 原始答案:

If you can I'll give you 500 rep, a 100 Bucks and my first born.. well no.. just the first two. 如果你能,我会给你500个代表,100个雄鹿和我的第一个出生......好吧没有..只是前两个。

To be serious: 要认真:

I've nagged the creator of PHPUnit about this topic on at least 3 conferences now and well.. it doesn't seem like it's possible. 我已经在至少3次会议上唠叨PHPUnit的创建者关于这个话题现在好了......看起来似乎不太可能。

There are a couple of issues with that. 这有几个问题。 First off PHPUnit spawns new php processes for test isolation. 首先,PHPUnit会生成用于测试隔离的新php进程。 The problem with this is that a phar can't tell which php executable called it. 这个问题是一个phar无法分辨哪个php可执行文件调用它。 So if you start phpunit with a custom compiled version it would use the "default" php installed to spawn the isolated tests. 因此,如果您使用自定义编译版本启动phpunit,它将使用安装的“默认”php来生成隔离的测试。

Secondly as far as i know and have been told it's not possible to put static files like images and css in a phar. 其次据我所知并且被告知不可能将像图像和css这样的静态文件放在phar中。 Which makes generating code coverage a lot harder. 这使得生成代码覆盖更加困难。 That would require some work on that part. 这需要在这方面做一些工作。

There are other issues i can't recall exactly recall right having to do with xDebug being able to provide code coverage for phars (and phpunit relying on not generating overage for it's own code and so) and others things. 还有其他一些我无法回想起的问题,正好与XDebug能够为phars提供代码覆盖(以及phpunit依赖于不为其自己的代码生成过剩等)以及其他事情。

There once was a phar but from my understanding that just doesn't work out with the current state of phpunit and never really worked completly. There once was a phar但是从我的理解,只是不使用PHPUnit的当前工作状态并没有真正完全地工作。


I'm not saying it can't be done just that various people already have given up on creating a phpunit.phar including the guy how develops it. 我并不是说不可能只是因为各种各样的人已经放弃了创建一个phpunit.phar,包括如何开发它的人。 (That is just my impression, i of course can't speak for Sebastian here and might be completely wrong, take this as a little disclaimer) (这只是我的印象,我当然不能在这里代表塞巴斯蒂安而且可能完全错了,把这作为一个小小的免责声明)

Putting PHPUnit into SVN 将PHPUnit放入SVN

You don't have to build a .phar to do so! 您不必构建.phar就可以了!

For my company I maintain a svnd version of PHPUnit. 对于我的公司,我维护了PHPUnit的svnd版本。 It's not the recommended way of using it but it works without much issues! 这不是推荐的使用方式,但它没有太多问题!

Follow the "using from a git checkout" instructions on the phpunit github site . 按照phpunit github网站上"using from a git checkout"说明进行操作 You then need to put those files into your php include path and it works. 然后,您需要将这些文件放入您的php包含路径,它的工作原理。

My suggestion would be to create a custom phpunit.sh that modifies the include path and then calls the original phpunit.sh passing along all arguments. 我的建议是创建一个自定义的phpunit.sh来修改包含路径,然后调用原始的phpunit.sh传递所有参数。 It's a little bit of work but it works quite well and it is a hell of a lot easier than creating a phar archive :) 这是一个小工作,但它工作得很好,这比创建一个phar存档容易得多:)

From the new PHPUnit page : 从新的PHPUnit页面

We distribute a PHP Archive (PHAR) that contains everything you need in order to use PHPUnit. 我们分发一个PHP Archive(PHAR),其中包含您使用PHPUnit所需的一切。 Simply download it from here , make it executable, and put it into your $PATH, for instance...... 只需从这里下载它,使其可执行,并将其放入$ PATH,例如......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM