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
checkout the source file
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
there is no command to publish these stubs idk why
@Exi i am using filament v4 beta
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.
not a regression, and its all documented here https://filamentphp.com/docs/4.x/advanced/file-generation
Oh OK, my bad, it's great 😄 Thanks
@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, ..?
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.@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.
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.
Thanks mate..
@Adysone