Closed rfay closed 2 years ago
This is a result of the environment variables being missing, so will be fixed with populating PLATFORM_*
environment variables.
PLATFORM_APPLICATION_NAME PLATFORM_ENVIRONMENT PLATFORM_PROJECT PLATFORM_ROUTES (not sure what its value could be) PLATFORM_VARIABLES USER
Not sure the immediate OP is solvable though,
Platformsh\ConfigReader\NotValidPlatformException: No routes are defined. Are you sure you are running on Platform.sh? in /var/www/html/vendor/platformsh/config-reader/src/Config.php on line 299
No, I'm definitely not running on Platform.sh :)
Mmm it's from the ConfigReader which is used in the Drupal template...
Re $PLATFORM_ROUTES
, here's what I have in my Symfony app on a PSH environment:
{
"https://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/": {
"primary": true,
"id": null,
"production_url": "https://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/",
"attributes": {},
"type": "upstream",
"upstream": "app",
"original_url": "https://{default}/"
},
"https://www.workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/": {
"primary": false,
"id": null,
"production_url": "https://www.workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/",
"attributes": {},
"type": "redirect",
"to": "https://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/",
"original_url": "https://www.{default}/"
},
"http://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/": {
"original_url": "http://{default}/",
"id": null,
"primary": false,
"type": "redirect",
"to": "https://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/",
"production_url": "http://workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/"
},
"http://www.workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/": {
"original_url": "http://www.{default}/",
"id": null,
"primary": false,
"type": "redirect",
"to": "https://www.workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/",
"production_url": "http://www.workshop-5ziq2gq-6j4ypl5iendqc.eu-3.platformsh.site/"
}
}
I guess it should be easy to populate this $PLATFORM_ROUTES
env var based on the URL generated by DDEV:
{
"https://bigfoot-symfony.ddev.site/": {
"primary": true,
"id": null,
"production_url": "https://bigfoot-symfony.ddev.site/",
"attributes": {},
"type": "upstream",
"upstream": "app",
"original_url": "https://{default}/"
}
}
This value would then be base64 encoded and assigned to $PLATFORM_ROUTES
Here is what I have in my .platform/routes.yaml
:
# The routes of the project.
#
# Each route describes how an incoming URL is going
# to be processed by Platform.sh.
"https://{default}/":
type: upstream
upstream: "app:http"
"https://www.{default}/":
type: redirect
to: "https://{default}/"
Remind me where you instructed me about all the oddball base64-encoded environment variables. I don't see it in the issues. Is it in google docs? Or just https://docs.platform.sh/development/variables/use-variables.html#use-platformsh-provided-variables I guess?
PSH docs only explains that some variables like PLATFORM_ROUTES
are base64-encoded JSON objects.
So assuming that you have the JSON example above in a routes.json
file, you can obtain the base64 blob by doing:
cat routes.json | base64
Of course... we can't assume that the base64 tool is available on the host, so there will be some issues here.
Could this be done using Go somehow?
Of course, but the go code doesn't know we're doing platformsh stuff. Will have to think how it could be informed or triggered.
This whole class of things is going to turn out to be fragile and not completely solvable.
php ./drush/platformsh_generate_drush_yml.php
(hook provided by drupal template) fails with "failed to find a site URL" on ddev.