Skip to main content

Questions tagged [environmentvariables]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
1k views

Craft 4 Custom Variables - From Env > General.php > template

Been trying for a wee while, but no joy so far. This worked in Craft 3, but not in Craft 4. It's a CSS cache buster, I basically want a variable to set in env, then taken into general.php[caveat] and ...
John Macpherson's user avatar
1 vote
1 answer
21 views

Possibility to create / link custom (global) variables to shortcuts

Maybe I'm a bit vague in the topic-title, but here's a more in depth explanation of my question. I'm still a total n00b when it comes to Craft / Templating, so I hope you would forgive me if I'm ...
Hielke's user avatar
  • 81
3 votes
1 answer
511 views

Is there a way to return all available (custom) variables in some kind of list?

As I'm still a total n00b in working with CraftCMS, so I hope to get some help from more experienced users :-) I followed every available tutorial (which are very clear and well written. Great job!) ...
Hielke's user avatar
  • 81
4 votes
2 answers
485 views

How to set SMTP Enrcyption with an environment variable

The official Craft documentation says it is possible to set the "Encryption Method (SMTP)" , Snipped from the documentation, with an Environment Variable. I think i am missing something but ...
Leonardo's user avatar
  • 471
0 votes
1 answer
112 views

All Plugins Showing "Not Installed" After Promoting Changes From Dev to Stage Environments

We are using the custom exec widget to move the codebase, backend fields, section creations, and images from one environment to another. We have Dev, Stage, and Production environments. After ...
ExterroMedia's user avatar
1 vote
1 answer
325 views

Template URL/path alias

Is there any way to use an environment variable in the URL and template path settings for sections? We are prototyping a site with a temporary skin running alongside our front-end build but would ...
Cole Henley's user avatar
  • 1,741
1 vote
1 answer
881 views

Managing `isSystemLive` with Project Config

In Step 6 of the Project Config Environment Setup, it is suggested to disable allowAdminChanges so that changes aren't lost unexpectedly on production environments. I maintain a Craft CMS site which ...
Joseph Kerkhof's user avatar
1 vote
1 answer
78 views

Craft Script: Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'

I keep getting the error Environment variable GLOBAL_DB_DRIVER was neither 'mysql' nor 'pgsql'. Aborting. when trying to pull the database from the production server to staging using Craft Script. I ...
Lee's user avatar
  • 139
1 vote
1 answer
240 views

Configure path craft uses for composer and php

Is it possible to configure the PATH to composer that craft is using? In a shared hosting (our server, lots of sites) php isn't available by default. It's provided via redhat software collections. ...
Derak's user avatar
  • 131
1 vote
1 answer
373 views

Use .env values in Craft 3 plugin settings

I’m writing a plugin and need some of its settings to be pulled from the .env file. According to the docs the following should work, but the getter isn’t getting called whenever the plugin’s ...
oscaralexander's user avatar
2 votes
1 answer
794 views

Error using environment variable for email setting

I'm trying to create an environment variable for email settings, but it doesn't work. Here is my email setting at config/general.php 'dev' => [ '@host' => 'host', '@port' => '587', ...
Lee's user avatar
  • 139
1 vote
1 answer
144 views

Just upgraded to Craft 3, environmentVariables changed or stopped working

In my Craft 2 install, I had many links in Twig templates like this: <link rel="stylesheet" href="{{ craft.config.environmentVariables.baseUrl }}assets/css/styles.css"> I recently upgraded to ...
David Rhoden's user avatar
1 vote
0 answers
725 views

Using @webroot in templates returns a different path, can't override in config

I'd like to use @webroot in my templates using the {{ alias('@webroot') }} tag. However, when I do this it returns a longer path than what is returned when I use @webroot in the control panel. For ...
Lauren's user avatar
  • 171
1 vote
1 answer
397 views

Are there any benefits to using Yii's Aliases vs getenv?

As part of a refactor on our code base, we have been looking into our use of Yii 2's aliases and PHP's getenv function. Here's a code example: Alias <link rel="icon" sizes="96x96" type="image/png"...
Jamie Wade's user avatar
  • 3,644
4 votes
1 answer
861 views

Asset Volume using Environment Variable on File System Path as literal string on upload

I have a volume called "Website" with a File System Path that uses an environment variable, $ASSET_ADHOC_PATH. The variable has been setup in my .env file as follows: ASSET_ADHOC_PATH="/home/theadhoc/...
theAdhocracy's user avatar
1 vote
1 answer
183 views

Allowing CRAFT_TEMPLATE_PATH in index.php from .env variable

It appears on Craft 3.1.8 that I can't set the CRAFT_TEMPLATE_PATH from .env without throwing a PHP notice error. This appears to be because the .env is loaded after the defines and I want to access ...
joomkit's user avatar
  • 2,034
2 votes
1 answer
533 views

baseUrl outputs environment variable

The newer versions of Craft CMS stimulate using environment variables in the CP. It works perfectly. I have set two variables for sites in my .env file: DUTCH_SITE_URL="http://company.test" ...
Rinus's user avatar
  • 135
1 vote
1 answer
2k views

How can I access environment variables from a javascript file in Craft 3?

I see a lot of information about using environment variables on php files or twig templates, but I want to use them on javascript. I need to pass the environment, located on the .env file, to the ...
Tyrannogina regina's user avatar
2 votes
1 answer
217 views

ImageOptimize not using image url specified in my multi-environment setup and my volume config

When I output my ImageOptimize field in the template, my images are not showing up. If you inspect the image url, it's missing a folder name I'm specifying as part of the url in my multi-environment ...
Dan Lee's user avatar
  • 1,107
7 votes
1 answer
3k views

How to set up multi-env in Craft 3 with .env files?

How do I take advantage of the new .env files? I want to setup a local and production environment in Craft 3. Anyone know how to do this or know of any docs out there explaining it ?
Payton Burdette's user avatar
3 votes
3 answers
465 views

Using a dynamic url with Feed Me

I'm trying to import posts using the Feed Me plugin. I'd like to make a dynamic URL so that I can access the feed from a Cron job or from elsewhere in the CP. It says in the docs that I can use ...
jtenclay's user avatar
  • 311
3 votes
1 answer
2k views

Craft 3: Environment variables are not parsed when used in Assets source field

I'm using Craft 3 and I have 2 Sites setup. In my config/general.php file I have: return [ '*' => [ 'environmentVariables' => [ 'baseAssetsUrl' => '//'.strtolower($...
Sean Delaney's user avatar
1 vote
1 answer
115 views

Can I get the value of an environment variable in routes.php (or other config files)?

I am trying to get the value of an environment variable (defined in the general.php config file) in the routes.php config file. Is it possible or not? I tried $environmentVariables = craft()->...
benface's user avatar
  • 226
1 vote
1 answer
105 views

Include Global Set Variable in Print Delimiters

I have a site which has another group site - both use same templates but I want to include different phone number in the header of each. I was wanting to use Global Set Variables to pull this ...
mmc501's user avatar
  • 1,789
0 votes
1 answer
987 views

Define a dynamic 'basePath' environmental variable without the locale

So in my general config file I've defined an environmental variable called basePath (as per the Environment-Specific Variables documentation). I'm using the getcwd() function to get the working ...
Mark Notton's user avatar
  • 2,337
1 vote
1 answer
130 views

How to set multi-lingual image paths in a css file for different environments?

Not sure how to do this. I'm setting up a multi-lingual site with a couple of locales and I have 3 different environments set up. I've set up some environmentVariables for assets store and assets path ...
Lettie's user avatar
  • 2,033
1 vote
0 answers
2k views

Can’t log in to the Craft control panel

After I input my credentials, it just stayed on the login page, and did not go to the dashboard. The password is good, we didn't get invalid username and password error. I opened the trace mode and ...
xyray's user avatar
  • 79
6 votes
1 answer
887 views

Using Craft environment variable for Asset source subfolder

I have an environment variable "bucketUrl" that I would like to use as the subfolder path in my S3 bucket. However, Craft is not parsing the variable. When I upload an image, I see in my S3 bucket ...
Manny's user avatar
  • 63
1 vote
1 answer
70 views

Environmental variable coming back as literal braces

I have my general config file set up as follows: return array( 'localhost' => array( 'devMode' => true, 'environmentVariables' => array( 'baseUrl' => 'http://localhost:8888/path/...
strandall's user avatar
  • 188
2 votes
1 answer
719 views

Images are broken when I upload them

I have just started using craft today and I have hit a bit of a bump with Images. I created and asset for Work and set it up to point to assets/images/work/ I was able to upload the image but when I ...
Daimz's user avatar
  • 171
2 votes
1 answer
406 views

devMode, phpdotenv variable ignored

I'm using dotphpenv for environment specific config. This works perfectly for my db config. I added another 2 environment vars for devMode and allowAutoUpdates DEV_MODE=false AUTO_UPDATE=false and ...
Steven Grant's user avatar
  • 1,855
3 votes
3 answers
2k views

How to parse environment variables and globals from a field

I want the ability to parse environment variables such as {siteName} and globals from channel fields, for example a rich text field. I have been using {{ include(template_from_string(entry.fieldName)|...
zizther's user avatar
  • 449
3 votes
1 answer
675 views

Custom Environmental Settings

Is it possible to use custom environmental settings with Craft? I have separate web services that I use in production and development environments. I would like to programmatically point to the ...
Kevin's user avatar
  • 73
4 votes
1 answer
323 views

How can I parse environment variables in a string?

I have a string in my plugin that contains environment variables. How can I parse them the same way Craft does?
André Elvan's user avatar
  • 7,288
1 vote
1 answer
602 views

Environment variable doesn't work in Assets field settings

I created an environment variable (in config/general.php) called {baseAssetPath} which contains the server path to the folder where all my assets are stored. This makes it easier to populate the Path ...
Philip Jones's user avatar
6 votes
1 answer
2k views

Getting environmental variable via plugin

A similar question was answered before, but I was wonder how I might be able to return the same query from within a plugin (php)? Convert this: {{ craft.config.environmentVariables.baseUrl }} To ...
Mark Notton's user avatar
  • 2,337