Class generator command with custom paths
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.5k
- Forks
- 468
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 2
Description
What problem does this feature proposal attempt to solve?
When running the artisan lighthouse:mutation command to generate a mutation class which is not within the app/ and App namespace, I receive the error: Maximum function nesting level of '256' reached, aborting!. I'm using nWidart modules and the "Modules/" directory is next to "app/".
Which possible solutions should be considered?
The LighthouseGeneratorCommand should implement a new method:
/**
* @return string
*/
protected function rootNamespace(): string
{
return config('lighthouse.namespaces.'.$this->namespaceConfigKey());
}
This way the generator works without throwing an exception. There is just one more adjustment to make because the generator is writing into the app/ directory directly. So we need to tell the generator to really use this namespace. We can do so by overwriting another method within LighthouseGeneratorCommand: protected function getPath($name). $this->laravel['path'] should only be used if the namespace returned from rootNamespace really starts with "App". Otherwise and absolute path to the namespace should be used.
The problem I figured out right now is that if I change a namespace back to start with "App" I'll receive Maximum function nesting level of '256' reached, aborting! if rootNamespace() is implemented like suggested above. So maybe there needs a few more adjustments to be done.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect LighthouseGeneratorCommand, especially rootNamespace() and getPath($name), along with the lighthouse.namespaces configuration. Reproduce artisan lighthouse:mutation with a namespace outside app/ and with an App namespace, then verify generation uses the configured namespace and path without the nesting-level error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, laravel, php
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100