Troubleshooting “require_once(../bootstrap.php.cache): failed to open stream: No such file or directory”

匿名 (未验证) 提交于 2019-12-03 01:56:01

问题:

I am trying to redeploy a Symfony 2.1x project I have been working on and app_dev.php is failing because it can't find app/bootstrap.php.cache. This file is omitted from the project's git repository because I used Symfony2's recommend .gitignore file:

# .gitignore /app/bootstrap* 

Am I correct in thinking that app/bootstrap.php.cache is generated during the $ php composer.phar install process? If this is the case then I will include for you my composer.json:

// composer.json {     "name": "symfony/framework-standard-edition",     "description": "The \"Symfony Standard Edition\" distribution",     "autoload": {         "psr-0": { "": "src/" }     },     "require": {         "php": ">=5.3.3",         "symfony/symfony": "2.1.*",         "doctrine/orm": "2.2.*",         "doctrine/doctrine-bundle": "dev-master",         "twig/extensions": "dev-master",         "symfony/assetic-bundle": "dev-master",         "symfony/swiftmailer-bundle": "dev-master",         "symfony/monolog-bundle": "dev-master",         "sensio/distribution-bundle": "dev-master",         "sensio/framework-extra-bundle": "dev-master",         "sensio/generator-bundle": "dev-master",         "jms/security-extra-bundle": "1.1.*",         "jms/di-extra-bundle": "1.0.*",         "ddeboer/guzzle-bundle": "dev-master",         "mopa/bootstrap-bundle": "dev-master",         "twitter/bootstrap": "master",         "knplabs/knp-paginator-bundle": "dev-master",         "knplabs/knp-menu-bundle": "dev-master",         "craue/formflow-bundle": "dev-master"     },     "repositories": [         {             "type": "package",             "package": {                 "version": "master",                 "name": "twitter/bootstrap",                 "source": {                     "url": "https://github.com/twitter/bootstrap.git",                     "type": "git",                     "reference": "master"                 },                 "dist": {                     "url": "https://github.com/twitter/bootstrap/zipball/master",                     "type": "zip"                 }             }         }     ],     "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"         ],         "post-install-cmd": [             "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"         ],         "post-update-cmd": [             "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"         ]     },     "config": {         "bin-dir": "bin"     },     "minimum-stability": "dev",     "extra": {         "symfony-app-dir": "app",         "symfony-web-dir": "web"     } } 

How can I generate bootstrap.php.cache?

回答1:

Just go to your project and generate it with composer like

php /path/to/composer/composer.phar install 


回答2:

Just run the following command.

php composer.phar install 

Source: http://symfony.com/doc/master/book/performance.html#use-bootstrap-files



回答3:

You have duplicated post-install-cmd and post-updated-cmd while you should have added MopaBootstrapBundle scripts to existing keys. Try the following composer.json and re-run php composer.phar install

{     "name": "symfony/framework-standard-edition",     "description": "The \"Symfony Standard Edition\" distribution",     "autoload": {         "psr-0": { "": "src/" }     },     "require": {         "php": ">=5.3.3",         "symfony/symfony": "2.1.*",         "doctrine/orm": "2.2.*",         "doctrine/doctrine-bundle": "dev-master",         "twig/extensions": "dev-master",         "symfony/assetic-bundle": "dev-master",         "symfony/swiftmailer-bundle": "dev-master",         "symfony/monolog-bundle": "dev-master",         "sensio/distribution-bundle": "dev-master",         "sensio/framework-extra-bundle": "dev-master",         "sensio/generator-bundle": "dev-master",         "jms/security-extra-bundle": "1.1.*",         "jms/di-extra-bundle": "1.0.*",         "ddeboer/guzzle-bundle": "dev-master",         "mopa/bootstrap-bundle": "dev-master",         "twitter/bootstrap": "master",         "knplabs/knp-paginator-bundle": "dev-master",         "knplabs/knp-menu-bundle": "dev-master",         "craue/formflow-bundle": "dev-master"     },     "repositories": [         {             "type": "package",             "package": {                 "version": "master",                 "name": "twitter/bootstrap",                 "source": {                     "url": "https://github.com/twitter/bootstrap.git",                     "type": "git",                     "reference": "master"                 },                 "dist": {                     "url": "https://github.com/twitter/bootstrap/zipball/master",                     "type": "zip"                 }             }         }     ],     "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",             "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"         ],         "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",             "Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap"         ]     },     "config": {         "bin-dir": "bin"     },     "minimum-stability": "dev",     "extra": {         "symfony-app-dir": "app",         "symfony-web-dir": "web"     } } 


回答4:

You just need to run

php composer.phar install 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!