Questions tagged [environmentvariables]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
24 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
1answer
55 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
0answers
74 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
1answer
78 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
1answer
267 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
1answer
61 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 ...
1
vote
1answer
252 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
1answer
889 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
1answer
73 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 ...
6
votes
1answer
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
1answer
200 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
1answer
1k 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
1answer
102 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
1answer
89 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
1answer
774 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
1answer
83 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
0answers
765 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 ...
5
votes
1answer
622 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
1answer
63 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
1answer
517 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
1answer
321 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
2answers
985 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
1answer
548 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
1answer
234 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
1answer
452 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 ...
5
votes
1answer
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 ...