1

我已经配置了 SonataAdmin 捆绑包,但是当我打算加载 admin/dashboard 时遇到了随机内存问题,

这是我的 2 个包含 Sonata CRUD 的实体:

namespace Jade\ReveBundle\Admin;

use Doctrine\Common\Collections\Collection;

use Jade\ReveBundle\Entity\Thematique;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;

class ProduitAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('titre')
            ->add('description')
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('titre')
            ->add('description')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('titre')
            ->add('description')
        ;
    }

    public function validate(ErrorElement $errorElement, $object)
    {
        $errorElement
            ->with('titre')
                ->assertMaxLength(array('limit' => 32))
            ->end()
        ;
    }
}


namespace Jade\ReveBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;

class ThematiqueAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('titre')
            ->add('description')
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('titre')
            ->add('description')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('titre')
            ->add('description')
        ;
    }

    public function validate(ErrorElement $errorElement, $object)
    {
        $errorElement
            ->with('titre')
                ->assertMaxLength(array('limit' => 32))
            ->end()
        ;
    }
}

有人知道我的问题吗?谢谢你的回答

4

1 回答 1

-1

如果错误是“ PHP Fatal Error: Allowed memory size of xxxx bytes exhausted... ”,则尝试增加 PHP 内存限制。Sonata 使用 Doctrine ORM,实体可能会消耗大量内存。许多信息也以开发模式存储在分析器的内存中。

文件 web/app_dev.php 和 web/app.php:

<?php 
ini_set('memory_limit','128M'); //or some other reasonable value
...

或在 php.ini 中:

memory_limit = 128M
于 2012-10-07T17:00:13.807 回答