I'm creating a entity for my bundle but if i want to generate my entity with php bin/console make:entity --regenerate App\\\\VacationManger\\\\Entity
it shows following error:
Invalid mapping file 'App.VacationManager.Entity.VacationRequests.orm.xml' for class 'App\VacationManager\Entity\VacationRequests'.
I think i have one problem in the XML file but i dont know where it is.
My ORM XML File:
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="App\VacationManger\Entity\VacationRequests" table="vacation_requests">
<id name="id" type="bigint" column="request_id">
<generator strategy="IDENTITY"/>
</id>
<many-to-one field="user" target-entity="App\Entity\User">
<join-column name="request_user_id" referenced-column-name="user_id"/>
</many-to-one>
<field name="dateFrom" column="request_dateFrom" type="date"/>
<field name="dateTo" column="request_dateTo" type="date"/>
<field name="days" column="request_days" type="integer" length="3"/>
<field name="reason" column="request_reason" type="text" nullable="true"/>
<field name="granted" column="request_granted" type="tinyint" length="2"/>
<field name="granted_reason" column="request_granted_reason" type="text" nullable="true"/>
</entity>
</doctrine-mapping>
If you want make a new Entity, this is what you need:
php bin/console make:entity EntityName
If you want regenerate one:
php bin/console make:entity --regenerate
And then Enter (if you want regenerate the all) or add an Entity like this: App\\Entity\\EntityName
You cant (or can, but very bad practice and need to reach into the kernel... dont do that...) use a custom folder instead of src... Your Entites should will be inside the folder: App/src/Entity
, and your Controllers inside App/src/Controller
, etc...
You can add extra folders to your namespaces, like this (if Entity)
App/src/Entity/VacationManger/VacationRequests.php
In this case you add this namespace to the current entity (so in VacationRequests.php)
<?php
namespace App\Entity\VacationManger;
class VacationRequests
{
// ...
Or may you can do (I never tested): php bin/console make:entity VacationManger\\VacationRequests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.