Skip to content
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

make:twig-component doesn't work well when using a custom root namespace #1641

Closed
dejagersh opened this issue Jan 4, 2025 · 1 comment · Fixed by #1642
Closed

make:twig-component doesn't work well when using a custom root namespace #1641

dejagersh opened this issue Jan 4, 2025 · 1 comment · Fixed by #1642

Comments

@dejagersh
Copy link

Hi!

Our app has a custom root namespace. Let's say Foobar\ instead of App\. We have this configured in maker.yaml:

maker:
  root_namespace: 'Foobar'

Now when we run make:twig-component we get:

bin/console make:twig-component

 The name of your twig component (ie Notification):
 > Button

 Make this a live component? (yes/no) [no]:
 > no

 created: src/ar/Twig/Components/Button.php
 created: templates/components/Button.html.twig

           
  Success! 
           


 To render the component, use <twig:Button />.

The first 4 characters of Foobar are removed and a file is created in src/ar/Twig/... instead of src/Twig.

@dejagersh
Copy link
Author

I think this goes wrong here in MakeTwigComponent.php:

$this->namespace = substr(array_key_first($value['twig_component']['defaults']), 4);

It strips the first 4 characters, which works when you use App namespace because App\ is 4 chars. Shouldn't it be based on strlen($rootNamespace)+1?

@dejagersh dejagersh changed the title make:twig-component doesn't work well when using a custom namespace make:twig-component doesn't work well when using a custom root namespace Jan 4, 2025
marcriemer added a commit to marcriemer/maker-bundle that referenced this issue Jan 5, 2025
@kbond kbond closed this as completed in 495b7d6 Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant