Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

use config instead of env()

peaklabs-dev1ffa88acf040
diff --git a/app/Console/Commands/Dev.php b/app/Console/Commands/Dev.php
index 1188463042..962000d070 100644
--- a/app/Console/Commands/Dev.php
+++ b/app/Console/Commands/Dev.php
@@ -57,7 +57,7 @@ class Dev extends Command
{
// Generate APP_KEY if not exists
- if (empty(env('APP_KEY'))) {
+ if (empty(config('app.key'))) {
echo "Generating APP_KEY.\n";
Artisan::call('key:generate');
}
diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php
index e81b22ee6b..bbf1dc0930 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -77,8 +77,8 @@ class Init extends Command
echo "Could not setup dynamic configuration: {$e->getMessage()}\n";
}
$settings = instanceSettings();
- if (! is_null(env('AUTOUPDATE', null))) {
- if (env('AUTOUPDATE') == true) {
+ if (! is_null(config('constants.coolify.autoupdate', null))) {
+ if (config('constants.coolify.autoupdate') == true) {
$settings->update(['is_auto_update_enabled' => true]);
} else {
$settings->update(['is_auto_update_enabled' => false]);
diff --git a/app/Console/Commands/SyncBunny.php b/app/Console/Commands/SyncBunny.php
index 228467f885..df19038286 100644
--- a/app/Console/Commands/SyncBunny.php
+++ b/app/Console/Commands/SyncBunny.php
@@ -57,7 +57,7 @@ class SyncBunny extends Command
PendingRequest::macro('storage', function ($fileName) use ($that) {
$headers = [
- 'AccessKey' => env('BUNNY_STORAGE_API_KEY'),
+ 'AccessKey' => config('constants.bunny.storage_api_key'),
'Accept' => 'application/json',
'Content-Type' => 'application/octet-stream',
];
@@ -69,7 +69,7 @@ class SyncBunny extends Command
});
PendingRequest::macro('purge', function ($url) use ($that) {
$headers = [
- 'AccessKey' => env('BUNNY_API_KEY'),
+ 'AccessKey' => config('constants.bunny.api_key'),
'Accept' => 'application/json',
];
$that->info('Purging: '.$url);
diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php
index 47fd21df7c..efda024963 100644
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@ -359,7 +359,7 @@ function isDev(): bool
function isCloud(): bool
{
- return ! config('constants.coolify.self_hosted');
+ return ! config('.self_hosted');
}
function translate_cron_expression($expression_to_validate): string
@@ -989,7 +989,7 @@ function generateEnvValue(string $command, Service|Application|null $service = n
function getRealtime()
{
- $envDefined = env('PUSHER_PORT');
+ $envDefined = config('constants.pusher.port');
if (empty($envDefined)) {
$url = Url::fromString(Request::getSchemeAndHttpHost());
$port = $url->getPort();
diff --git a/config/constants.php b/config/constants.php
index d8e8223cde..5c54cea0d6 100644
--- a/config/constants.php
+++ b/config/constants.php
@@ -29,6 +29,7 @@ return [
'pusher' => [
'host' => env('PUSHER_HOST'),
+ 'port' => env('PUSHER_PORT'),
'app_key' => env('PUSHER_APP_KEY'),
],
@@ -56,20 +57,6 @@ return [
],
],
- 'waitlist' => [
- 'enabled' => env('WAITLIST', true),
- 'expiration' => 10,
- ],
-
- 'sentry' => [
- 'sentry_dsn' => env('SENTRY_DSN'),
- ],
-
- 'webhooks' => [
- 'feedback_discord_webhook' => env('FEEDBACK_DISCORD_WEBHOOK'),
- 'dev_webhook' => env('SERVEO_URL'),
- ],
-
'limits' => [
'trial_period' => 0,
'server' => [
@@ -89,4 +76,23 @@ return [
'dynamic' => true,
],
],
+
+ 'waitlist' => [
+ 'enabled' => env('WAITLIST', true),
+ 'expiration' => 10,
+ ],
+
+ 'sentry' => [
+ 'sentry_dsn' => env('SENTRY_DSN'),
+ ],
+
+ 'webhooks' => [
+ 'feedback_discord_webhook' => env('FEEDBACK_DISCORD_WEBHOOK'),
+ 'dev_webhook' => env('SERVEO_URL'),
+ ],
+
+ 'bunny' => [
+ 'storage_api_key' => env('BUNNY_STORAGE_API_KEY'),
+ 'api_key' => env('BUNNY_API_KEY'),
+ ],
];
diff --git a/config/sentry.php b/config/sentry.php
index 232070705b..0efb4a0e2b 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -3,11 +3,11 @@
return [
// @see https://docs.sentry.io/product/sentry-basics/dsn-explainer/
- 'dsn' => config('coolify.sentry_dsn'),
+ 'dsn' => config('constants.sentry.sentry_dsn'),
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.368',
+ 'release' => config('constants.coolify.version'),
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php
index 78ae02f3ac..8c5017e03b 100644
--- a/resources/views/layouts/base.blade.php
+++ b/resources/views/layouts/base.blade.php
@@ -84,9 +84,9 @@
window.Pusher = Pusher;
window.Echo = new Echo({
broadcaster: 'pusher',
- cluster: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
- key: "{{ env('PUSHER_APP_KEY') }}" || 'coolify',
- wsHost: "{{ env('PUSHER_HOST') }}" || window.location.hostname,
+ cluster: "{{ config('constants.pusher.host') }}" || window.location.hostname,
+ key: "{{ config('constants.pusher.app_key') }}" || 'coolify',
+ wsHost: "{{ config('constants.pusher.host') }}" || window.location.hostname,
wsPort: "{{ getRealtime() }}",
wssPort: "{{ getRealtime() }}",
forceTLS: false,
diff --git a/resources/views/livewire/project/shared/terminal.blade.php b/resources/views/livewire/project/shared/terminal.blade.php
index 3bbc9946c4..b15f2aaa90 100644
--- a/resources/views/livewire/project/shared/terminal.blade.php
+++ b/resources/views/livewire/project/shared/terminal.blade.php
@@ -26,9 +26,9 @@
<script>
// expose terminal config to the terminal.js file
window.terminalConfig = {
- protocol: "{{ env('TERMINAL_PROTOCOL') }}",
- host: "{{ env('TERMINAL_HOST') }}",
- port: "{{ env('TERMINAL_PORT') }}"
+ protocol: "{{ config('constants.terminal.protocol') }}",
+ host: "{{ config('constants.terminal.host') }}",
+ port: "{{ config('constants.terminal.port') }}"
}
</script>
@endscript
diff --git a/resources/views/livewire/settings/index.blade.php b/resources/views/livewire/settings/index.blade.php
index 42bdfc2675..6eef2982ec 100644
--- a/resources/views/livewire/settings/index.blade.php
+++ b/resources/views/livewire/settings/index.blade.php
@@ -102,7 +102,7 @@
placeholder="1.1.1.1,8.8.8.8" />
<h4 class="pt-6">Update</h4>
<div class="text-right md:w-96">
- @if (!is_null(env('AUTOUPDATE', null)))
+ @if (!is_null(config('constants.coolify.autoupdate', null)))
<div class="text-right md:w-96">
<x-forms.checkbox instantSave helper="AUTOUPDATE is set in .env file, you need to modify it there."
disabled id="is_auto_update_enabled" label="Enabled" />
@@ -119,7 +119,7 @@
<x-forms.button wire:click='checkManually'>Check Manually</x-forms.button>
</div>
- @if (is_null(env('AUTOUPDATE', null)) && $is_auto_update_enabled)
+ @if (is_null(config('constants.coolify.autoupdate', null)) && $is_auto_update_enabled)
<x-forms.input required id="auto_update_frequency" label="Auto Update Frequency" placeholder="0 0 * * *"
helper="Cron expression for auto update frequency (automatically update coolify).<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every day at 00:00" />
@endif