Commit 273fd1e1 authored by Timothée Jaussoin's avatar Timothée Jaussoin

Move the configuration to the .env file to support per-instances configurations

Complete the README
parent dfc619a1
Pipeline #15330 passed with stages
in 1 minute and 9 seconds
......@@ -5,6 +5,10 @@ APP_DEBUG=false
......@@ -26,6 +26,41 @@ Complete all the other variables in the `.env` file:
- SMTP configuration
- App name, SIP domain…
### Multi instances environement
FlexiAPI can also handle multi domains setup.
To do so, configure several web servers virtualhosts and set a specific `APP_ENV` environement variable in each of them.
With Apache, use the [mod_env]( module.
SetEnv APP_ENV foobar
On nginx use `fastcgi_param` to pass the parameter directly to PHP.
location ~ [^/]\.php(/|$) {
include /etc/nginx/fastcgi_params;
fastcgi_param APP_ENV foobar;
Note that if `APP_ENV` is not set FlexiAPI will directly use the default `.env` file.
FlexiAPI will then try to load a custom configuration file with the following name `.env.$APP_ENV`. So for the previous example `.env.foobar`.
You can then configure your instances with specific values.
INSTANCE_COPYRIGHT="FooBar - Since 1997"
INSTANCE_INTRO_REGISTRATION="Welcome on the FooBar Server"
#### Custom theme
If you set `INSTANCE_CUSTOM_THEME` to true, FlexiAPI will try to load a CSS file located in `public/css/$`. If the file doesn't exists it will fallback to `public/css/style.css`.
We advise you to copy the `style.css` file and rename it to make your custom CSS configurations for your instance.
### SELinux
If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured.
namespace App;
use Illuminate\Database\Eloquent\Model;
class Configuration extends Model
protected $table = 'configuration';
protected $fillable = ['copyright', 'intro_registration', 'custom_theme'];
......@@ -10,7 +10,6 @@ use Carbon\Carbon;
use App\Account;
use App\Alias;
use App\Configuration;
use App\Rules\SIP;
use App\Helpers\Utils;
use App\Libraries\OvhSMS;
......@@ -41,8 +40,7 @@ class AccountController extends Controller
public function register(Request $request)
return view('account.register', [
'domain' => '@' . config('app.sip_domain'),
'configuration' => Configuration::first()
'domain' => '@' . config('app.sip_domain')
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Configuration;
class ConfigurationController extends Controller
public function edit(Request $request)
$configuration = Configuration::first();
if (!$configuration) $configuration = new Configuration;
return view('admin.configuration.edit', [
'configuration' => $configuration
public function update(Request $request)
$configuration = Configuration::first();
if (!$configuration) $configuration = new Configuration;
$configuration->copyright = $request->get('copyright');
$configuration->intro_registration = $request->get('intro_registration');
$configuration->custom_theme = $request->input('custom_theme', false);
return redirect()->route('admin.configuration.update');
return [
'copyright' => env('INSTANCE_COPYRIGHT', null),
'intro_registration' => env('INSTANCE_INTRO_REGISTRATION', null),
'custom_theme' => env('INSTANCE_CUSTOM_THEME', false),
\ No newline at end of file
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateConfigurationTable extends Migration
public function up()
Schema::create('configuration', function (Blueprint $table) {
public function down()
......@@ -40,12 +40,6 @@
<p class="mb-1">Manage the FlexiSIP accounts</p>
<a href="{{ route('admin.configuration.edit') }}" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Configuration</h5>
<p class="mb-1">Configure the layout and other parameters</p>
......@@ -2,8 +2,8 @@
@if ($configuration && !empty($configuration->intro_registration))
<p>{!! nl2br($configuration->intro_registration) !!}</p>
@if (config('instance.intro_registration'))
<p>{!! nl2br(config('instance.intro_registration')) !!}</p>
You already have an account?
<li class="breadcrumb-item active" aria-current="page">Configuration</li>
{!! Form::open(['route' => 'admin.configuration.update']) !!}
<div class="form-row">
<div class="form-group col-md-6">
{!! Form::label('copyright', 'Copyright') !!}
{!! Form::text('copyright', $configuration->copyright, ['class' => 'form-control', 'placeholder' => 'Copyright']) !!}
<div class="form-row">
<div class="form-group">
{!! Form::label('intro_registration', 'Introduction text during Registration') !!}
{!! Form::textarea('intro_registration', $configuration->intro_registration, ['class' => 'form-control', 'placeholder' => 'Introduction text during registration']) !!}
<div class="form-check mb-3">
{!! Form::checkbox('custom_theme', 'checked', $configuration->custom_theme, ['class' => 'form-check-input', 'id' => 'custom_theme']) !!}
<label class="form-check-label" for="custom_theme">CSS spéficique</a></label>
<div class="form-row">
<button type="submit" class="btn btn-primary">Save</button>
{!! Form::close() !!}
\ No newline at end of file
<!DOCTYPE html>
@php $configuration = \App\Configuration::first() @endphp
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<meta charset="utf-8">
......@@ -9,8 +7,12 @@
<title>{{ config('') }}</title>
<link rel="stylesheet" href="" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
@if ($configuration && $configuration->custom_theme)
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}" >
@if (config('instance.custom_theme'))
@if (file_exists(public_path('css/'.config('app.env').'.style.css')))
<link rel="stylesheet" type="text/css" href="{{ asset('css/'.config('app.env').'.style.css') }}" >
<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}" >
......@@ -19,8 +21,8 @@
<footer class="text-center mt-2">
@if ($configuration)
{{ $configuration->copyright }}
@if (config('instance.copyright'))
{{ config('instance.copyright') }}
......@@ -56,7 +56,4 @@ Route::group(['middleware' => 'auth.admin'], function () {
Route::get('admin/accounts/{id}/deactivate', 'Admin\AccountController@deactivate')->name('admin.account.deactivate');
Route::get('admin/accounts/{id}/admin', 'Admin\AccountController@admin')->name('admin.account.admin');
Route::get('admin/accounts/{id}/unadmin', 'Admin\AccountController@unadmin')->name('admin.account.unadmin');
Route::get('admin/configuration', 'Admin\ConfigurationController@edit')->name('admin.configuration.edit');
Route::post('admin/configuration', 'Admin\ConfigurationController@update')->name('admin.configuration.update');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment