2

I know this may be a long and general question but I am struggling with it for the past two days and have achieved nothing.

I am a C# .net developer and I use Visual Studio IDE for my development which does all the back-end work for me when creating projects, setting virtual hosts, publishing the project and etc.

Now for some reasons I have to do a project in PHP and I chose PhpStorm as my IDE. I installed XAMPP and the Apache server is working ok, and I set its' php executable as an php interpreter in PhpStorm.

I don't want all my projects to be in xampp/htpdocs so I choose another location (d:\projects\phpStorm\<name of the project>) as my working space when I first created a project.

I installed xdebug using the tutorial it gave me:

Download php_xdebug-2.4.0rc4-5.6-vc11.dll

Move the downloaded file to C:\xampp\php\ext

Edit C:\xampp\php\php.ini and add the line

zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll

Restart the webserver

And I can confirm that it is installed using phpinfo() in a php file located in xampp/htpdocs.

My problem is with the debugging. When I click Run->Run in an opened php file in PhpStorm, it uses a free port and opens the php file with a url like this: localhost:port_number/<name of the project> and everything is ok.

Now I followed this tutorial to configure the xdebug. In step two, when I go to Run->Web Server debug validation, fill the Path to create validation script with d:\projects\phpStorm\<name of the project> and Url to validation script with localhost:port_number/<name of the project> (as mentioned above) and click validate I get this information (and an error in the last line):

Server Name: PhpStorm 10.0.3

Loaded php.ini: C:\xampp\php\php.ini

No debug extension is loaded

Follow this links to configure Xdebug or Zend Debugger. If you have already configured debug extension in php.ini file check possible reasons why it was not loaded:

You forgot to reload web server after changes in php.ini file.

You are configuring debug extension in the wrong php.ini (see the loaded php.ini files below).

There are errors on attempt to load debug extension, e.g. version incompatibility.

I want to know what should I do?

I really really want to set my projects in another location other than xampp/htpdocs to organize them properly, just like I do it in Visual Studio. So please don't suggest solutions involving me changing my working directory.

Thanks in advance.

P.S.: In JetBrain's tutorial, I see that the xdebug's IDKEY is PHPSTORM whereas mine is my pc's username, it it ok?

6
  • 1) I would suggest that you stick to xdebug 2.3.2 for PHP 5.6 -- 2.4 is not so stable/still has some issues 2) Please provide xdebug section of phpinfo() output - -just activating xdebug is not enough. 3) localhost:63342/PROJECT_NAME/ means that you are using PhpStorm's built-in simple web server. You need to define and configure deployment entry ("Local or Mounted Folder" type) and specify the URL that will be served by Apache. Commented Feb 18, 2016 at 20:05
  • 4) If you do not want to keep your project in xampp/htpdocs (like any proper dev would do) then you will either have to use symbolic link (from there to your real folder) or configure your Apache to use VirtualHosts (just like in IIS -- so that it will have it's own domain name (can be fakened via hosts file) / document root) Commented Feb 18, 2016 at 20:06
  • I wasn't aware that php storm has its own web server.thanks for that tip.So I should somehow make php storm user apache as its server, right? Commented Feb 18, 2016 at 20:36
  • Could you tell me specifically what to do? I know how to make a virtual server in xampp(I hope that I know the right way), but now I don't know how I can integrate it with php storm.also I have no idea if I should set a unique virtual host for each of my projects or I can just create one and then serve them all with that?I'll be really thankful if you could help me Commented Feb 18, 2016 at 20:40
  • 1) I host per project is the best (more close to real world examples -- each site uses it's own domain) 2) Define Deployment entry (if no file copying is required then "in Place" type will do) -- URLs are taken from there (you define website URL there so it will be used when you choose "Open in Browser" or some other actions) 3) On that official tutorials site -- there is section for Deployment as well. Commented Feb 18, 2016 at 20:59

1 Answer 1

0

I really really want to set my projects in another location other than xampp/htpdocs to organize them properly, just like I do it in Visual Studio. So please don't suggest solutions involving me changing my working directory.

Well you're really going to hate this then, but unfortunately Apache (which is what php runs on) only recognizes htdocs (or public_html, or www, depending on what specific server you are running, but anyhow in your case only htdocs) as a valid directory for php execution. Sooooo...

That doesn't really mean this is hopeless, but you might have to jump through some silly hoops to get it to work this way.

Option 1

You may have some luck creating a symbolic link from .htdocs to your projects folder from the command line:

ln -s C:xampp/htpdocs d:/projects/phpStorm

If you're on windows, this probably won't work. It also likely won't work between drives. It also may not work depending on your Apache configuration in XAAMP.

PROS: If it works, will do exactly what you want.

CONS: Probably won't work, if it does, will require nightmarish levels of config fiddling

Option 2

Use a remote development server, and sync over FTP with your IDE. I'm not super familiar with PhpStorm, but I can pretty easily do this in Netbeans or Eclipse. This is a good option when you need a local archive of a project retained. You might be able to set up an FTP server on your machine and accomplish this, however you are going to wind up with two copies of your project; one in your projects folder and the other in htdocs.

PROS: Your projects stay organized where you want them without much issue.

CONS: File duplication, they will have to be in htdocs anyhow for Apache to run php

Option 3

Accept that the technology is not designed to work this way and just put everything in htdocs where it belongs. Resisting the way technology works because you are used to a different workflow is how design flaws and really bad bugs happen. Use it the way it was meant to work and don't be scared of learning new things.

PROS: No conflicts with the XAAMP stack whatsoever

CONS: You specifically stated you don't want to do it this way, but this is really the best way

Option 4 (Don't do this)

Install PHP as a globally accessible command line utility across your entire system, and consequently get all kinds of crazy viruses and errors that you may not be able to fix ever.

PROS: Minor alleviation of aggravation with foreign workflows

CONS: All of the things. The worst things.

Option 5 (probably not going to work)

Try using VirtualHosts. There's a bunch of caveats with this though. First, doing this between different drives is nearly impossible to configure correctly due to security policies in your operating system that are difficult to overrule. Second, if you're on Windows (I assume you are if you are using XAAMP), you need to do all of the following: -In apache.conf, you need to enable your hosts file. -In the vhosts file, you need to create a new vhost. -In the windows hosts file, you also need to create a host, because for whatever reason windows likes to arbitrarily add redundant steps. On every other OS, this step is not neccessary. Also, you need to run your text editor as administrator to even do this at all. -Restart apache when it's all set up -Pray your machine will let you do this between drives (C: -> D:), or not take a million years to enable.

Sign up to request clarification or add additional context in comments.

5 Comments

"and consequently get all kinds of crazy viruses and errors that you may not be able to fix ever." lol....
it is not the matter of refusing to learn something new.It's just that I think it will be much cleaner and organized if I could do it this way.that's all
If you're coming from a .NET environment and getting into the apache stack, you're going to have to get used to the stack not automating the redundant stuff or holding your hand through it. This is actually the number one complaint most shops have about .NET devs: that they don't really fully understand the stack because it's too abstracted away in their work environment.
That's not really a criticism of .NET, but apache stacks are veeeeeeery different, and they turn into a mess very quickly if you try to reinvent the wheel.
Better option: Organize your project with Git. Then it doesn't matter where it is, because you can always git clone it to wherever you want on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.