4

I'm developing two Laravel+Backpack applications at the same time.

I'm styling and changing the look and feel of Backpack a lot, not just on the CSS level, but also inside individual Blade templates.

Most of the changes apply to both applications I'm working on.

Currently, I will apply changes I make to one application manually to the other by copy+pasting the files and changes in /resources/views/vendor/backpack/crud and some custom CSS.

That however gets old fast, and I'm starting to think I should be building a package that I can share between projects. Maybe the changes I make eventuelly turn into a theme that might interest others and I'd need a delivery mechanism for that as well.

Does anyone have some pointers how to best do this. I'm new to the Laravel ecosystem and seeing a lot of advice on how to create a Laravel package, but I'm not sure if that applies to my situation.

What I'm looking for is to create a package that does nothing more than mirror the original views and CSS resources in vendor/backpack/crud/src/resources, but of course can also be customized in the project itself.

So when Backpack builds the UI, it would look up, say, a view

  • first in vendor/backpack/crud/src/resources/views
  • then in vendor/my-theme-for-crud/src/resources/views <-- my package/theme
  • then in my-project/resources/views/vendor/crud

Does Backpack even allow for that at present?

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • 1
    There's https://laravel.com/docs/9.x/packages and https://laravelpackage.com/#reasons-to-develop-a-package that I've referenced for package development, but I haven't developed any that require another package (backpack) as a dependency... Backpack _is_ open source, https://github.com/laravel-backpack/crud, so you _could_ fork the repo, modify to your needs, then install that instead of base backpack, but then comes the headache of keeping it up-to-date with `main` (technically optional, but good for security issues, etc.). Beyond those musings, not sure; haven't worked with backpack directly. – Tim Lewis Jan 17 '23 at 15:28
  • 1
    @TimLewis yeah forking would be a last resort, but one I'm hoping to be able to avoid if possible! What I'm building might be to the liking of other users down the line as well, so some sort of theming mechanism could be really useful for everyone involved (but may simply not exist in Backpack as of yet) – Pekka Jan 17 '23 at 15:31
  • I would suggest a better alternative, which is laravel nova. That is better customizable and easier to template as well. Plus it's made by the laravel team – RG Servers Jan 17 '23 at 19:14

1 Answers1

3

Turns out there is some theming support in Backpack!

https://backpackforlaravel.com/docs/5.x/base-how-to#create-a-new-theme-child-theme

You can create a theme with your own HTML. Create a folder with all the views you want to overwrite, then change view_namespace inside your config/backpack/base.php to point to that folder. All views will be loaded from that folder if they exist, then from resources/views/vendor/backpack/base, then from the Base package.

You can use child themes to:

create packages for your Backpack admin panels to look different (and re-use across projects) use a different CSS framework (ex: Tailwind, Bulma)

Changes are to come in the upcoming v6 of backpack:

We are completely re-writing the theming/asset system in Backpack v6 (due next months).

Pekka
  • 442,112
  • 142
  • 972
  • 1,088