Ivan Gretsky Posted March 25, 2022 Share Posted March 25, 2022 Good day, fellow Wireframe users! @Zeka once asked about how to organize large number of components in subfolders of components folder. Since then @teppointroduced view namespaces (for partials ATM), which probably could be extended to support components. We have found another way to use components in subfolders - via the usage of php namespaces. In @Zeka's case with the Blocks subdolder it would work like this: <?php // In [wireframeRoot]/components/Blocks/BlockText.php // Note the namespace namespace Wireframe\Component\Blocks; class BlockText extends \Wireframe\Component { ... and <?php // In the view file <?= Wireframe::component('Blocks\BlockText', [...]); ?> I guess this is possible due to PSR-4 compliance of the autoloader used. Or maybe @teppohas added something since then. Do you see this as a valid usage? Do you see any drawbаcks? 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted April 3, 2022 Author Share Posted April 3, 2022 Good day, @teppo! You answered in the other thread, but not here. And the posts were made on the same day... So just bumping this one to make sure you didn't miss it))))) Link to comment Share on other sites More sharing options...
teppo Posted April 3, 2022 Share Posted April 3, 2022 Hey @Ivan Gretsky, I don't see anything wrong with your approach. This is not something I had specifically planned for, but as you've noted above, it works thanks to the autoloader setup ? Only "issue" — and it's not much of an issue to be honest — would be that technically /components/Blocks/ should be the "view path" for a component called "Blocks". I can't really think of any real world situation where this would cause problems, though. The approach Zeka took in earlier posts effectively created a whole new type of components, in some ways more strictly separated from the built-in component structure. I'd say that it's largely a matter of preference. 1 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted April 3, 2022 Author Share Posted April 3, 2022 Are you planning on "component namespaces"? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now