我是 Symfony 的新手,我正在尝试使用 Sonata 和 Doctrine ORM 创建一个数据库接口。起初,我已经阅读了本教程,几天后它开始在我的 VirtualBox 机器 Ubuntu 服务器上运行。
现在,我正在尝试在另一个包中使用奏鸣曲管理员。
所以,我在这里有我的 SonataAdminBundle:
/var/www/Symfony/testsonata/src/Application/Sonata
这里还有新的捆绑包:
/var/www/Symfony/testsonata/src/Application/MyDbBundle
我m trying to use [this man](http://symfonydev.ru/symfony-back-and-front-interfaces/) (it
是俄语)。
接下来,在我ve got working Sonata, I
创建了一个新包之后:
$ php app/console generate:bundle --namespace=Application/MyDbBundle
You are going to generate a "Application\MyDbBundle\MyDbBundle" bundle
in "/var/www/Symfony/testsonata/src/" using the "annotation" format.
然后,我运行了以下命令:
$ php app/console doctrine:mapping:import MyDbBundle xml --filter=Link
writing /var/www/Symfony/testsonata/src/Application/MyDbBundle/Resources/config/doctrine/Link.orm.xml
$ php app/console doctrine:generate:entities --path="/var/www/Symfony/testsonata/src" MyDbBundle:Link
Generating entities for namespace "Application\MyDbBundle\Entity\Link"
> backing up Link.php to Link.php~
> generating Application\MyDbBundle\Entity\Link
我想做的最后一件事是创建一个管理类和一个服务描述
我创建了这个文件/var/www/Symfony/testsonata/src/Application/MyDbBundle/Admin/LinkAdmin.php
,其中包含:
<?php
namespace Application\MyDbBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Knp\Menu\ItemInterface as MenuItemInterface;
use My\DbBundle\Entity\Link;
class LinkAdmin extends Admin
{
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper->add('title')
->add('url');
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper->addIdentifier('title')
->add('url')
->add('updatedAt');
}
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper->add('title')
->add('url')
->add('annotation');
}
}
我将此添加到我的services.xml
:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sonata.admin.my.db.link" class="Application\MyDbBundle\Admin\LinkAdmin">
<tag name="sonata.admin" manager_type="orm" group="Databases" label="Links"/>
<argument/>
<argument>Application\MyDbBundle\Entity\Link</argument>
<argument>SonataAdminBundle:CRUD</argument>
</service>
</services>
</container>
当我去
http://localhost/Symfony/testsonata/web/app_dev.php/admin/dashboard
我收到这条消息:
InvalidArgumentException:[ERROR 94] 验证失败:未找到 DTD!(在 n/a - 第 5 行,第 20 列)[错误 5] 文档末尾的额外内容(在 n/a - 第 22 行,第 1 列)
我究竟做错了什么?