Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [environmentvariables]

The tag has no usage guidance.

1
vote
1answer
20 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
57 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
195 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
32 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
1k 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
105 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 ...
2
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
85 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
79 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
616 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
70 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
659 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
1answer
457 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
60 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/...
3
votes
1answer
385 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 ...
3
votes
1answer
236 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
775 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
453 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
201 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
348 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 ...