简体   繁体   中英

symfony OAuth2 Validation failed: no DTD found

i use this tutorial http://blog.tankist.de/blog/2013/07/17/oauth2-explained-part-2-setting-up-oauth2-with-symfony2-using-fosoauthserverbundle/

i have error

php app/console doctrine:schema:update --dump-sql



  [Symfony\Component\Config\Exception\FileLoaderLoadException]                                                                                     
  Cannot import resource "/home/miejsce/public_html/src/Acme/DemoBundle/Resources/config/services.xml" from "/home/miejsce/public_html/app/config  
  /config.yml". (Unable to parse file "/home/miejsce/public_html/src/Acme/DemoBundle/Resources/config/services.xml".)                              






  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]                           
  Unable to parse file "/home/miejsce/public_html/src/Acme/DemoBundle/Resources/config/services.xml".  



  [InvalidArgumentException]                                                      
  [ERROR 94] Validation failed: no DTD found ! (in n/a - line 2, column 12)       
  [ERROR 5] Extra content at the end of the document (in n/a - line 7, column 1) 

services.xml fils is copy and paste from manual here is source

<!-- src/Acme/DemoBundle/Resources/config/services.xml -->
<parameters>
    <parameter key="platform.entity.user.class">Acme\DemoBundle\Entity\User</parameter>
    <parameter key="platform.user.provider.class">Acme\DemoBundle\Provider\UserProvider</parameter>
</parameters>

<services>
<service id="platform.user.manager" class="Doctrine\ORM\EntityManager"
         factory-service="doctrine" factory-method="getManagerForClass">
    <argument>%platform.entity.user.class%</argument>
</service>

<service id="platform.user.repository"
         class="Acme\DemoBundle\Repository\UserRepository"
         factory-service="platform.user.manager" factory-method="getRepository">
    <argument>%platform.entity.user.class%</argument>
</service>

<service id="platform.user.provider" class="%platform.user.provider.class%">
    <argument type="service" id="platform.user.repository" />
</service>
</services>

only one diffrence i make from manual - i add

imports: ** - { resource: @AcmeDemoBundle/Resources/config/services.xml }

to config.yml is need i think

where i can have error ?

UPDATE1

i revrite config to yml now have

parameters:
    platform.entity.user.class: Acme\DemoBundle\Entity\User
    platform.user.provider.class: Acme\DemoBundle\Provider\UserProvider
services:
    platform.user.manager:
        class:            "%doctrine.entity_managers%"
        factory_service:  doctrine
        factory_method:   getManagerForClass
        arguments:
                    - "%platform.entity.user.class%"
    platform.user.repository:
        class:            Acme\DemoBundle\Repository\UserRepository
        factory_service:  platform.user.manager
        factory_method:   getRepository
        arguments:
                    - "%platform.entity.user.class%"

    platform.user.provider:
        class:            "%platform.user.provider.class%"
        arguments:
                    - "@platform.user.repository"

sory still is error :

php app/console doctrine:schema:update --force
PHP Warning:  DOMElement::setAttribute() expects parameter 2 to be string, array given in /home/miejsce/public_html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php on line 117
PHP Warning:  strpos() expects parameter 1 to be string, array given in /home/miejsce/public_html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php on line 508
PHP Notice:  Array to string conversion in /home/miejsce/public_html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php on line 508
PHP Notice:  Array to string conversion in /home/miejsce/public_html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php on line 508
Nothing to update - your database is already in sync with the current entity metadata.

When i run i get succes:

php app/console acme:oauth-server:client:create --redirect-uri="http://clinet.local/" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials"
Added a new client with public id 3_4gn1mzg8lnackso0s8c0o0gk004sgkog4000o4gg8ss4s40g4, secret 6bq5vs50kuossgs08ccsgskwc0ow4ssosw8k084cgk0w0wo8cg

but on page

FatalErrorException: Compile Error: Cannot redeclare class Acme\\DemoBundle\\SecurityController in /home/miejsce/public_html/src/Acme/DemoBundle/Controller/SecurityController.php line 0

You are trying to import an XML services file from a YML config file. The YML reader follows the import and tries to parse the XML which gives an error.

Why do you need to do that import? If it is really needed maybe you cant try to rewrite the XML services config in YML

Please use reference implementation for this blog article to troubleshoot troubles like this.

The file you are interested in is here: https://github.com/iamtankist/oauth-server/blob/master/src/StarkIndustries/IronWallBundle/Resources/config/services.xml

Reference implementation all together: https://github.com/iamtankist/oauth-server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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