2012-10-13 49 views
0

這裏的問題是:我沒有成功安裝的STOF同捆交響樂2.0致命錯誤STOF束和學說擴展(樹)

我如何着手:

我添加此行在DEPS文件:

[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斌/廠商安裝--reinstall

一切都很好。

然後我激活擴展在有關文件

# 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: ~ 

# AppKernel.php  
use Symfony\Component\HttpKernel\Kernel; 
use Symfony\Component\Config\Loader\LoaderInterface; 

class AppKernel extends Kernel 
{ 
    public function registerBundles() 
    { 
     $bundles = array(
      [...] 
      new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), 
      [...] 
     ); 

# autoload.php 
use Symfony\Component\ClassLoader\UniversalClassLoader; 
use Doctrine\Common\Annotations\AnnotationRegistry; 

$loader = new UniversalClassLoader(); 
$loader->registerNamespaces(array(
    'Gedmo'   => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib', 
    'Stof'    => __DIR__.'/../vendor/bundles', 
    [...] 
    )); 

最後,我想補充我的實體類別,在本教程中http://gediminasm.org/article/tree-nestedset-behavior-extension-for-doctrine-2#including-extension

<?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; 
} 

但是當我運行命令的PHP應用程序/控制檯產生:學說:實體MyProjectMyBundle:類別,我有以下錯誤:

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 

+0

你能轉換成兆字節嗎?另外,如果你沒有獲得堆棧跟蹤,那麼請安裝xdebug – greg0ire

+0

它在你的本地機器上?或者在服務器上? –

+0

不確定它沒有任何關係,但文檔中說「如果使用auto_mapping設置,則不需要將DoctrineExtensionsBundle添加到映射中」,並且「只有在使用Translatable或Loggable行爲時才需要映射。如果不使用它們中的任何一個,即使使用auto_mapping,也可以禁用它以避免創建表「。所以我使用'StofDoctrineExtensionsBundle:false' –

回答

1

我會說,這些錯誤都沒有關係的Symfony也不學說。對我來說,它更像是一個PHP配置問題。

您可以嘗試增加php.ini文件中的memory_limit值。在大多數情況下,128MB的內存限制應該足夠了,但如果您的項目處理大量數據,則可能需要更多。