MolinaM
MolinaM

Reputation: 1

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. 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):

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:

require __DIR__ . '/Resources/Private/Libraries/autoload.php';

My composer.json look like this:

{
    "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:

PHP Fatal Error: class Sinergi\\BrowserDetector\\...not  found...

I tried some solution which I founded in Internet like:

  1. Adding to my composer.json:

    "autoload": "prs-4": { "Sinergi\BrowserDetector\" : "Libraries/sinergi/browser-detector/src/" }

  2. Dumping the autoload

    composer dump-autoload

  3. Disabling opcache

  4. Deleting composer.lock and new install

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. Do anybody know what can I make?

Upvotes: 0

Views: 679

Answers (1)

Georg Ringer
Georg Ringer

Reputation: 7939

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.

Upvotes: 1

Related Questions