Capsules dependency management #979
Replies: 6 comments 27 replies
-
Hey @antonioribeiro! A lot to think about here :) I haven't started using Capsules yet, but I really see the appeal! I think you put the problem in context quite well. From my point of view, the first question that comes to mind reading your message is: Are Capsules intended as "boilerplate" to be customized and extended, or more as "plugins" to be integrated and built around? At a glance, it looks like I agree that dependency management is a must. For what it's worth, I also think that a line in a README that says "to use this Capsule, you must run I really see that the question of why and how to update a Capsule is at the heart of the problem. I don't see how Capsules as "boilerplate" can be updated — once it's in your project, it's yours. On the other hand, Capsules as "plugins" can very well be updated, whether via composer or just unzipping, really. Not sure if I've actually added new thoughts to the discussion at this point but, I'm interested in the subject ;) |
Beta Was this translation helpful? Give feedback.
-
Using composer to manage the capsules and a dependencies is imho, a no-brainer. It offers a wealth of opportunities and advantages over manually doing this. That said, publicly available capsules should be configurable just like the rest of the system, rather than being copied or "published" to your local project (I see this introducing a world of problems, the main one being, as you suggested - capsule updates). They should be viewed as mini repositories with a dependency on Twill versions. |
Beta Was this translation helpful? Give feedback.
-
My background: I see use cases for both require and copy. But first of all: In WP there is the rule to never touch a plugin directly to not break my own modifications by updating the plugin. I see a use case for --require mostly in high optimized or specialized stuff. I see --copy more where I want a boilerplate with best practice that I can quickly delete down to what I need and customize. Maybe capsules need to be split in two things? Could there be a mix of boilerplate and updatable parts. I guess for trivial stuff I would just want to get a head start. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback @pboi20 , @kirkbushell , @ibes! Looks like REQUIRE is a must, so let's try to do this, and see how it plays. I believe it could work well for really big, super complex, or highly configurable Capsules, where people would not feel the need to change as soon as they touch it. @ibes , you came up with a third kind of capsule: HYBRID, nice one! But the way Twill modules (and Laravel) are made, a very simple update (like adding a new field) require changes to at least migration and model, if you are adding a relationship, you may have to change the repository, if the index or browser are customized, you may also have to change the controller. And I'm just oversimplifying it, because Twill is huge and pretty much anything could require a change to a class, which would prevent the Capsule from receive updates. But I would love to hear more about what could be the implementation for this. Maybe we can, in the future, make Capsules less dependable of some classes, relying more in configuration (I'm more a configuration over convention guy), using DTOs or configuration objects (as pointed by @kirkbushell on #internals @ our Discord), but I feel we have too much unneeded boilerplate code. For example, seems to me that we don't really need this kind of controller, and I have many of those: <?php
namespace App\Twill\Capsules\Collections\Http\Controllers;
use A17\Twill\Http\Controllers\Admin\ModuleController;
class CollectionController extends ModuleController
{
protected $moduleName = 'collections';
protected $indexColumns = [
'title' => [
'title' => 'Title',
'field' => 'title',
],
'city' => [
'title' => 'City',
'field' => 'city_name',
],
];
} We can probably have a configuration for the index and a more global Controller class handling the requests. Same for migrations, we could probably use an object like Laravel's validation Laravel Nova also uses it extensively, that's probably the cleverest part of it, and it's also super powerful: public function fields(NovaRequest $request)
{
return [
Text::make('First Name'),
Text::make('Last Name'),
Text::make('Job Title'),
];
} We could possibly do forms this way, like Nova too. But Twill forms are also a different kind of beast. If we are able to do something like this, maybe we can have HYBRID Capsules, configurable and upgradable. But this is how I see it. What about you? |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, my first take on making Composer install Capsules into our own Capsules folder failed, because I failed to understand the concept of a As most of you know, Composer allows frameworks to configure installer-paths, what I didn't know when I first tried this is that this feature is tied to a I believe (yes I'm still not totally sure) that in order for this to work our application {
"name": "twill/project",
"type": "project",
"require": {
"php": "^8.0",
"area17/twill": "^2.5.1",
"area17/twill-capsule-homepages": "^1.0",
"laravel/framework": "^8.54"
},
"extra": {
"installer-paths": {
"app/Twill/Capsules/Vendor/{$name}": ["type:twill-capsule"]
}
}
} This is not impossible, of course, but this means a lot of changes to the Twill ecosystem, like creating a "Twill Project" repository, based on the laravel/laravel, of course, possibly an installer and who knows what more... Any ideas on how could we tackle this without going down this path? Cheers! |
Beta Was this translation helpful? Give feedback.
-
I know we can do anything with code, the question we have to pose ourselves is: should we? Just to scratch the surface of a plugin system for Twill here, I believe a real plugin system for Twill would have to have support for VueJS. So are we adding JavasScript compilation to Modules now? Because this is clearly something that Modules doesn't support today, and, as said before Capsules are nothing more than Modules living on their own directory tree. And if we don't do this, well, Capsules will also start to become incompatible with Modules, or maybe just do more things than Modules do and, but this can be very confusing. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone!
Not sure if any of you are using Capsules already, but I'm finishing a project at AREA 17 with them (at least one other internal Team is also using it) and it feels good to use it so far. If you need help using it, just mention me here.
Well the next step would be to improve the installer, which exists already but it's not totally ready for prime time yet. I'm working (yes WIP) on 3 different public Capsules now to better understand the needs, and @ifox#4260 came to me one of these days thinking about the --copy option not being the best one for Capsules. So now I'm second guessing @ifox#4260's second guess 😄
For everyone to better understand the what we are thinking, we have two installing options:
Currently the COPY command just downloads the zip and unzip it on your /Capsules directory. Implementation is very rudimentary, but it's gettind the job done. But I believe we still need it to do more:
The REQUIRE command would, in other hand, use Composer as a dependency manager, which is, of course, fantastic, but we have some things to think about here:
I know I'm asking the same question over and over, using different words, but I feel that Capsules are so connected to the project we are building now, because as soon as you install a Capsule you may want to add or remove fields from it, or change the order of the fields in the form, or just disable translations because your project has only one language. So I feel that they are too much of a living being and cannot do everything, for everyone, so that "require" option could pose more problems than solutions.
Unless we keep the dependency management for packages and disable it for the Capsule itself and just let users to modify them if they want.
What do you think about all this?
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions