Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I've been working through the book recently, and once it gets into the "pagination" section, a strange bug seems to appear on my local -

Binding entities to query parameters only allowed for entities that have an identifier. Class "App\Entity\Conference" does not have an identifier.

I've followed the book to the letter and been unable to work out why this was happening, until a random stack overflow thread I came across made note that this version of the book is for older versions of Symfony, and has a package missing, now long unsupported, that causes this bug. Any ideas?

You must be logged in to vote

Replies: 2 comments · 3 replies

Comment options

Your class needs a unique identifier so Doctrine can identify each record and paginate accordingly.

You must be logged in to vote
1 reply
@MPAGenie
Comment options

On what part? can you give a little more context? I'm still pretty new to all this

Comment options

The Conference entity created in chapter 8 has an identifier field (named id). So to me, getting this error makes me think that your code does not actually correspond to following the book to the letter.

You must be logged in to vote
2 replies
@MPAGenie
Comment options

My Conference entity controller has ...
#[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null;

On lines 13-16. is that not correct?
@yun548
Comment options

This should not be in your Controller but in the Conference entity you generated using the command.

The generated entity should look like this :

namespace App\Entity;

use App\Repository\ConferenceRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: ConferenceRepository::class)]
class Conference
{
    #[ORM\Column(type: 'integer')]
    #[ORM\Id, ORM\GeneratedValue()]
    private $id;

    #[ORM\Column(type: 'string', length: 255)]
    private $city;

    // ...

    public function getCity(): ?string
    {
        return $this->city;
    }

    public function setCity(string $city): self
    {
        $this->city = $city;

        return $this;
    }

    // ...
}

I suggest you go over the database chapter one more time to make sure everything is in order there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.