foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Default namespace adding a App\ as a prefix

Open ldefautubi opened this issue 1 year ago • 1 comments

I want to use Foundry in my project to generate fixtures. I've configured the zenstruck_foundry.yaml as the following :

zenstruck_foundry:
    make_factory:
        # Default namespace where factories will be created by maker.
        default_namespace: \Tcs\Service\ServiceName\Factory

but when I do a bin/console make:factory, and choosing the entity I need, I have this error :

Could not determine where to locate the new class "App\Tcs\Service\ServiceName\Factory\DeviceFactory", maybe try with a full namespace like "\My\Full\Namespace\DeviceFactory"

ldefautubi avatar Oct 02 '24 12:10 ldefautubi

Hey,

I've tried to reproduce in a project which does not use App as main namespace, and I got this warning:

➜ bin/console make:factory --namespace MyVendor\\Factory

 ! [NOTE] It looks like your app may be using a namespace other than "App".                                             
 !                                                                                                                      
 !        To configure this and make your life easier, see: https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html#configuration

The links suggests to add some config for maker bundle:

    maker:
        root_namespace: 'MyVendor'

I think it is super explicit, so this won't need any change in Foundry. Or maybe there is a bug where it didn't not show up?

nikophil avatar Oct 03 '24 08:10 nikophil

I'm closing this stale issue

nikophil avatar Oct 24 '24 18:10 nikophil