Questions tagged [environmentvariables]
The environmentvariables tag has no usage guidance.
36
questions
1
vote
1
answer
15
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 ...
3
votes
1
answer
78
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!) ...
2
votes
2
answers
49
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 ...
0
votes
0
answers
34
views
Environment Password Variable Not Working
I have env variables setup for a SMTP connection. These setting work correctly locally, the same on a production server don't work.
After some troubleshooting, if I manually add the password via the ...
0
votes
1
answer
33
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 ...
1
vote
1
answer
84
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 ...
1
vote
1
answer
99
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 ...
1
vote
1
answer
40
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 ...
1
vote
1
answer
76
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. ...
1
vote
1
answer
142
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 ...
2
votes
1
answer
364
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',
...
1
vote
1
answer
105
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 ...
1
vote
0
answers
487
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 ...
1
vote
1
answer
296
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"...
3
votes
1
answer
530
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/...
1
vote
1
answer
101
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 ...
2
votes
1
answer
428
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"
...
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 ...
2
votes
1
answer
135
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 ...
7
votes
1
answer
2k
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 ?
1
vote
1
answer
281
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 ...
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($...
1
vote
1
answer
114
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()->...
1
vote
1
answer
102
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 ...
0
votes
1
answer
898
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 ...
1
vote
1
answer
121
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 ...
1
vote
0
answers
887
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 ...
6
votes
1
answer
840
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 ...
1
vote
1
answer
67
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/...
2
votes
1
answer
620
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 ...
2
votes
1
answer
383
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 ...
3
votes
3
answers
1k
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)|...
3
votes
1
answer
625
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 ...
4
votes
1
answer
269
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?
1
vote
1
answer
543
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 ...
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 ...