简体   繁体   English

使用Symfony2在共享主机上安装/更新Composer的运行时异常

[英]Runtime exception with Composer install/update on shared hosting w/ Symfony2

I seem to be having some problems with cache permissions on shared hosting. 我似乎在共享主机的缓存权限上遇到了一些问题。 Specifically, when I try to install/update vendors via Composer, I get a runtime exception: 具体来说,当我尝试通过Composer安装/更新供应商时,出现运行时异常:

$ php composer.phar update -v -o

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.

Exception trace:
() at /home/thesewingdiva/private/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:137
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::executeCommand() at /home/thesewingdiva/private/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Composer/ScriptHandler.php:48
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Script/EventDispatcher.php:122
Composer\Script\EventDispatcher->executeEventPhpScript() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Script/EventDispatcher.php:101
Composer\Script\EventDispatcher->doDispatch() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Script/EventDispatcher.php:74
Composer\Script\EventDispatcher->dispatchCommandEvent() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Installer.php:237
Composer\Installer->run() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Command/UpdateCommand.php:82
Composer\Command\UpdateCommand->execute() at phar:///home/thesewingdiva/private/composer.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:238
Symfony\Component\Console\Command\Command->run() at phar:///home/thesewingdiva/private/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Console/Application.php:101
Composer\Console\Application->doRun() at phar:///home/thesewingdiva/private/composer.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:106
Symfony\Component\Console\Application->run() at phar:///home/thesewingdiva/private/composer.phar/src/Composer/Console/Application.php:74
Composer\Console\Application->run() at phar:///home/thesewingdiva/private/composer.phar/bin/composer:37
require() at /home/thesewingdiva/private/composer.phar:15

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]

I don't have the ability to use ACL, and I don't have the ability to use sudo since it's shared hosting. 我没有使用ACL的能力,也没有使用sudo的能力,因为它是共享主机。 The cache is set to 777 for it's permissions (recursive), and app/console, app.php, and app_dev.php all have umask(0000). 出于权限(递归)的原因,缓存设置为777,而app / console,app.php和app_dev.php都具有umask(0000)。 I've also erased the cache to see if that would help. 我还删除了缓存以查看是否有帮助。 No dice. 没有骰子。 Any ideas on how to fix this? 有想法该怎么解决这个吗?

In a comment under this question , it's pointed out that the issue has to do with a missing timezone setting. 此问题下的评论中,指出该问题与缺少时区设置有关。

What happens if you do "php app/console cache:clear --verbose" 如果您执行“ php应用程序/控制台缓存:clear --verbose”会发生什么?

I had this same issue for a while and after hours of face to brick wall pounding I realized... I have a .gitmodule in my project, and on initial checkout these submodules are NOT initialized and as such are not there for your composer to update, which results in the above error. 我有一段时间遇到同样的问题,在面对砖墙的重击后数小时,我意识到...我的项目中有一个.gitmodule,并且在最初签出时未初始化这些子模块,因此您的作曲家无法使用这些子模块更新,从而导致上述错误。

Make sure you run the following 确保运行以下命令

git submodule update --init src/Acme/Sadness/Bundle

of course replace src/Acme/Sadness/Bundle with YOUR project namespace. 当然用您的项目名称空间替换src / Acme / Sadness / Bundle

Hope this helps someone not go through the same pain I just did. 希望这可以帮助某人摆脱我刚才的痛苦。

To find out exact reason for exception, see the php error logs. 要找出异常的确切原因,请参阅php错误日志。 However, as mentioned by Jared Farrish, this could be due to not setting of timezone in php ini settings. 但是,正如Jared Farrish所述,这可能是由于未在php ini设置中设置时区。

#/etc/php5/cli/php.ini
date.timezone = 'Asia/Kolkata'
log_errors = On
error_log = /var/log/php/error.log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM