Doctrine PHPCR-ODM - Symfony 2.3.1 - Problems

Discuss Symfony 2 bundles here

Moderators: tiagojsag, dcobalt

Doctrine PHPCR-ODM - Symfony 2.3.1 - Problems

Postby koakh » Tue Jul 02, 2013 12:18 am

Hi

I have trying to install Doctrine PHPCR-ODM - Jackalope with Doctrine DBAL on my Symfony 2.3.1,
based on Symfony oficial info, like
Installing and Configuring Doctrine PHPCR-ODM
or
The DoctrinePHPCRBundle

After many try and fails I installed it with above composer.json

Code: Select all
{
  "name": "symfony/framework-standard-edition",
  "license": "MIT",
  "type": "project",
  "description": "The \"Symfony Standard Edition\" distribution",
  "autoload": {
    "psr-0": { "": "src/" }
  },
  "require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.2.*",
    "twig/extensions": "1.0.*",
    "symfony/assetic-bundle": "2.3.*",
    "symfony/swiftmailer-bundle": "2.3.*",
    "symfony/monolog-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "sensio/framework-extra-bundle": "2.3.*",
      "sensio/generator-bundle": "dev-master",
    "incenteev/composer-parameter-handler": "~2.0",

     "doctrine/doctrine-fixtures-bundle": "dev-master",
     "doctrine/data-fixtures" : "dev-master",

     "doctrine/doctrine-migrations-bundle": "dev-master",
     "doctrine/migrations": "dev-master",

     "phpunit/phpunit": "3.7.*",

    "braincrafted/bootstrap-bundle": "dev-master",
    "twitter/bootstrap": "2.3.*",
     "bmatzner/fontawesome-bundle": "*",
     "knplabs/knp-menu": "2.0.*@dev",
     "knplabs/knp-menu-bundle": "2.0.*@dev",
     "knplabs/knp-paginator-bundle": "2.3.*@dev",
     "leafo/lessphp": "0.3.*@dev",
     "components/jquery": "1.10.*@dev",
    
     "liip/imagine-bundle": "dev-master",
     "symfony-cmf/routing": "1.1.*@dev",
     "symfony-cmf/routing-bundle": "1.1.0-beta1",
     "friendsofsymfony/user-bundle": "dev-master",
     "gedmo/doctrine-extensions": "2.3.*@dev",
   
     "phpcr/phpcr": "2.1.*@dev",
     "phpcr/phpcr-utils": "1.0.*@dev",
     "doctrine/phpcr-bundle": "1.0.*@dev",
     "doctrine/phpcr-odm": "1.0.*@dev",
     "jackalope/jackalope": "1.0.*@dev",
     "jackalope/jackalope-jackrabbit": "1.0.*@dev",
     "jackalope/jackalope-doctrine-dbal": "1.0.x-dev"
  },
  "scripts": {
    "post-install-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
      "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
      "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
  },
  "config": {
    "bin-dir": "bin"
  },
  "minimum-stability": "stable",
  "extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
      "file": "app/config/parameters.yml"
    },
    "branch-alias": {
      "dev-master": "2.3-dev"
    }
  }
}


I dont include here my config.php, app/AppKernel.php, app/autoload.php, and other related files, because I replicated the steps in
Installing and Configuring Doctrine PHPCR-ODM
and my config files are equal to the tutorial.......I have already try so many things but the error is always the same, and I dont find any related info about its resolution

Lets explain my problem

The Symfony framework is working almost in every Routes, but in some Routes that uses Forms it shows this error:

Interface Doctrine\Common\Proxy\Proxy does not exist
500 Internal Server Error - ReflectionException


in
Code: Select all
vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php at line 200   
}
  $proxyClass = new \ReflectionClass($class);
  if ($proxyClass->implementsInterface($this->proxyInterfaceName)) {
    $class = $proxyClass->getParentClass()->getName();
}


What I Found was that its has related to form types and form entities that use @ORM annotations

Example with a minimal entity class, form type that shows the error

Minimal Controller to Show Error
Code: Select all
<?php
// src/Acme/TaskBundle/Controller/DefaultController.php

namespace Acme\TaskBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Acme\TaskBundle\Entity\Task;
use Acme\TaskBundle\Form\Type\TaskType;

class DefaultController extends Controller
{
  public function indexAction($name)
  {
    $task = new Task();
    $form = $this->createForm(new TaskType(), $task);
   
    return $this->render('AcmeTaskBundle:Default:index.html.twig', array(
      'name' => $name
    ));
  }
}


The problem #1
Show error!
Code: Select all
$form = $this->createForm(new TaskType(), $task);

Dont show error!
Code: Select all
$form = $this->createForm(new TaskType());


Minimal Form Type to Show Error
Code: Select all
// src/Acme/TaskBundle/Form/Type/TaskType.php

namespace Acme\TaskBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class TaskType extends AbstractType
{
  public function buildForm(FormBuilderInterface $builder, array $options)
  {
    $builder->add('task');
  }

  public function getName()
  {
    return 'acme_taskbundle_tasktype';   
  }
 
  public function setDefaultOptions(OptionsResolverInterface $resolver)
  {
    $resolver->setDefaults(array(
      'data_class' => 'Acme\TaskBundle\Entity\Task'
    ));
  } 
}


