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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With