What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

I want to get http_host for back office in spryker can anyone help how should i get it ?

U042Q46D597
U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

I want to get http_host for back office in spryker
can anyone help how should i get it ?

Comments

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    You mean getenv('SPRYKER_ZED_HOST')...?

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    i want to get $_SERVER['HTTP_HOST'] in spryker
    but i do not know how to get it in spryker ?

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    i want to verify wether it is http or https ?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    If you have xdebug configured, then you can just set up a random breakpoint somewhere in PHPStorm, load a shop page and once the breakpoint is caught, you can check the value of $_SERVER['HTTP_HOST'] in PHPStorm.

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    i tried to print $_SERVER but i did not get HTTP_HOST in $_SERVER array ?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Try what I just described above and see if you can find it that way.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    So like this:

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    Okay @U04FXCTCWPP
    But i want to get http or https because i want to append this to third party url..and i do not have xdebug configured

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Well, at least in my case, the value I have for $_SERVER['HTTP_HOST'] is the same what I see in my browser's URL bar. What do you see in yours? http or https?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Also, for configuring xedbug (if you are using Docker):
    https://docs.spryker.com/docs/scos/dev/the-docker-sdk/202204.0/configuring-debugging-in-docker.html
    It is very helpful, you should try to set it.

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    when i print $_SERVER i did not get HTTP_HOST

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Where and how do you print this? Because you don't seem to have any HTTP_ entries in there.
    (Also, you should probably remove that copypaste from here or at least edit it and remove the private key from it, as for reasons of security, you should not share that publicly)

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    yes i removed

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    So, where did you print that?

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    i print in my facade file...

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    And if you check the URL in your browser for the page you are on, what do you see there?

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    that is backoffice url

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Because, as I mentioned above, the $_SERVER['HTTP_HOST'] seems to be the same as what is in the browser's URL bar. So for example when I go to the Zed login page, the URL is:
    <http://backoffice.de.spryker.local/security-gui/login>
    and the $_SERVER['HTTP_HOST'] value is:
    [backoffice.de](http://backoffice.de).spryker.local

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    So you should be able to derive that from the URL you see there, based on the above example.

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    Okay @U04FXCTCWPP
    got it now
    so i created one console command which do some db operations and after that i want to get the http or https what ever it may be ?
    how should i get that ?

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    I'm not sure if http even comes into the picture at all if you're only working with a console command. Seeing how you didn't have any HTTP_ entries in your $_SERVER, I think you might simply not have that there at all. But if what you really need is simply to know whether you are using http or https, then you might simply check the SSL settings in your config.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    And that should be available.

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Use getenv('SPRYKER_SSL_ENABLE')

  • U04FXCTCWPP
    U04FXCTCWPP Posts: 91 🧑🏻‍🚀 - Cadet

    Yep, as I suspected:
    https://www.php.net/manual/en/reserved.variables.server.php

    Note: When running PHP on the command line most of these entries will not be available or have any meaning.

  • U042Q46D597
    U042Q46D597 Posts: 26 🧑🏻‍🚀 - Cadet

    Got that

    getenv('SPRYKER_SSL_ENABLE') ? 'https' : 'http';