0

Currently I am struggling with finding the best approach, to implement the following, maybe not everyday, requirement.

I plan to develop a Laravel application. The very general idea of this application is to generate the for websites, which are based on Laravel too, but completely working independent. So as an example: I, as an user, login to the Laravel application, create a new record „Webseite“ in the database and have, let’s say about 50 settings to individualize the website. To have some example of settings, this could be: the logo on the website, decision if the website should have a blog or not, the theme color to used in bootstrap variables, etc. After I have configured the website, I press a button and the Laravel application generates the code for this website, which works on Laravel too. In our case, we are building Statamic websites. So, after this process, I can download a Zip or even better everything gets moved to a new Git repository for this website and in this repository, I have all the files (app, bootstrap, config, content, database, .env.example, etc…) I need to get my Statamic running on any server. Now I have just to clone this new generated repository (or upload the Zip) to any server, run composer install & cp .env.example .env and website is ready to go.

In other words, with this Laravel application I want to write/generate code for another Laravel website. Code in this case means:

  • PHP (configs, routes, …)
  • YAML (Statamic blueprints, ….)
  • Statamic Templates (would prefer to you blade for Statamic instead of Antlers)
  • JS (frontend)
  • SCSS (frontend) And in all these files, I need to use blade-directives as I need to manipulate all these files, depending on the settings of the website.

Without a doubt, it’s technically no problem to do this. To have an config-app-php.blade.php which renders the config/app.php, or to have a app-scss.blade.php, etc.

But for me, it feels wrong to re render PHP, SCSS, JS or even worst, Blade-Template-files from Blade-Template-Files

Do you have any ideas, if there is a better way to implement this?

Thank you very much!

rakete
  • 2,953
  • 11
  • 54
  • 108
  • 1
    You mean something like "stubs"? Laravel uses stubs to generate models, controllers, view etc. [Stub Customization](https://laravel.com/docs/8.x/artisan#stub-customization) – brombeer Feb 27 '21 at 21:33
  • 1
    This sounds like it's probably not the right approach. If you're trying to let a user create a new site on a subdomain, then multitenancy is probably closer to what you want. – Matthew Daly Feb 27 '21 at 21:45
  • @brombeer Stubs seems to be the exact right keyword I am searching for. With Stubs, Laravel seems to do very similar stuff like I plan to do: Generate technical files (PHP, ...) depending on different parameters. Thanks for the hint! – rakete Feb 28 '21 at 08:21
  • @Matthew Daly, my idea is not about pointing several domains to one Laravel setup and answer all these requests from one multi tenancy system depending on the domain. Each website needs it's own repo and need to work 100% standalone. – rakete Feb 28 '21 at 08:27

0 Answers0