Livewire Class create in Http, does not match with Laravel-11 / config of livewire
Opened this issue · 3 comments
php artisan make:livewire MyDemoLivewireModule --module=[module name]
create the Livewire File into
'/app-modules/my-demo-livewire-module/Http/Livewire/MyDemoLivewireModule' regardless what is configured in config('livewire.class_namespace')
File should be during creation stored into '/app-modules/my-demo-livewire-module/Livewire/MyDemoLivewireModule' or whatever the str_contains(config('livewire.class_namespace') is.
protected function createClass($force = false, $inline = false)
{
if ($module = $this->module()) {
$name = Str::of($this->argument('name'))
->split('/[.\/(\\\\)]+/')
->map([Str::class, 'studly'])
->join(DIRECTORY_SEPARATOR);
// Bugnotice: Http can be wrong
$classPath = $module->path('src/Http/Livewire/'.$name.'.php');
if (File::exists($classPath) && ! $force) {
$this->line("<options=bold,reverse;fg=red> WHOOPS-IE-TOOTLES </> 😳 \n");
$this->line("<fg=red;options=bold>Class already exists:</> {$this->parser->relativeClassPath()}");
return false;
}
$this->ensureDirectoryExists($classPath);
File::put($classPath, $this->parser->classContents($inline));
$component_name = Str::of($name)
->explode('/')
->filter()
->map([Str::class, 'kebab'])
->implode('.');
$fully_qualified_component = Str::of($this->argument('name'))
// Bugnotice: Http can be wrong
->prepend('Http/Livewire/')
->split('/[.\/(\\\\)]+/')
->map([Str::class, 'studly'])
->join('\\');
Livewire::component("{$module->name}::{$component_name}", $module->qualify($fully_qualified_component));
return $classPath;
}
return parent::createClass($force, $inline);
}
#/internachi/modular/src/Support/AutoDiscoveryHelper.php
public function livewireComponentFileFinder(): FinderCollection
{
$directory = $this->base_path.'/*/src';
if (str_contains(config('livewire.class_namespace'), '\\Http\\')) {
$directory .= '/Http';
}
$directory .= '/Livewire';
return FinderCollection::forFiles()
->name('*.php')
->inOrEmpty($directory);
}
I think config('livewire.class_namespace')
with livewire default value 'class_namespace' => 'App\\Livewire',
does not make sense in InterNACHI-Module.
may be it smarter to create in /confg/app-modules.php a 'livewire_location' => './' // in your modules src root.
good or bad way?
@inxilpro At the Moment i am on refactoring(local) your module-package with a lot of enhancements
My question: is there a way or do you wish my refactoring in module@next or something like that or is it better, that i make my own fork completly by myself as an own fork?