[英]TYPO3 - Loading external libraries in my Extbase extension with composer works in development context but not in production
I'm using TYPO3 6.2.26, I added to my extension an external library (sinergi/browser-detector) using composer. 我使用的是TYPO3 6.2.26,我使用composer向扩展中添加了一个外部库(sinergi / browser-detector)。 We have two servers one for development and another for production. 我们有两台服务器,一台用于开发,另一台用于生产。 The problem appear in the production context, but in development work it excellent. 该问题出现在生产环境中,但是在开发工作中却非常出色。
I have the next structure on both servers (git subversion): 我在两台服务器上都有下一个结构(git subversion):
myext/Resources/Private/composer.json
myext/Resources/Private/Libraries/autoload.php (generate by composer)
myext/Resources/Private/Libraries/sinergi/...
myext/Resources/Private/Libraries/composer/... (generate by composer)
myext/ext_autoload.php
I load the composer loader in the ext_autoload.php: 我在ext_autoload.php中加载composer loader:
require __DIR__ . '/Resources/Private/Libraries/autoload.php';
My composer.json look like this: 我的composer.json看起来像这样:
{
"name": "vendor/vendor",
"description": "My description",
"type": "library",
"require-dev": {
"sinergi/browser-detector": "^6.1"
},
"config": {
"vendor-dir": "Libraries"
},
"authors": [
{
"name": "xxx",
"email": "xxx"
}
]
}
With this configurations it works without problems in the development environment. 通过这种配置,它可以在开发环境中正常工作。 In production occurs a strange situation, when I delete the cache it works only one time, at the second time the web server returns a 500 Error: 在生产中会发生一种奇怪的情况,当我删除缓存时,它只能工作一次,第二次Web服务器返回500错误:
PHP Fatal Error: class Sinergi\\BrowserDetector\\...not found...
I tried some solution which I founded in Internet like: 我尝试了一些我在Internet中创建的解决方案,例如:
Adding to my composer.json: 添加到我的composer.json中:
"autoload": "prs-4": { "Sinergi\\BrowserDetector\\" : "Libraries/sinergi/browser-detector/src/" } “ autoload”:“ prs-4”:{“ Sinergi \\ BrowserDetector \\”:“库/ sinergi /浏览器检测器/ src /”}
Dumping the autoload 转储自动加载
composer dump-autoload 作曲家转储-自动加载
Disabling opcache 禁用opcache
Deleting composer.lock and new install 删除composer.lock和新安装
But, the problem is still there only in production. 但是,问题仍然只存在于生产中。 I remove too the content of the typo3temp directory, and then it works one time, but at the second 500 Error. 我也删除了typo3temp目录的内容,然后它可以工作一次,但是出现第二个500错误。 Do anybody know what can I make? 有人知道我能做什么吗?
I don't know how your files end up on production but you should use 我不知道您的文件最终会如何投入生产,但您应该使用
"require": {
"sinergi/browser-detector": "^6.1"
},
instead of require-dev
, otherwise, it is just for dev. 而不是require-dev
,否则,它仅适用于dev。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.