The problem #2
Show error!
Code: Select all
'data_class' => 'Acme\TaskBundle\Entity\Task'

Dont show error!
Code: Select all
'data_class' => null

or comment it
Code: Select all
//'data_class' => 'Acme\TaskBundle\Entity\Task'


and the related Task Entity ($task)
Code: Select all
<?php

// src/Acme/TaskBundle/Entity/Task.php

namespace Acme\TaskBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="task")
 */
class Task
{
  /**
   * @ORM\Id
   * @ORM\Column(type="integer")
   * @ORM\GeneratedValue(strategy="AUTO")
   */
  protected $id;
 
  /**
   * @ORM\Column(type="text")
   * @Assert\NotBlank()
   */
  protected $task;

  /**
   * @ORM\Column(type="datetime")
   * @Assert\NotBlank()
   * @Assert\Type("\DateTime")
   */ 
  protected $dueDate;
 
  /**
   * @Assert\NotNull(message="You must select a category")
   * @Assert\Type(type="Acme\TaskBundle\Entity\Category")
   * @ORM\ManyToOne(targetEntity="Category", inversedBy="task", cascade={"persist"})
   * @ORM\JoinColumn(name="task_id", referencedColumnName="id")
   */
  protected $category;
 
  /**
   * Get id
   *
   * @return integer
   */
  public function getId()
  {
    return $this->id;
  }

  /**
   * Set task
   *
   * @param string $task
   * @return Task
   */
  public function setTask($task)
  {
    $this->task = $task;
   
    return $this;
  }

  /**
   * Get task
   *
   * @return string
   */
  public function getTask()
  {
    return $this->task;
  }

  /**
   * Set dueDate
   *
   * @param \DateTime $dueDate
   * @return Task
   */
  public function setDueDate(\DateTime $dueDate = null)
  {
    $this->dueDate = $dueDate;
   
    return $this;
  }

  /**
   * Get dueDate
   *
   * @return \DateTime
   */
  public function getDueDate()
  {
    return $this->dueDate;
  }
 
  /**
   * Set category
   *
   * @param \Acme\TaskBundle\Entity\Category $category
   * @return Task
   */
  public function setCategory(\Acme\TaskBundle\Entity\Category $category = null)
  {
    $this->category = $category;

    return $this;
  }

  /**
   * Get category
   *
   * @return \Acme\TaskBundle\Entity\Category
   */
  public function getCategory()
  {
    return $this->category;
  }
 
}


I have tried to installed SimpleCMS and CMF Core on top of Symfony 2.3.1 from the tutorials, but no chance, Always have so many dependency problems, a true nightmare......

I even installed Symfony2 (2.1.x), like it was explained in CMF Core, but I must be honest,
I really like this cool framework when we are developing, but when we try install CMS Bundles, its like a nightmare.......

In fact it is a nightmare to install the Installing the Symfony CMF Standard Edition from tutorial, but i made it, after some hours......but I think I have wasting so many time fighting with Bundles dependencies, and less with development, its just a bad start or a bad luck for me?

Notes:
1) I have Symfony CMF Standard 2.2.3 With Jackalope with Doctrine DBAL on same linux server machine working without problems,
but I prefer to install the required bundles on TOP of my Symfony 2.3.1 Development Version.....This way I test Bundle installation......

I Think that I miss something related to Doctrine PHPCR-ODM config, but it I miss it is missing from tutorials to

The question is How we install DoctrinePHPCRBundle in symfony without proxy errors?

Thanks in Advance for Helping

PS: forget my english
koakh
Junior Member
 
Posts: 2
Joined: Wed May 22, 2013 2:30 am

Re: Doctrine PHPCR-ODM - Symfony 2.3.1 - Problems

Postby codevarun » Fri Jul 26, 2013 6:54 am

Hi

Just finished reading your post almost twice (Yes almost) and this isn't any solution per say but it is sort of global solution.

I think core problem lies in composer update updating every packages and these packages might not be stable that time.

Try doing following:

  1. Hold packages in particular versions like instead of * or 2.1* try using 2.1.1
  2. Add new things and use composer install and not composer update
  3. Make sure your PHP version is ok. I always recommend to use latest one.
  4. I know now it will sound weird and intentionally put at last. Hold packages in * versions like instead of 2.1.1 instead of 2.1* or *. But then go to these packages and see what is latest version then find latest one and use what is mentioned in 1.

You might like to read here:
Click here to know difference

That's the only thing that guaranteed stable installation.

I followed point 4 for FOS bundles, Sylius. So that is combination of point 1 and 4. Despite of fact that few said that min. requirement is 5.3.10, no it isn't. It was 5.4. This happened in installation of Sylius as well.
Good Luck.
Regards
Varun Batra
IT Consultant
@batravarun
codevarun
Junior Member
 
Posts: 15
Joined: Fri Dec 07, 2012 9:59 am

Re: Doctrine PHPCR-ODM - Symfony 2.3.1 - Problems

Postby koakh » Fri Aug 09, 2013 5:34 pm

First Thanks for your repply Varun Batra

I will try your tips next time I put my hands on Symfony, and post here the solution, If i found it

Once more Thanks for your usefull tips........
koakh
Junior Member
 
Posts: 2
Joined: Wed May 22, 2013 2:30 am


Return to Bundles discussion

Who is online

Users browsing this forum: No registered users and 1 guest