How to Preview a Word Press site

PHP Tools [?] extends Visual Studio with set of advanced features to work more efficiently with PHP code.

How to Preview a Word Press site

Postby gregoryagu » October 4th, 2013, 10:40 am

Hi,

Am new to PHP and PHP Tools for VS, but have used VS for a long time.

What I want to do is use VS for modifying a Word Press site. So I installed PHP Tools, and can run a basic PHP site.

Now, I created a new project from existing code, and selected the WordPress site directory and it imported the project.

What I want to do now is run/preview the site.

When I hit F5, it opens up IE, and tries to go to: http://localhost/?XDEBUG_SESSION_START=1

But it gives a 404 error.

So how do I preview the site? I made sure that index.php is set as the start-up page.

Greg
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am

Re: How to Preview a Word Press site

Postby Jakub Misek » October 4th, 2013, 10:52 am

Hi,

How did you configure startup options in your project properties?

I think WordPress would require IIS Express at least (built-in PHP web server is not enough for this)

Please give me know how it works for you.

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to Preview a Word Press site

Postby gregoryagu » October 4th, 2013, 11:12 am

Yes, I am using IIS Express.

When I create project from scratch, and run it, I do see Hello World, so everything is set up ok.

I tried then to add this line:

require('./wp-blog-header.php');

from wordpress, then it will no longer preview.

Maybe it can't find the file? I have ensured that the file is in the project.
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am

Re: How to Preview a Word Press site

Postby Jakub Misek » October 4th, 2013, 11:22 am

I see.

http://localhost/?XDEBUG_SESSION_START=1

is definitely not correct URL. If you open project properties, you can see actual URL is http://localhost:SOMETHING/

So PHP Tools opens this URL, BUT WordPress is probably installed already for http://localhost/.

This means, WordPress first thing it does is it redirects to http://localhost/ (which does not work).

You should remove wp-config.php file and let WordPress to install again using the correct URL.

Please give me know if it works for you,

Thanks!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to Preview a Word Press site

Postby gregoryagu » October 4th, 2013, 11:55 am

OK, I start with fresh WordPress installing, ie no configuration.

I then put a breakpoint in the code and run. It starts stepping through the PHP, including the WordPress.

And it is trying to do a redirect, which fails. But at least I can step through the code to debug.

My next question is on debugging: Once an error is thrown, I try to fix and run again. But it won't run a second time. It only gives a 404 error, but at least this time it's a bit different:
http://localhost/index.php?XDEBUG_SESSION_START=1 Note that it is at least giving the index.php. But the only way to get it to run again is to create a new php page, and then Require("index.php") which then does step in to the new code. But I have to create a new file every time the debugger errors out.

I have tried shutting down IIS Express so it restarts, and I have even tried shutting down Visual Studio and restarting it, but still it will not run unless I create a new file! This makes no sense unless it is a refresh issue with IE.
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am

Re: How to Preview a Word Press site

Postby Jakub Misek » October 4th, 2013, 2:30 pm

It is still the same issue with WordPress - it redirects you to localhost. This is WordPress feature. You have to setup WordPress to use IIS Express URL (localhost:1234) not localhost.

Once WordPress redirects to localhost, of course you cannot debug anything, because such URL does not exist, there is no web server that could respond to this request.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to Preview a Word Press site

Postby gregoryagu » October 7th, 2013, 9:54 am

I finally did get this working with Wordpress: What I did was install full IIS, set up working website, then use "Custom Web Server" in the PHP project properties. I set the Server Url to the website, and then it works!

I can then it F5 to run, and can step through the code and see the site it full.

Greg
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am

Re: How to Preview a Word Press site

Postby Jakub Misek » October 7th, 2013, 2:41 pm

Great!

Still I think the issue was, WordPress was installed on a different URL than it was being debugged, right?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to Preview a Word Press site

Postby gregoryagu » October 8th, 2013, 1:05 am

Yes, your right.

I could actually get index.php to view in IIS Express by removing all port numbers. But then as soon as I click on a link, then WordPress forwards to OfficeExtreme.com, as that is what is in the database as the location of the site. So then it gives a 404 error.

I suppose I could modify the database to say "localhost", but since I get it working with a custom server, I stopped working on it.

Thank you so much for your support, it was really frustrating trying to get this to work!

Greg
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am

Re: WordPress Compilation

Postby gregoryagu » October 8th, 2013, 1:22 am

I know this is old post, but I just ran into the same problem, and this is the fix:

Just add this to php.in.
extension=php_mysql.dll

and then make sure it exists in your ext directory (which it should already).

Greg

EDIT: Moved from Phalanger forum
gregoryagu
 
Posts: 9
Joined: October 4th, 2013, 10:31 am


Return to PHP Tools

Who is online

Users browsing this forum: No registered users and 46 guests

cron

User Control Panel

Login

Who is online

In total there are 46 users online :: 0 registered, 0 hidden and 46 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 46 guests