Hicham Dev
Hicham Dev

Reputation: 9

the name of class is already in use

I have a problem with symfony:

Fatal error: Cannot declare class App\Entity\UserGroup, because the name is already in use in /var/www/app/src/Entity/UserGroup.php on line 17).

I emptied the cache and reinstalled the packages but the problem still remains.

The class:

<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/* @ORM\Table(name="UserGroup", indexes={@ORM\Index(name="usergroup_license_id_foreign", columns={"license_id"})})
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="App\Repository\UsergroupRepository")
/
class UserGroup{
    / @var int
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY")
     */ 
    private $id;

my composer.json { "type": "project", "license": "proprietary", "minimum-stability": "stable", "prefer-stable": true, "require": { "php": ">=8.0.2", "ext-ctype": "", "ext-iconv": "", "beberlei/doctrineextensions": "^1.3", "doctrine/annotations": "^1.0", "doctrine/doctrine-bundle": "^2.6", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.12", "dompdf/dompdf": "^1.2", "easycorp/easyadmin-bundle": "^4.3", "karser/karser-recaptcha3-bundle": "^0.1.22", "knpuniversity/oauth2-client-bundle": "^2.10", "league/oauth2-facebook": "^2.2", "league/oauth2-google": "^4.0", "phpdocumentor/reflection-docblock": "^5.3", "phpoffice/phpspreadsheet": "^1.23", "phpstan/phpdoc-parser": "^1.4", "sendgrid/sendgrid": "~7", "sensio/framework-extra-bundle": "^6.1", "symfony/apache-pack": "^1.0", "symfony/asset": "6.0.", "symfony/console": "6.0.", "symfony/doctrine-messenger": "6.0.", "symfony/dotenv": "6.0.", "symfony/expression-language": "6.0.", "symfony/flex": "^2", "symfony/form": "6.0.", "symfony/framework-bundle": "6.0.", "symfony/google-mailer": "6.0.", "symfony/http-client": "6.0.", "symfony/http-foundation": "6.0.", "symfony/intl": "6.0.", "symfony/mailer": "6.0.", "symfony/mime": "6.0.", "symfony/monolog-bundle": "^3.8", "symfony/notifier": "6.0.", "symfony/process": "6.0.", "symfony/property-access": "6.0.", "symfony/property-info": "6.0.", "symfony/proxy-manager-bridge": "6.0.", "symfony/runtime": "6.0.", "symfony/security-bundle": "6.0.", "symfony/sendgrid-mailer": "6.0.", "symfony/serializer": "6.0.", "symfony/string": "6.0.", "symfony/translation": "6.0.", "symfony/twig-bundle": "6.0.", "symfony/ux-chartjs": "^2.2", "symfony/ux-dropzone": "^2.2", "symfony/validator": "6.0.", "symfony/web-link": "6.0.", "symfony/webapp-meta": "^1.0", "symfony/webpack-encore-bundle": "^1.12", "symfony/yaml": "6.0.", "symfonycasts/reset-password-bundle": "^1.13", "symfonycasts/verify-email-bundle": "^1.10", "tattali/calendar-bundle": "^1.2", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0", "vich/uploader-bundle": "^1.19" }, "config": { "allow-plugins": { "composer/package-versions-deprecated": true, "symfony/flex": true, "symfony/runtime": true }, "optimize-autoloader": true, "preferred-install": { "": "dist" }, "sort-packages": true }, "autoload": { "psr-4": { "App\": "src/" } }, "autoload-dev": { "psr-4": { "App\Tests\": "tests/" } }, "replace": { "symfony/polyfill-ctype": "", "symfony/polyfill-iconv": "", "symfony/polyfill-php72": "", "symfony/polyfill-php73": "", "symfony/polyfill-php74": "", "symfony/polyfill-php80": "" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "conflict": { "symfony/symfony": "" }, "extra": { "symfony": { "allow-contrib": false, "require": "6.0." } }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.4", "phpunit/phpunit": "^9.5", "symfony/browser-kit": "6.0.", "symfony/css-selector": "6.0.", "symfony/debug-bundle": "6.0.", "symfony/maker-bundle": "1.43", "symfony/phpunit-bridge": "^6.0", "symfony/stopwatch": "6.0.", "symfony/web-profiler-bundle": "6.0." } }

Upvotes: 0

Views: 527

Answers (1)

Mayor of the Plattenbaus
Mayor of the Plattenbaus

Reputation: 1256

Welcome to Stack Overflow!

Assuming you're using PHPStorm for development, I'd suggest trying the following:

  • Hit command-shift-o to bring up the class-opening dialogue box
  • Type in UserGroup to see what classes already exist
  • Depending on your needs, you can then either edit that existing class or create your new class using a different namespace -- something other than App\Entity

I hope that helps!

Upvotes: 0

Related Questions