Naming Convention: Singular vs. Plural for Classes Describing Objects in PHP

I think the standard practice for table names in MySQL is to use plural names.

Classes referencing these tables should also be plural?

For example, imagine you have a table called "Users" that is used for authentication purposes.

This table will be described in an entity class in a more or less similar way using the ORM doctrine:

namespace Company\BlogBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="Users")
 */
class Users
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer", name="user_id")
     * @ORM\GeneratedValue(strategy="AUTO")
     * 
     * @var integer $userId
     */
    protected $userId;

    /**
     * @ORM\Column(type="string", length="255", name="first_name")
     * 
     * @var string $userName
     */
    protected $userName;
    ...
}

Is it correct?

Or should the "Users" class be named in the singular ("User")?

+3
source share
4 answers

, (), . Doctrine 2 - . @Table, , Doctrine. .

+3

, , . , . , , .

+4

, ; . , ; . .

+2

, , . , , , ( ) , "" .

0

All Articles