stub

I created a Filament resource using the following command: -----php artisan make:filament-resource XYZ --generate --view --soft-deletes After running this, Filament automatically generated the following file structure: 🗂️ app/Filament/Resources/XYZResource/Pages CreateXYZ.php EditXYZ.php ListXYZ.php ViewXYZ.php 🧩 app/Filament/Resources/XYZResource/Schemas XYZForm.php XYZInfoList.php 📊 app/Filament/Resources/XYZResource/Tables XYZTable.php To understand and possibly customize the generation process, I published the stubs using: ----------php artisan vendor:publish --tag=filament-stubs This gave me the following files in app/stubs/filament: ColumnView.stub ComponentView.stub EntryView.stub FieldView.stub LivewireFormView.stub LivewireSchemaView.stub LivewireTableView.stub PageView.stub ThemeCss.stub WidgetView.stub How are the Pages, Schemas, and Tables files generated internally? I don’t see any corresponding stubs for them in the published stub folder. Is the generation logic hardcoded or located elsewhere? Would appreciate any insights on how this works under the hood. I appreciate any help you can provide.
12 Replies
Exi
Exi4mo ago
checkout the source file
Exi
Exi4mo ago
GitHub
filament/packages/tables/stubs/Table.stub at 3.x · filamentphp/fil...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Exi
Exi4mo ago
there is no command to publish these stubs idk why
Sarthak Garg
Sarthak GargOP4mo ago
@Exi i am using filament v4 beta
Adysone
Adysone4mo ago
Hello! Apparently, there are no stubs for these files anymore. I encountered the issue when I tried to publish AdminPanelProvider.stub, but it turns out a class is now used to generate the files instead. I believe this is a regression, as it prevents me from customizing the stubs like before.
Adysone
Adysone4mo ago
Oh OK, my bad, it's great 😄 Thanks
Sarthak Garg
Sarthak GargOP4mo ago
@Adysone can u guide me please how can we edit stubs like v3, so that if we want to create a resource with custom stub settings, ..?
Adysone
Adysone4mo ago
The documentation states that you need to create a ClassGenerator class, which extends the base class PanelProviderClassGenerator (this is just an example). This approach gives you more flexibility than using stubs, since you can add custom logic. The only drawback is that I had to override the whole generatePanelMethodBody() method just to insert a few lines in the AdminPanelProvider, which feels a bit redundant.
Sarthak Garg
Sarthak GargOP4mo ago
@Adysone thanks mate.. it means the easiness of the filament is getting hard now. In previous version V3.x.. we just update the stubs and create as many crud forms with all things which we want to implement by default like roles and permissions on actions and so.. but this time in v4.xx it's getting hard to implement such basic things as we have to manually put line by line in each crud forms.
Adysone
Adysone3mo ago
I'm pretty sure you can make a class for resources generation, in which you can add your permissions stuff. I didn't test it but I believe it's possible.
Sarthak Garg
Sarthak GargOP3mo ago
Thanks mate.. @Adysone

Did you find this page helpful?