简体   繁体   English

在运行Ubuntu 12.04的Travis CI上使用APCu

[英]Using APCu on Travis CI, which runs Ubuntu 12.04

I have a Symfony-application which is dependent on APCu ( php5-apcu ). 我有一个依赖于APCu( php5-apcu )的Symfony应用程序。 The server is running PHP 5.6 on Ubuntu 15.04. 服务器在Ubuntu 15.04上运行PHP 5.6。 APCu is required as a dependency through composer, ie: 通过作曲家需要APCu作为依赖,即:

"require": {
    "ext-apc": "~4.0"
}

Which works great. 哪个效果很好。 Trying to get the application running on Travis-CI, isn't as smooth, since they run Ubuntu 12.04, which doesn't have the php5-apcu package, which yields: 试图让应用程序在Travis-CI上运行,并不是那么顺利,因为它们运行的​​是Ubuntu 12.04,它没有php5-apcu包,它产生:

E: Unable to locate package php5-apcu E:无法找到包php5-apcu

Installing php-apc doesn't satisfy the ext-apcu requirement, and I'd prefer not to promote deprecated packages. 安装php-apc不符合ext-apcu要求,我宁愿不推广已弃用的软件包。

Any suggestions on how to setup APCu on Travis CI? 有关如何在Travis CI上设置APCu的任何建议? Preferably without manually downloading the package. 优选地,无需手动下载包。

You can easily install the apcu extension from pecl. 您可以从pecl轻松安装apcu扩展。

Here is an example .travis.yml file: 这是一个示例.travis.yml文件:

language: php

php:
  - 5.6

before_script:
  - pear config-set preferred_state beta
  - yes '' | pecl install apcu

script:
  - cd tests/ && phpunit

If you need a more complex solution, for example multiple php versions, you should be able to easily adopt the solution from the doctrine/cache repository ( https://github.com/doctrine/cache/blob/master/.travis.yml ). 如果您需要更复杂的解决方案,例如多个php版本,您应该能够轻松采用doctrine / cache存储库中的解决方案( https://github.com/doctrine/cache/blob/master/.travis.yml )。 They run the tests against php 5.3 - 5.6 and hhvm with the following before_script: 他们使用以下的before_script运行针对php 5.3 - 5.6和hhvm的测试:

[...]
before_script:
    - [...]
    - sh -c "if [[ $TRAVIS_PHP_VERSION != 'hhvm' && `php-config --vernum` -ge 50500 ]] ; then pecl config-set preferred_state beta; printf "yes\n" | pecl install apcu ; else echo 'extension="apc.so"' >> ./tests/travis/php.ini ;fi"
    - [...]
[...]

Happy testing 快乐的测试

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

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