我已将应用程序从Symfony 2.1升级到Symfony 3.4。当我在localhost中测试新应用程序时,它可以完美,快速地运行,甚至更快 比以前的应用程序。但是,当我在服务器上推送应用程序时,对于 新应用程序,而Symfony 2.1下的应用程序将在1秒内加载到他的服务器上。
两个版本中的数据库参数是相同的,我已经努力了很多天以找出问题所在。特别是 我不知道这是应用程序还是服务器出现问题。
为了更加精确,以下是这两个应用程序的详细信息:
升级前:
PHP 5.3
Symfony 2.1
VM上的Windows Server 2012
XAMPP
MySQL
加载时间:约1秒
composer.json文件:
{
"name" : "symfony/framework-standard-edition",
"license" : "MIT",
"type" : "project",
"description" : "The \"Symfony Standard Edition\" distribution",
"autoload" : {
"psr-0" : {
"" : "src/"
}
},
"require" : {
"php" : ">=5.3.3",
"symfony/symfony" : "2.1.13",
"doctrine/orm" : ">=2.2.3,<2.5-dev",
"doctrine/doctrine-bundle" : "1.1.*",
"twig/extensions" : "1.0.*@dev",
"symfony/assetic-bundle" : "2.1.*",
"symfony/swiftmailer-bundle" : "2.1.*",
"symfony/monolog-bundle" : "2.1.*",
"sensio/distribution-bundle" : "2.1.*",
"sensio/framework-extra-bundle" : "2.1.*",
"sensio/generator-bundle" : "2.1.*",
"jms/security-extra-bundle" : "1.2.*",
"jms/di-extra-bundle" : "1.1.*",
"kriswallsmith/assetic" : "1.1.*@dev",
"besimple/sso-auth-bundle" : "dev-master",
"besimple/soap" : "0.2.*@dev",
"friendsofsymfony/user-bundle" : "~1.3",
"sonata-project/admin-bundle" : "2.1.*",
"sonata-project/cache-bundle" : "2.1.*",
"sonata-project/easy-extends-bundle" : "2.1.*",
"sonata-project/doctrine-orm-admin-bundle" : "2.1.*@dev",
"sonata-project/user-bundle" : "2.1.*",
"noiselabs/nusoap-bundle" : "dev-master",
"sonata-project/intl-bundle" : "2.1.*",
"whiteoctober/breadcrumbs-bundle": "dev-master"
},
"repositories" : [{
"type" : "package",
"package" : {
"name" : "nusphere/nusoap",
"version" : "0.9.5",
"dist" : {
"url" : "http://downloads.sourceforge.net/project/nusoap/nusoap/0.9.5/nusoap-0.9.5.zip",
"type" : "zip"
},
"autoload" : {
"classmap" : [
"lib/"
]
}
}
}
],
"scripts" : {
"post-install-cmd" : [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd" : [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"extra" : {
"symfony-app-dir" : "app",
"symfony-web-dir" : "web",
"branch-alias" : {
"dev-master" : "2.1-dev"
}
}
}
升级后:
PHP 7.2
Symfony 3.4
VM上的Windows Server 2016
XAMPP
MySQL(两个应用程序中调用了相同的数据库)
加载时间:2分钟
composer.json文件:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.5.9",
"besimple/sso-auth-bundle": "dev-master",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"jms/security-extra-bundle": "^1.6",
"phpoffice/phpspreadsheet": "^1.6",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"sonata-project/admin-bundle": "^3.48",
"sonata-project/cache-bundle": "^3.0",
"sonata-project/doctrine-orm-admin-bundle": "^3.8",
"sonata-project/user-bundle": "^4.0",
"symfony/assetic-bundle": "^2.8",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0",
"whiteoctober/breadcrumbs-bundle": "^1.4"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"symfony-scripts": [
"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::prepareDeploymentTarget"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
},
"config": {
"platform": {
"php": "7.2.6"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "3.4-dev"
}
}
}
您知道为什么新应用程序中会有这样的加载时间吗?
谢谢。
编辑:
您好,@ habibun,谢谢您的回答。
下面是探查器中的性能图片:
问题似乎是由于需要105秒的“控制器”行所致。有没有办法减少这条线的加载时间?
此外,您能告诉我如何在Symfony 3.4上浏览config.php吗?我应该使用哪个命令?抱歉,如果我问一个愚蠢的问题,我是Symfony的新手。