Bluemix上的Laravel 5应用程序

时间:2015-05-05 10:39:31

标签: php laravel composer-php ibm-cloud

我一直无法使用laravel 4.2和5.0将我的laravel应用程序部署到bluemix。 这是blumix日志中的错误:

2015-05-01T16:52:49.71+0100 [STG/0] ERR [UnexpectedValueException]
2015-05-01T16:52:49.71+0100 [STG/0] ERR Could not parse version constraint ^1.2.2: Invalid version string “^1.2.2″
2015-05-01T16:52:49.71+0100 [STG/0] ERR install [–prefer-source] [–prefer-dist] [–dry-run] [–dev] [–no-dev] [–no-plugins] [–no-custom-installers] [–no-scripts] [–no-progress] [-v|vv|vvv|–verbose] [-o|–optimize-autoloader] [–ignore-platform-reqs] [packages1] … [packagesN]
2015-05-01T16:52:49.73+0100 [STG/0] OUT —–> Composer command failed
2015-05-01T16:52:49.73+0100 [STG/0] ERR Traceback (most recent call last):
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/scripts/compile.py”, line 51, in
2015-05-01T16:52:49.73+0100 [STG/0] ERR .from_build_pack(‘lib/additional_commands’)
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/lib/build_pack_utils/builder.py”, line 189, in extensions
2015-05-01T16:52:49.73+0100 [STG/0] ERR process_extension(path, ctx, ‘compile’, process, args=[self])
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/lib/build_pack_utils/utils.py”, line 69, in process_extension
2015-05-01T16:52:49.73+0100 [STG/0] ERR success(getattr(extn, to_call)(*args))
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/extensions/composer/extension.py”, line 359, in compile
2015-05-01T16:52:49.73+0100 [STG/0] ERR return composer.compile(install)
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/lib/extension_helpers.py”, line 154, in compile
2015-05-01T16:52:49.73+0100 [STG/0] ERR self._compile(install)
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/extensions/composer/extension.py”, line 162, in _compile
2015-05-01T16:52:49.73+0100 [STG/0] ERR self.run()
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/extensions/composer/extension.py”, line 244, in run
2015-05-01T16:52:49.73+0100 [STG/0] ERR *self._ctx[‘COMPOSER_INSTALL_OPTIONS’])
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/extensions/composer/extension.py”, line 289, in run
2015-05-01T16:52:49.73+0100 [STG/0] ERR shell=True)
2015-05-01T16:52:49.73+0100 [STG/0] ERR File “/tmp/buildpacks/php-buildpack/lib/build_pack_utils/runner.py”, line 109, in stream_output
2015-05-01T16:52:49.73+0100 [STG/0] ERR raise CalledProcessError(retcode, cmd)
2015-05-01T16:52:49.73+0100 [STG/0] ERR build_pack_utils.runner.CalledProcessError: Command ‘<open file '’, mode ‘w’ at 0x28b9420>’ returned non-zero exit status 1
2015-05-01T16:52:49.76+0100 [STG/0] OUT Staging failed: Buildpack compilation step failed
2015-05-01T16:52:50.02+0100 [API/3] ERR Encountered error: App staging failed in the buildpack compile phase

这是composer.lock文件失败的地方:

“require”: {
“nikic/php-parser”: “^1.2.2″,
“php”: “>=5.3.3″,
“symfony/console”: “~2.1″,
“symfony/filesystem”: “~2.1″,
“symfony/finder”: “~2.1″
},

^1.2.2正是它所抱怨的。对于如何解决这个问题,有任何的建议吗?提前谢谢。

3 个答案:

答案 0 :(得分:3)

您使用的是哪个版本的PHP buildpack?您可以使用-b https://github.com/cloudfoundry/php-buildpack选项推送您的应用,尝试使用最新的社区版本。

我知道使用早期版本的buildpack(v3.1.0),您实际上需要在一个文件中指定一个名为COMPOSER_VERSION的特殊属性,该文件与您的应用程序一起推送,名为options.json

示例options.json:

{
  "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "fpm", "tokenizer", "curl", "mcrypt", "mbstring", "pdo"],
  "PHP_VERSION": "PHP_55_LATEST",
  "COMPOSER_VENDOR_DIR":"htdocs/vendor",
  "COMPOSER_VERSION": "latest",
  "WEBDIR": "htdocs/public"
}

来源:https://github.com/cloudfoundry/php-buildpack/issues/47#issuecomment-82972562

有关此配置文件的更多信息,请访问https://github.com/cloudfoundry/php-buildpack/blob/master/docs/config.md

答案 1 :(得分:1)

您可以在本地运行composer update以确保您的composer.lock是最新的。还要确保你没有将composer.phar推送到Bluemix。您可以通过在代码根目录中创建.cfignore文件,然后添加您不想上传到该文件的文件/目录的名称来阻止任何文件被推送到Bluemix。

答案 2 :(得分:0)

感谢您的回答。我确实有.cfignore文件,我确实使用了v3.1.0。

无论如何,作为临时修复,我用&gt; =&lt;替换了所有^相应的值,尽管不需要更新版本的buildpack。

此外,PHP版本需要包含在{}中,以便bluemix正确地选择它:“PHP_VERSION”:“{PHP_55_LATEST}”

由于