-
-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Console command d:g:entities cannot find base path #723
Comments
The possible solution I've got would require a PR on 2 bundles, although I'm not sure where to raise this. private function getBasePathForClass($name, $namespace, $path)
{
$namespace = str_replace('\\', '/', $namespace);
$search = str_replace('\\', '/', $path);
if ($namespace === 'App/Entity') {
$destination = str_replace('/Entity', '', $search, $c);
} else {
$destination = str_replace('/'.$namespace, '', $search, $c);
}
if ($c != 1) {
throw new \RuntimeException(sprintf('Can\'t find base path for "%s" (path: "%s", destination: "%s").', $name, $path, $destination));
}
return $destination;
} Change 2: public function writeEntityClass(ClassMetadataInfo $metadata, $outputDirectory)
{
$metaNamePath = substr($metadata->name, 0, 4) === 'App\\' ? substr($metadata->name, 4) : $metadata->name;
$path = $outputDirectory . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $metaNamePath) . $this->extension; Not sure if this is ideal though or if the bundle should perhaps alter the name in the metadata instead. Thoughts? |
Your proposal only work when entities are in Entity folder and don't manage subfolder private function getBasePathForClass($name, $namespace, $path)
{
$namespace = str_replace('\\', '/', $namespace);
$search = str_replace('\\', '/', $path);
$namepath = substr($namespace, 0, 4) != 'App/' ? : substr($namespace, 4);
$destination = str_replace('/'.$namepath, '', $search, $c);
if ($c != 1) {
throw new \RuntimeException(sprintf('Can\'t find base path for "%s" (path: "%s", destination: "%s").', $name, $path, $destination));
}
return $destination;
} See #729 for more informations |
Thanks for the link to the other issue, in fact that means I can close this as I hadn't seen it. The comments in there are very useful to know the direction that this bundle is taking. |
hi there, |
It does not generate the setters and getters.
error:
|
Same error like @kporras07 and @chiqui3d |
Same error as @pierre-H @kporras07 @chiqui3d |
Same error for me to , I'm using symfony 4.0.4. Generating entities for namespace "App" In DisconnectedMetadataFactory.php line 158:
|
Hi,
Maybe the steps below are not 100% accurate as I have tried a lot of different attempts..
And voila - in little strange path |
i am getting this error too @Kuro-dake @pierre-H @kporras07 @chiqui3d |
I'm still having this error aswell, with the exact same message, pleae reopen the issue. |
Please look at #729. |
I don't think that's a good idea. Read the conversation and you'll see it is not going to be a feature anymore or Doctrine. If you're going to pester the collaborators about it then you can open a new PR, I'm not willing to do this. I'd expect new PRs to be closed quickly referencing #729 conversation anyway. |
@Ocramius - I'd appreciate if this conversation was locked as well to prevent conversations spilling over to here. Some will find it hard to say goodbye to this feature it seems. |
With the new directory structure for Symfony 3.4+ getBasePathForClass returns a runtime exception:
https://github.com/doctrine/DoctrineBundle/blob/master/Mapping/DisconnectedMetadataFactory.php#L151
It looks like the function attempts to find the namespace in the path. Because 'AppBundle' is not longer in the file path and it is just within the 'src' directory I get the error:
Can't find base path for "App\Entity\XXX"
The text was updated successfully, but these errors were encountered: