Search code examples
symfonynginxcomposer-phpvendor

symfony 2.8 preprod deployement error 500 on nginx


I tried to deployed my symfony 2.8 app on an nginx prepod server. Project is working fine on local nginx server and on an other nginx test server.

I followed :

git clone the project
composer install --optimize-autoloader
cache:clear --env=prod

I have no use of doctrine in my project i'm using an api.

I got several errors in my nginx error.log because I try to lauch composer install and composer update several times because iI thought it was a vendor installation trouble.

here are the differents error i got :

Cannot redeclare class Symfony\Component\Config\Resource\SelfCheckingResourceChecker in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/SelfCheckingResourceChecker.php on line 24 Cannot redeclare class symfony\component\classloader\apcclassloader Interface 'Symfony\Component\EventDispatcher\EventDispatcherInterface' not found in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php on line 29" Interface 'Symfony\Component\Config\Resource\ResourceInterface' not found in /home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Config/Resource/SelfCheckingResourceInterface.php on line 21" Interface 'Symfony\Component\Routing\Matcher\RequestMatcherInterface' not found in /home/l4mmobile/public_html/v2/app/cache/prod/classes.php Interface 'Symfony\Component\Routing\RequestContextAwareInterface' not found in home/l4mmobile/public_html/v2/vendor/symfony/symfony/src/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php on line 24"

app.php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
$apcLoader = new ApcClassLoader('l4m_site_mobile_v2', $loader);
$loader->unregister();
$apcLoader->register(true);
require_once __DIR__.'/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

composer.json

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-4": {
        "": "src/",
        "SymfonyStandard\\": "app/SymfonyStandard/"
    }
},
"require": {
    "php": ">=5.4.4",
    "symfony/symfony": "~2.8",
    "doctrine/orm": "~2.2,>=2.2.3,<2.5",
    "doctrine/dbal": "<2.5",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/assetic-bundle": "~2.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~4.0",
    "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "guzzle/guzzle": "3.9.*",
    "guzzlehttp/guzzle" : "5.3.1",
    "keeguon/oauth2-php": "1.3.6",
    "facebook/php-sdk": "3.2.0",
    "friendsofsymfony/facebook-bundle": "1.3.0",
    "symfony/intl": "^2.8",
    "monolog/monolog": "^1.20",
    "twig/extensions": "^1.4"
},
 "require-dev": {
    "sensio/generator-bundle": "~2.3"
},
"scripts": {
    "post-root-package-install": [
        "SymfonyStandard\\Composer::hookRootPackageInstall"
    ],
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
     "symfony-assets-install": "relative",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.8-dev"
    }
}

}


Solution

  • hope my struggling can help other developers. i use this bundleto clear the apc cache and things got back to normal