简体   繁体   English

Symfony Pdfbundle不起作用

[英]Symfony Pdfbundle not working

When trying to use pdfBundle with symfony I get the following error, all i've done so far is installed pdfbundle via symfony and registered it in app.php. 当尝试将symfony与pdfBundle结合使用时,出现以下错误,到目前为止,我所做的所有事情都是通过symfony安装pdfbundle并将其注册到app.php中的。

Catchable fatal error: Argument 1 passed to Silex\Application::register() must implement interface Silex\ServiceProviderInterface, instance of Ps\PdfBundle\PsPdfBundle given, called in C:\wamp\www\computername\Project1\app\bootstrap.php on line 20 and defined in C:\wamp\www\computername\Project1\vendor\silex\silex\src\Silex\Application.php on line 165

My composer file looks like this: 我的作曲者文件如下所示:

{
"require": {
    "silex/silex": "~1.1",
    "components/jquery": "2.1.0",
    "twig/twig": "1.18.0",
    "symfony/twig-bridge": "2.3.*",
    "psliwa/pdf-bundle": "dev-master",
    "knplabs/repository-service-provider": "dev-master",
    "sensio/framework-extra-bundle": "3.0.7"
},
"autoload": {
    "psr-0": {
        "Defensie": "src/"
    }
}

} }

App.php: App.php:

....
$app->register(new Ps\PdfBundle\PsPdfBundle());
....

If there's more information you need, go ahead and ask. 如果您需要更多信息,请继续询问。

trying to use pdfBundle with symfony 试图将pdfBundle与symfony一起使用

First of all that it looks like you are using Silex that is micro-framework based on Symfony2. 首先,看起来您正在使用基于Symfony2的微框架Silex。

So you try to use Symfony2 bundle, but register it as Silex service provider. 因此,您尝试使用Symfony2捆绑包,但将其注册为Silex服务提供商。

$app->register(new Ps\PdfBundle\PsPdfBundle());

You can't just connect 3rd party bundles from Symfony2 with Silex. 您不能仅将Symfony2的第三方捆绑包与Silex连接。 Silex uses a "ServiceProviderInterface" to connect 3rd party bundles. Silex使用“ ServiceProviderInterface”连接第三者包。 http://silex.sensiolabs.org/doc/providers.html http://silex.sensiolabs.org/doc/providers.html

interface ServiceProviderInterface
{
    public function register(Application $app);

    public function boot(Application $app);
}

So either a bundle should have already implemented service provider to integrate it to Silex or you must to implement it self to connect 3rd party lib. 因此,捆绑软件应该已经实施了服务提供商以将其集成到Silex,或者必须自行实施以连接第三方库。 Here is some example how to create service provider to integrate Buzz client http://php-and-symfony.matthiasnoback.nl/2012/02/silex-creating-a-service-provider-for-buzz/ 这是一些示例,说明如何创建服务提供商以集成Buzz客户端http://php-and-symfony.matthiasnoback.nl/2012/02/silex-creating-a-service-provider-for-buzz/

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

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