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?
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.
The current system requires the global
composer.json
to specifiy thesite/components/
path for autoloading component classes. And components have to be declared in theApp\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 theApp\View\Components
namespace, we could useclass_alias()
as a last resortImplementation 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 beFormSelectComponent
/form-select.php
(will get messy for larger component libraries) or ratherForm\SelectComponent
/form/select.php
or maybe something completely different?@lukasleitsch What do you think?