You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Where do we draw the line between having classes in the core sprinkle vs. a vendor package?
First, it's important to note we do need a higher lever dependency. For a bare minimum, we need the SprinkleManager to be out of core, and ideally out of the skeleton repo too.
This question is valid for both UF core code and user code. Is there really a requirement for a user or UF extension to create a sprinkle (repo), load the code as a vendor package ?
I think the answer relies on one thing : Is the code UserFrosting specific, or can it be reused in another project ?
If the answer is yes, then I think a vendor package would make sense. But we have to keep in mind all other resources (locale, assets, routes, templates, etc.) still need to be accessible in a specific path (see point 4 about this).
In a functional standpoint, running phpunit on the skeleton repo should run all integration tests related to the content (controller, model, etc.). While all the "unit testing" of the individual component should be done independently.
I did a quick mockup of what the class/repo structure would be :
The difference between the core sprinkle and the framework repo can be seen as :
All data structure stays in the sprinkle, while all the helper methods moves to the framework repo.
This means all Migrations, Model, Seeds, template, locale, assets, etc. stays in the sprinkle.
Some of the UserFrosting/Framework content could be split into their own read-only repo, just like Laravel Illuminate packages… But that wouldn’t be required, as the skeleton repo would probably load the whole framework repo.
The “framework” namespace wouldn’t be used for simplicity. So it would still be UserFrosting/Assets/…, UserFrosting/i18n/…, not UserFrosting/Framework/i18n. Only sprinkles would be differentiated with the UserFrosting/Sprinkles/ Namespace.
At this point, I’m not sure how the bakery commands should be handled. Of course, bakery commands should be registered instead of discovered, which means we could put them wherever we want. They could be in the Framework (would make it easier to test) or a sprinkle. Assuming the Bakery class is in the Framework, then I guess it makes sense for command to be found there too. A good example would be the locale commands. They don't technically requires UF to run. One could clone the i18n repo and want execute those commands. Note Laravel works that way.
Same goes for services provider. One thing important about service, currently my IDE doesn’t recognize $this->ci->translator as an instance of Translator since it’s actually loaded as a callback inside the provider class. We should implement a custom way to implement something that could take this into account, plus one which is testable.
In the end, I think the key is everything in the Framework repo needs to be self contained. They can't have dependencies on the content of the sprinkle (including Models), but it can have dependency on other framework component.
In other word, if a component form UF 4 can be moved to a distinct repo right now, it should be moved to the framework repo.
On the other hand, we also need to take into account dependencies on the locale strings, which would stay inside the sprinkle...
I see the Framework as the bare minimum UF needs to run, but also the one that dictate how it should run. That's why I think this should also apply for Interfaces, which should ideally be in the Framework.
2. How do we structure the Sprinkle namespace and directory structure if we add sprinkle vendor name ?
I suggest we stick to the first option, as it’s more “psr-esque”
3. Should vendor dir be in app/vendor/ or vendor/ ?
I think we should move vendor/ to the root repo to be consistent with 99% of the PHP world, especially when running command (ie. vendor/bin/phpunit vs app/vendor/bin/phpunit)
4. Should dependent sprinkles be loaded in vendor, and custom user code be left in app/sprinkles/ ?
For this one, I think we need some sort of control. I've talked about classes so far, but we still need to think about the other resources not in src/ : assets, locale, routes, config, etc.
Following my first attempt at moving into the UF 5.0 structure, I think we need to define a formal plan regarding the repo and class structure for the future version of UserFrosting.
We already know the main goals for v5 are :
Creating a skeleton repo means all base code not in the core Sprinkle needs to be moved somewhere else, especially the
sprinklemanager.To better illustrate the current situation, here is the current UF repo structure :
Compared to the proposed structure :
I also generated the current class structure of UF 4 : https://gist.github.com/lcharette/0d6db88d300690468436ed7555cf5ef2#file-1-currentstructure-md
Big questions that needs answers
1. Where do we draw the line between having classes in the core sprinkle vs. a vendor package?
First, it's important to note we do need a higher lever dependency. For a bare minimum, we need the
SprinkleManagerto be out of core, and ideally out of the skeleton repo too.This question is valid for both UF core code and user code. Is there really a requirement for a user or UF extension to create a sprinkle (repo), load the code as a vendor package ?
I think the answer relies on one thing : Is the code UserFrosting specific, or can it be reused in another project ?
If the answer is yes, then I think a vendor package would make sense. But we have to keep in mind all other resources (locale, assets, routes, templates, etc.) still need to be accessible in a specific path (see point 4 about this).
In a functional standpoint, running phpunit on the skeleton repo should run all integration tests related to the content (controller, model, etc.). While all the "unit testing" of the individual component should be done independently.
I did a quick mockup of what the class/repo structure would be :
The full mockup can be found here :
https://gist.github.com/lcharette/0d6db88d300690468436ed7555cf5ef2#file-3-proposedstructure-md
Some notes about this structure :
The difference between the core sprinkle and the framework repo can be seen as :
Some of the
UserFrosting/Frameworkcontent could be split into their own read-only repo, just like Laravel Illuminate packages… But that wouldn’t be required, as the skeleton repo would probably load the whole framework repo.The “framework” namespace wouldn’t be used for simplicity. So it would still be
UserFrosting/Assets/…,UserFrosting/i18n/…, notUserFrosting/Framework/i18n. Only sprinkles would be differentiated with theUserFrosting/Sprinkles/Namespace.At this point, I’m not sure how the bakery commands should be handled. Of course, bakery commands should be registered instead of discovered, which means we could put them wherever we want. They could be in the Framework (would make it easier to test) or a sprinkle. Assuming the Bakery class is in the Framework, then I guess it makes sense for command to be found there too. A good example would be the
localecommands. They don't technically requires UF to run. One could clone thei18nrepo and want execute those commands. Note Laravel works that way.Same goes for services provider. One thing important about service, currently my IDE doesn’t recognize
$this->ci->translatoras an instance ofTranslatorsince it’s actually loaded as a callback inside the provider class. We should implement a custom way to implement something that could take this into account, plus one which is testable.In the end, I think the key is everything in the
Frameworkrepo needs to be self contained. They can't have dependencies on the content of the sprinkle (including Models), but it can have dependency on other framework component.In other word, if a component form UF 4 can be moved to a distinct repo right now, it should be moved to the framework repo.
On the other hand, we also need to take into account dependencies on the locale strings, which would stay inside the sprinkle...
I see the Framework as the bare minimum UF needs to run, but also the one that dictate how it should run. That's why I think this should also apply for Interfaces, which should ideally be in the Framework.
2. How do we structure the Sprinkle namespace and directory structure if we add sprinkle vendor name ?
The directory structure would ideally be :
Current namespace for sprinkle is :
UserFrosting/Sprinkles/CoreUserFrosting/Sprinkles/AdminUserFrosting/Sprinkles/FormGeneratorUserFrosting/Sprinkles/MySiteI see 3 options for the new sprinkle namespaces :
Option 1 :
UserFrosting/Sprinkles/UserFrosting/CoreUserFrosting/Sprinkles/UserFrosting/AdminUserFrosting/Sprinkles/Lcharette/FormGeneratorUserFrosting/Sprinkles/Lcharette/MySiteOption 2 :
UserFrosting/Sprinkles/CoreUserFrosting/Sprinkles/AdminLcharette/Sprinkles/FormGeneratorLcharette/Sprinkles/MySiteOption 3:
Sprinkles/UserFrosting/CoreSprinkles/UserFrosting/AdminSprinkles/Lcharette/FormGeneratorSprinkles/Lcharette/MySiteI suggest we stick to the first option, as it’s more “psr-esque”
3. Should vendor dir be in
app/vendor/orvendor/?I think we should move
vendor/to the root repo to be consistent with 99% of the PHP world, especially when running command (ie.vendor/bin/phpunitvsapp/vendor/bin/phpunit)4. Should dependent sprinkles be loaded in vendor, and custom user code be left in
app/sprinkles/?For this one, I think we need some sort of control. I've talked about classes so far, but we still need to think about the other resources not in
src/: assets, locale, routes, config, etc.See also
UF 5.0 Related issue / ideas / wishlist :
bake#1021