Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: setting urls + cookie domain #111

Open
shakyShane opened this issue Jun 19, 2018 · 2 comments
Open

Feature Request: setting urls + cookie domain #111

shakyShane opened this issue Jun 19, 2018 · 2 comments

Comments

@shakyShane
Copy link
Contributor

shakyShane commented Jun 19, 2018

When importing DB's from anywhere -> local, I always end up needing something like the following, can we make a helper command for it?

LOCAL_DOMAIN="daylong.m2"
LOCAL_URL="https://daylong.m2/"
workflow setup:store-config:set --base-url-secure="$LOCAL_URL"
workflow setup:store-config:set --base-url="$LOCAL_URL"
workflow sql -s "UPDATE core_config_data t SET t.value = '$LOCAL_DOMAIN' WHERE t.path = 'web/cookie/cookie_domain'"
@maxbucknell
Copy link
Contributor

In Magento 2.2, it is possible to set configuration in config.php, and env.php. These are merged. I'd far prefer that things like base URLs were set up once in a file env.php.template, and then not touched after that.

At that point, your refined setup process with a shell script neatly solves this problem too.

@maxbucknell
Copy link
Contributor

Another option that I've persistently used on Magento 1 and Magento 2 projects is an N98-Magerun script that sets config values. I've used these on basically every project I ever ran to automate configuration setting across environments.

In app/etc/store_config, there are four files, local.n98, dev.n98, staging.n98, and production.n98.

After pulling a database dump, running the command:

n98-magerun2 script < app/etc/store_config/local.n98

This file would contain something like:

config:store:set --scope-id=0 --scope=default -- 'web/secure/base_url' 'https://project.m2/'
config:store:set --scope-id=0 --scope=default -- 'web/unsecure/base_url' 'https://project.m2/'

config:store:set --scope-id=0 --scope=default -- 'web/secure/base_media_url' 'https://project.m2/media/'
config:store:set --scope-id=0 --scope=default -- 'web/secure/base_static_url' 'https://project.m2/static/'

config:store:set --scope-id=0 --scope=default -- 'web/unsecure/base_media_url' 'https://project.m2/media/'
config:store:set --scope-id=0 --scope=default -- 'web/unsecure/base_static_url' 'https://project.m2/static/'

config:store:set --scope-id=5 --scope=websites -- 'web/secure/base_url' 'https://project.m2/aus/'
config:store:set --scope-id=5 --scope=websites -- 'web/unsecure/base_url' 'https://project.m2/aus/'

These scripts with relevant environments would also run on deployments to the respective environments, and this would run in a nested fashion (so staging would run production.n98, followed by staging.n98, and dev would run these two in addition to dev.n98.

Since Magento 2.2, this is a worse solution than locking the values in env.php and config.php, but if we want to target every project we deliver, this is worth considering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants