Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8304545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:52:41+00:00 2026-06-08T17:52:41+00:00

I have a problem trying to get data from a table (via entity) using

  • 0

I have a problem trying to get data from a table (via entity) using Doctrine2 in a Symfony2.1 project. Here is the controller where I get the error:

/**
 * Country list
 */
public function countrylistAction()
{
    $em = $this->getDoctrine()->getManager();
    $countryList = $em->getRepository('ProjectBaseBundle:SYS_TCountry')
        ->findAll();

    $serializer = new Serializer(array(new GetSetMethodNormalizer()),
        array('json' => new JsonEncoder()));

    return new Response($serializer->serialize($countryList, 'json'));
}

The entity:

<?php

namespace Company\Project\BaseBundle\Entity;

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

/**
 * @ORM\Entity
 * @ORM\Table(name="SYS_TCountry")
 */
class SYS_TCountry
{
    /**
     * @ORM\Id
     * @ORM\Column(type="string", length=3, nullable=false)
     * @var string
     */
    protected $idcountry;

    /**
     * @ORM\Column(type="string", length=75, nullable=false)
     * @Assert\NotBlank()
     * @var string
     */
    protected $name;

    ....

    public function getIdcountry()              { return $this->idcountry; }
    public function getName()                   { return $this->name; }
    public function getA2()                     { return $this->a2; }
    public function getA3()                     { return $this->a3; }
    public function getIdstatus()               { return $this->idstatus; }
    public function setIdcountry($idcountry)    { $this->idcountry = $idcountry; }
    public function setName($name)              { $this->name = $name; }
    public function setA2($a2)                  { $this->a2 = $a2; }
    public function setA3($a3)                  { $this->a3 = $a3; }
    public function setIdstatus($idstatus)      { $this->idstatus = $idstatus; }

    public function __toString()                { return $this->idcountry; }

}

Config.yml:

# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        charset:  UTF8

    orm:
        auto_generate_proxy_classes: %kernel.debug%
        auto_mapping: true

And this is the error:

Warning: class_parents(): 
Class Company\Project\BaseBundle\Entity\SYS_TCountry does not exist and could not be loaded in 
/var/www/project/src/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 40

It is strange because, as Doctrine says in console, the mapping is properly done: I test it executing php app/console doctrine:mapping:info:

[OK]   Company\Project\BaseBundle\Entity\SYS_TCountry

and if I execute a query in console everything goes fine -> app/console doctrine:query:sql ‘SELECT * FROM SYS_TCountry’, that return results.

I do not know if using Symfony2.1 I have to configure something different to the 2.0 version, but seems the same because the mapping is Doctrine responsibility.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:52:42+00:00Added an answer on June 8, 2026 at 5:52 pm

    Symfony follows the PSR-0 standard for filenames. That, amongst other things, means that if you use an underscore in your class name, it will replace it with a directory separator when deciding where your class should live, like this:

    \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
    

    So, if you have a class named SYS_TCountry it would expect to find it in

    Company/Project/BaseBundle/Entity/SYS/TCountry.php
    

    instead of

    Company/Project/BaseBundle/Entity/SYS_TCountry.php
    

    I think that your best solution would be to change the filename and class name to SYSTCountry. You don´t need to change the table name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using phpQuery to get the data from elements. I'm trying to get
Hey all, i have a problem with trying to get 2 forms to close
I'm trying to get a handle on whether we have a problem in our
I have a problem with this query trying to get a sum and a
I have a problem with a page where I am trying to get colorbox
I have a problem in firefox, where I'm trying to get a form submission
I'm trying to get a regexp to solve the next problem: I have some
I have what is likely a simple problem, whereby I am trying to get
I have a problem trying to turn my python code into an executable using
Problem I have a YQL query result that I'm trying to get converted and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.