adamziel / playground-docs-workflow

Experimenting with maintaining WordPress docs using WordPress Playground
https://adamziel.github.io/playground-docs-workflow/
11 stars 2 forks source link

reallycoolobjects.com #55

Closed flexseth closed 2 months ago

flexseth commented 4 months ago

Blueprint idea: make a website that spoofs the URL bar

User goes to reallycoolobjects.com and it looks like their website

Their hosts file is tricked, but it makes demonstration so much better.

The challenge

In any case, recreating this huge knowledge base in Playground’s documentation site seems like a bad idea.

Here's a bad idea....

@ironnysh - you're good with wp-now ;)

I've got a scenario for you:

The steps should include how to set up VS Code for the instance.

And yes, the user will have to edit their hosts file.

End result

ie: user's website is called Really Cool Objects

the URL bar could show reallycoolobjects.com

Why?

Being able to customize the perceived URL is a huge benefit in many ways.

Extra Credit

Show how to save developer workspaces in VS Code

Make theme1 go to dev.reallycoolobjects.com

ironnysh commented 4 months ago

Hi @flexseth, not sure I follow 😅 Can you elaborate on the why?

adamziel commented 4 months ago

Also, spoofing the hosts file from Playground isn't technically possible.

flexseth commented 2 months ago

I tried getting this to work based on the instructions available in the wp-now documentation, did not seem to work.

Hosts file

## Playground ##
http://127.0.0.1:8881   http://myurl.wpnow:8881

blueprint

{
    "steps": [
        {
            "step": "defineWpConfigConsts",
            "consts": {
                "WP_HOME": "http://myurl.wpnow:8881",
                "WP_SITEURL": "http://myurl.wpnow:8881"
            },
            "method": "define-before-run"
        }
    ]
}

npx command

npx @wp-now/wp-now start --blueprint=blueprint.json

result

This site can’t be reached
Check if there is a typo in myurl.wpnow.
DNS_PROBE_FINISHED_NXDOMAIN

errors

errors: 'PHP Warning:  Constant WP_HOME already defined in /var/www/html/wp-config.php on line 2\n' +
      'PHP Warning:  Constant WP_SITEURL already defined in /var/www/html/wp-config.php on line 3\n' +
      'PHP Warning:  Cannot modify header information - headers already sent by (output started at /var/www/html/wp-config.php:2) in /var/www/html/wp-login.php on line 504\n' +

notable

I ran this in "WordPress" mode - IE: no files or folders except the blueprint.json file.

ironnysh commented 2 months ago

Hey @flexseth, the hosts file should look like this (without the protocol and port number):

127.0.0.1       myurl.wpnow

Can you see if it works?

flexseth commented 2 months ago

Hey @flexseth, the hosts file should look like this (without the protocol and port number):

127.0.0.1       myurl.wpnow

This works, but throws the error

Warning: Constant WP_HOME already defined in /var/www/html/wp-config.php on line 2 Warning: Constant WP_SITEURL already defined in /var/www/html/wp-config.php on line 3

Feel like this has been addressed somewhere.

I'll mark this as closed, there will probably be a good solution for handling URLs at some point.

ironnysh commented 2 months ago

@flexseth, you can try resetting the project (see wp-now README): --reset

Probably better to open a separate issue in the playground-tools repo, though.