Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store templates for non-php files in Laravel?

Tags:

shell

php

laravel

We can store PHP template files using blade templating engine in Laravel. But, I want to create a config file on a remote server having more than 20-30 lines each.

Till now, I was doing this using Perl. I used to execute Perl file that used to dump contents in one file and I used to pass variables as parameters.

Now, I want to do it without using Perl. I tried looking for a solution but failed. To make it easy to understand, Here is what I am trying to do exactly!

I want to create the following config file on a remote server (Just an example).

Example.conf

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
</VirtualHost>

Here, example.com and www.example.com will vary in every config file.

Now, I want to create this file from my laravel application to the remote server. Is there any way I can store template of this config file and can compile and put file on remote server?

I know how can I put this file on Remote server. I just want to know the best possible way to store template and customize it when needed.

like image 817
p01ymath Avatar asked Mar 01 '18 07:03

p01ymath


Video Answer


1 Answers

You can put it into blade template like server-config.blade.php and then when you want to place it on a a server you just call:

\File::put('place-on-the-server.conf', view('server-config')->render());

which will generate content based on the blade template (so you can pass variables to this template).

like image 94
Filip Koblański Avatar answered Oct 10 '22 13:10

Filip Koblański