Symfony 安装stof捆绑包和条令扩展(树)时发生致命错误
问题是:我没有成功地用symphony 2.0安装stof捆绑包 我如何继续: 我在deps文件中添加以下行:Symfony 安装stof捆绑包和条令扩展(树)时发生致命错误,symfony,doctrine-orm,symfony-2.0,doctrine-extensions,Symfony,Doctrine Orm,Symfony 2.0,Doctrine Extensions,问题是:我没有成功地用symphony 2.0安装stof捆绑包 我如何继续: 我在deps文件中添加以下行: [GedmoDoctrineExtensions] git=https://github.com/l3pp4rd/DoctrineExtensions.git target=bundles/gedmo-doctrine-extensions version=e93fc1e0a0 [StofDoctrineExtensionsBundle] git=ht
[GedmoDoctrineExtensions]
git=https://github.com/l3pp4rd/DoctrineExtensions.git
target=bundles/gedmo-doctrine-extensions
version=e93fc1e0a0
[StofDoctrineExtensionsBundle]
git=https://github.com/stof/StofDoctrineExtensionsBundle.git
target=bundles/Stof/DoctrineExtensions/Bundle
version=6b2a8c74bd
然后我运行命令
php bin/供应商安装--重新安装
一切都很好
然后激活相关文件中的扩展名
# config.yml
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
tree: true
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
mappings:
StofDoctrineExtensionsBundle: ~
最后,我添加了实体类别,如本教程所示 有时候,这个:
Fatal error: Out of memory (allocated -1222901760) (tried to allocate 261900 bytes) in /home/user/Project/vendor/gedmo-doctrine-extensions/lib/Gedmo/Mapping/MappedEventSubscriber.php on line 176
我做错了什么?尝试仅加载树扩展:
doctrine:
orm:
entity_managers:
default:
mappings:
gedmo_tree:
type: annotation
prefix: Gedmo\Tree\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
alias: GedmoTree # this one is optional and will default to the name set for the mapping
is_bundle: false
正如文档所说:我想说,这些错误与Symfony或学说无关。对我来说,这更像是一个PHP配置问题
您可以尝试增加
php.ini
文件中的内存限制
值。在大多数情况下,128MB的内存限制应该足够了,但如果您的项目正在处理大量数据,则可能需要更多的内存 你能把它转换成兆字节吗?另外,如果没有堆栈跟踪,请在本地计算机上安装xdebugIt?或者在服务器上?不确定这与此无关,但文档中说“如果使用自动映射设置,则不需要将DoctrineExtensionsBundle添加到映射中”,并且“只有在使用可翻译或可记录行为时才需要映射。如果不使用其中任何一个,则可以禁用它以避免创建表,即使在使用自动映射时也是如此“。因此,我将使用StofDoctrineExtensionsBundle:false
我想知道,如果您不使用XML映射并且使用注释,为什么会在XmlDriver.php处出错。或者您是在以某种方式使用XML?为什么要使用这些库的特定版本?
<?php
namespace Myproject\MyBundle\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
/**
* @Gedmo\Tree(type="nested")
* @ORM\Table(name="Category")
* use repository for handy tree functions
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
*/
class Category
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* @ORM\Column(name="title", type="string", length=64)
*/
private $title;
/**
* @Gedmo\TreeLeft
* @ORM\Column(name="lft", type="integer")
*/
private $lft;
/**
* @Gedmo\TreeLevel
* @ORM\Column(name="lvl", type="integer")
*/
private $lvl;
/**
* @Gedmo\TreeRight
* @ORM\Column(name="rgt", type="integer")
*/
private $rgt;
/**
* @Gedmo\TreeRoot
* @ORM\Column(name="root", type="integer", nullable=true)
*/
private $root;
/**
* @Gedmo\TreeParent
* @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $parent;
/**
* @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
* @ORM\OrderBy({"lft" = "ASC"})
*/
private $children;
}
Fatal error: Out of memory (allocated -1227096064) (tried to allocate 261900 bytes) in /home/user/Project/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 75
Fatal error: Out of memory (allocated -1222901760) (tried to allocate 261900 bytes) in /home/user/Project/vendor/gedmo-doctrine-extensions/lib/Gedmo/Mapping/MappedEventSubscriber.php on line 176
doctrine:
orm:
entity_managers:
default:
mappings:
gedmo_tree:
type: annotation
prefix: Gedmo\Tree\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
alias: GedmoTree # this one is optional and will default to the name set for the mapping
is_bundle: false