使用新的Symfony安装程序,我创建了一个项目:
symfony new project
问题Nº1
然后,我编辑了.gitignore
文件,将其重命名为.hgignore
(因为我使用的是Mercurial)。
编辑文件以满足我的需求,PHPStorm搜索文件用途。它找到了一些用途,主要是Sensio\Bundle\DistributionBundle\Composer\ScriptHandler.php
这个脚本似乎创建了.gitignore文件,这对我来说很奇怪。我想知道正在使用 WHEN 这个文件,或者它只是一次性运行脚本。
问题Nº2
尝试测试使用composer
时是否使用它,我安装了它。然后,按照Symfony How to deploy App
教程,我输入了composer install --no-dev --optimize-autoloader
,然后出现了这些错误:
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- sensiolabs/security-checker v2.0.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- sensiolabs/security-checker v2.0.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- Installation request for sensiolabs/security-checker v2.0.1 -> satisfiable by sensiolabs/security-checker[v2.0.1].
然后我再次运行它,我不知道为什么,但它不是相同的输出,它删除一个包:
composer install --no-dev --optimize-autoloader
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
- Removing sensio/generator-bundle (v2.5.3)
Generating optimized autoload files
Updating the "app/config/parameters.yml" file
PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /home/jsivil/Desktop/Proyectos/UNPAZ/secyt/app/AppKernel.php on line 27
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]
然后我运行了composer update
:
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
^[[B - Removing twig/twig (v1.18.0)
- Installing twig/twig (v1.18.1)
Downloading: 100%
- Removing doctrine/collections (v1.2)
- Installing doctrine/collections (v1.3.0)
Downloading: 100%
- Removing doctrine/cache (v1.4.0)
- Installing doctrine/cache (v1.4.1)
Downloading: 100%
- Removing doctrine/annotations (v1.2.3)
- Installing doctrine/annotations (v1.2.4)
Downloading: 100%
- Removing doctrine/common (v2.4.2)
- Installing doctrine/common (v2.5.0)
Downloading: 100%
- Removing sensiolabs/security-checker (v2.0.1)
- Installing sensiolabs/security-checker (v2.0.2)
Downloading: 100%
- Removing sensio/distribution-bundle (v3.0.20)
- Installing sensio/distribution-bundle (v3.0.22)
Downloading: 100%
- Removing sensio/framework-extra-bundle (v3.0.6)
- Installing sensio/framework-extra-bundle (v3.0.7)
Downloading: 100%
- Installing sensio/generator-bundle (v2.5.3)
Downloading: 100%
Writing lock file
Generating autoload files
Updating the "app/config/parameters.yml" file
Clearing the cache for the dev environment with debug true
Trying to install assets as symbolic links.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
The assets were installed using symbolic links.
Installing assets for Acme\DemoBundle into web/bundles/acmedemo
The assets were installed using symbolic links.
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
The assets were installed using symbolic links.
现在似乎很好,如何测试所有需要的东西?
我做了正确的命令吗?
感谢。
修改
当我运行composer install
时,PHP致命错误再次出现:
composer install --no-dev --optimize-autoloader
Loading composer repositories with package information
Installing dependencies from lock file
- Removing sensio/generator-bundle (v2.5.3)
Generating optimized autoload files
Updating the "app/config/parameters.yml" file
PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /home/jsivil/Desktop/Proyectos/UNPAZ/secyt/app/AppKernel.php on line 27
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [packages1] ... [packagesN]
答案 0 :(得分:1)
现在似乎很好,如何测试所有需要的东西?
我做了正确的命令吗?
如果再次运行composer update
,composer将检查是否已安装依赖项,如果没有错误,则表示所有内容都已正确安装。
当我运行
composer install
时,PHP致命错误再次出现:composer install --no-dev --optimize-autoloader … PHP Fatal error: Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /home/jsivil/Desktop/Proyectos/UNPAZ/secyt/app/AppKernel.php on line 27 …
一旦composer完成安装包,它就会启动一些Symfony2脚本(它们在 composer.json 中声明)。 SensioGeneratorBundle
被调用但未安装。
您可以使用--no-scripts
选项禁用这些脚本:
composer install --no-dev --optimize-autoloader --no-scripts
这将删除错误。
答案 1 :(得分:0)
您运行的命令应该是
composer install --optimize-autoloader
而不是
composer install --no-dev --optimize-autoloader
您运行的命令包含--no-dev指令,这意味着它不会导入任何dev dependendies(composer.json中require-dev下的条目)。
您的symfony框架当前正在开发模式下运行,并且期望正确安装dev资源。