Special thanks to @vidar.langseid for his help to figure out the problem.
Well, I have figured out what’s the problem is to get the local environment up and running using the remote DB and Redis services.
First of all, I have to add some environment variables and this is covered in the platform.sh documentation page. Well, it covers just the related information and not the specific issue I encountered. But let’s add the relationships first:
platform tunnel:open && export PLATFORM_RELATIONSHIPS="$(platform tunnel:info --encode)"
This local variable is base64 encoded and you can see the real value behind it once you decrypt it using:
echo $PLATFORM_VARIABLES | base64 --decode
We can add
| json_pp to have much better readable form of the value.
BTW, you can get the same information when you run below command:
But the issue will not be solved with the above relationship!
In my case, I will not run the PHP built-in server and I gonna use my local nginx instead. It allows me to expose the environment variable from the webserver without being afraid that they will be lost for some reason. I add following in the Vhost file:
fastcgi_param PLATFORM_RELATIONSHIPS XXXXXXXX;
Note that the value here is the base64 one.
So, I still not have the
PLATFORM_ROUTES vaibale right now. To do so, I have to login into the running instance in platform.sh and get the value from there. First, the ssh connection to the webserver and just use
printenv. In the output we can see the value we are looking for.
I just add it to my local nginx too:
fastcgi_param PLATFORM_ROUTES XXXXX;
Alternatively, you can export it as environment variable as well:
We can also see the decrypted value if we want using:
echo $PLATFORM_ROUTES| base64 -d | json_pp
The first problem is solved. FYI: This issue is caused in this line
NOTE: We can run into purging caching issue if we have varnish in place, what is the common (active per default) use case when using ezplatform with platform.sh. So we have to purge or send invalidations to the local varnish instead of the remote one. We can avoid this situation by using the local Domain and configure it as
PLATFORM_ROUTES instead of using the remote one. To do so, just replace the remote domain in the previous echo output with your domain and use any online tool if you want to encrypt the value in base64 format. If you already have some experience using local varnish with tethered platform.sh project, don’t hesitate to write few lines about your experience ; - )
The Database connection issue is pretty simple to solve. Just create the
.env.local file and amend the database credentials there. This file usually will be ignored as you can see it in the
.gitignore file. No worry : - ) so in my case the configuration looks like below
# Doctrine DBAL