首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何通过作曲家安装第三方库到Symfony 3.1?

如何通过作曲家安装第三方库到Symfony 3.1?
EN

Stack Overflow用户
提问于 2016-10-13 17:24:01
回答 3查看 670关注 0票数 0

我正在尝试使用Symfony 3.1开发一个web应用程序,我需要使用一些外部库,比如费克口香糖。但是,每次我尝试用这样的作曲家安装它们时:

代码语言:javascript
运行
复制
composer require fzaninotto/Faker

它总是抛出这样的错误:

代码语言:javascript
运行
复制
Using version ^1.6 for fzaninotto/Faker
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing fzaninotto/faker (v1.6.0)
    Loading from cache

Writing lock file
Generating autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Updating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache


  [Symfony\Component\Config\Exception\FileLoaderLoadException]
  There is no extension able to load the configuration for "service" (in C:\xampp\htdocs\myapp\app/config\config.yml). Looked for namespace "service", found "framework", "securi
  ty", "twig", "monolog", "swiftmailer", "doctrine", "doctrine_migrations", "sensio_framework_extra", "debug", "web_profiler", "sensio_distribution" in C:\xampp\htdocs\myapp\app
  /config\config.yml (which is being imported from "C:\xampp\htdocs\myapp\app/config/config_dev.yml").



  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
  There is no extension able to load the configuration for "service" (in C:\xampp\htdocs\myapp\app/config\config.yml). Looked for namespace "service", found "framework", "securi
  ty", "twig", "monolog", "swiftmailer", "doctrine", "doctrine_migrations", "sensio_framework_extra", "debug", "web_profiler", "sensio_distribution"


Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

Installation failed, reverting ./composer.json to its original content.


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


    [Symfony\Component\Config\Exception\FileLoaderLoadException]

    There is no extension able to load the configuration for "service" (in C:\xampp\htdocs\myapp\app/config\config.yml). Looked for namespace "service", found "framework
  ", "securi
    ty", "twig", "monolog", "swiftmailer", "doctrine", "doctrine_migrations", "sensio_framework_extra", "debug", "web_profiler", "sensio_distribution" in C:\xampp\htdocs\res
  epkita\app
    /config\config.yml (which is being imported from "C:\xampp\htdocs\myapp\app/config/config_dev.yml").





    [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]

    There is no extension able to load the configuration for "service" (in C:\xampp\htdocs\myapp\app/config\config.yml). Looked for namespace "service", found "framework
  ", "securi
    ty", "twig", "monolog", "swiftmailer", "doctrine", "doctrine_migrations", "sensio_framework_extra", "debug", "web_profiler", "sensio_distribution"



  .


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

我真的需要使用第三方symfony包吗?还是如何使用“原样”库?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-10-13 17:40:48

您似乎已经在config_dev.yml中放置了一个“服务”块,这意味着没有安装与该配置相关联的包。

只需删除"service“块,您就会没事,因为清洁安装symfony并运行。

代码语言:javascript
运行
复制
composer require fzaninotto/Faker

就像一种魅力。

票数 2
EN

Stack Overflow用户

发布于 2016-10-13 17:52:12

只需输入config.yml文件,就可以编写service:而不是services:

票数 1
EN

Stack Overflow用户

发布于 2016-10-13 17:40:31

您可以用这样的作曲家自动加载第三方库。

代码语言:javascript
运行
复制
// composer.json
{
    // ...

    "autoload": {
        "psr-4": {
            "Custom\\Namespace\\": "relative/path/to/library"
        }
    }
}

路径必须相对于包根。

您可以在作曲家文档中找到更多的信息。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40027309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档