patgilmour's avatar

Telescope in Hell (read "WordPress")

I appreciate this is unconventional and likely unadvised but, at my wit's end trying to wrangle a WordPress plugin square peg into a round hole, I have given up and installed Laravel inside a WordPress plugin (yep!). For those not familiar with WordPress (lucky you), Laravel resides here:

https://mydomain.com/wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/

Incredibly, it worksand brings instant relief for what I need to do.

To hit my Laravel site home page, I visit:

https://mydomain.com/wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/public/

Pretty much everything works, make:auth, migrations, php artisan, etc.

I can make a new route like Route::get('my_route', 'SomeController@index'); and that works if I hit it at:

https://mydomain.com/wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/public/my_route

Encouraged by this, I installed Telescope and I can visit it too at the default path:

https://mydomain.com/wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/public/telescope

This successfully loads the Telescope interface, but when I click on one of the sidebar categories, the path is wrong on the click and so I get an eternal "Scanning..." message. For example, if I click on 'Requests' the URL is not:

https://mydomain.com/wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/public/telescope/requests

but

https://mydomain.com/telescope/requests

So, I know I'm trying to mix oil and water, and I know I'm bringing disgrace on our noble house etc., but can anyone think of a way to get Telescope to work in this scenario?

I've tried adding TELESCOPE_PATH=various_different_paths but to no avail

And by the way, this Laravel app will only ever have two routes: a redirect from WordPress and an endpoint form an external service... so it's not that bad.

Thanks!

0 likes
3 replies
patgilmour's avatar

Okay, here is a fix that works. In the .htaccess file in root of the WordPress install, add this before all other directives:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^telescope/(.*)$ /wp-content/plugins/MY_PLUGIN/MY_LARAVEL_INSTALL/public/index.php/telescope [L,NS]
</IfModule>

Leave your config/telescope.php TELESCOPE_PATH as the default.

patgilmour's avatar

Thanks Snapey, and you are right.

However, I am able to move anything I want to keep secure from .env to the various PHP files in /config

Do you think that would be enough?

[Edit...]

Actually, after considering your answer, I think I should move the whole thing to a subdomain and completely out of WordPress, so only the Laravel /public folder is exposed. Thanks.

Please or to participate in this conversation.