lukasleitsch / kirby-blade

Enable Laravel Blade Template Engine for Kirby 4
MIT License
17 stars 4 forks source link

Better autoloading for component classes #10

Closed fabianmichael closed 1 year ago

fabianmichael commented 2 years ago

The current system requires the global composer.json to specifiy the site/components/ path for autoloading component classes. And components have to be declared in the App\View\Components namespace in order to be recognized.

I think an alternative approach like scanning the whole directory and just incuding the files automatically would probably feel more Kirby-like. Components could use a suffix in their class name, like page models, e.g. ButtonComponent. If the blade compiler requires these to live within the App\View\Components namespace, we could use class_alias() as a last resort

Implementation should be pretty straightforward. The only thing that I’m currently struggling with is finding a decent naming scheme for sub-components with dot-notation, e.g. <x-form.select />. Should it be FormSelectComponent/form-select.php (will get messy for larger component libraries) or rather Form\SelectComponent/form/select.php or maybe something completely different?

@lukasleitsch What do you think?

lukasleitsch commented 1 year ago

We had a discussion (outside this issue) about this issue and came to the conclusion that we will stick to composer and use composer autoloader to load the component classes.