When I make local changes to my PHP / WordPress website, the localhost does not seem to update for 20-30 minutes.
I'm on Mac OSX 10.8.4 and using MAMP Pro. I have two sites that I have created separate host entries for, let's call them mysite1.dev and mysite2.dev.
Here is my MAMP Server configuration:
Apache: 80
MySQL: 3306
SSL: 443
I saw this article ( How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion? ) on the Bonjour conflicts and edited my /private/etc/hosts file with the suggestions in this article:
I changed the host names from mysite1.localhost to mysite.dev because it sounds like the conflict is with .local names - DID NOT WORK
I updated the Hosts file to have separate ::1 addresses - DID NOT WORK:
::1 <tab> mysite1.dev
::1 <tab> mysite2.dev
I tried putting all of my host entries onto one line - also didn't work:
127.0.0.1 localhost mysite1.dev mysite2.dev
::1 localhost
fe80::1%lo0 localhost
It seems like MAMP Pro overwrites the hosts file any time I restart the server.
I would be SUPER grateful for any help you can offer.
Change MAMP cache to OPcache. It worked for me
I had the same problem and found the solution on this post: MAMP time between seeing live changes
The instructions, which I followed:
The solution is uncommenting lines in the php.ini file, which can be found in
/{MAMP Directory}/bin/php/php5.5.3/conf/php.ini
Comment out Opcache:
[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
; opcache.memory_consumption=128
; opcache.interned_strings_buffer=8
; opcache.max_accelerated_files=4000
; opcache.revalidate_freq=60
; opcache.fast_shutdown=1
; opcache.enable_cli=1
Documentation ( yes it started in 5.5 ):
http://www.php.net/manual/en/intro.opcache.php
I've been struggling with this issue ever since switching to SSL for my local environment (thanks, Salesforce API) and finally found a solution that worked for me:
Turning off Xdebug cut TTFB from 25 seconds to 2. Yeesh.
I had similar problems running php 5.5.3. After I changed back to 5.4.19 it worked.
You can change the version in the MAMP GUI. You might have to rename your 5.5.3 folder to 5.5.X for 5.4.19 to show up in the GUI. The php folders are placed at: Applications/MAMP/bin/php
For me, changing back to MAMPS standard port settings did the trick.
The solution that worked for me was to turn off Xdebug as #tammy-shipps mentioned. However since I have the vanilla MAMP version, I had to turn off Xdebug with the php.ini file found here:
/{MAMP Directory}/bin/php/{PHP Version}/conf/php.ini
Then change xdebug.remote_enable from 1 to 0:
xdebug.remote_enable=0
Unlike other proposed solutions, turning off cache or changing ports had no affect on the problem.
MAMP's default ports are non-standard. When I switched to standard ports (80 for Apache & 443 for SSL), it sped up dramatically.
I'm not sure if this is what Paul Bakker did, or if he switched the other way.
I'm using MAMP Pro 4.2, PHP 7.1.6, Apache, OS X 10.11.6.
It was really hard, but I found a solution that it works in my environment:
MAMP 4.2.1
PHP 5.6.31
SETTINGS left menu > Ports settings > Run servers as: > Change it to "Unix Users" option.
Setting xdebug.remote_host to to 127.0.0.1 instead of "localhost" solved this issue for me. This skips IPV6 resolution, which caused the delay.
Switching off remote_enable is not an option, because it kills debugging in PHPStorm:
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
I'm not sure about Mamp, however, I use php -S 0.0.0.0:4444 to spin up a local server. Its response got very slow after moving to Mojave.
I was able to fix it by updating /etc/hosts file with
::1 localhost YouMacName.local
127.0.0.1 localhost YouMacName.local
You can get YourMacName.local by running in terminal:
$ hostname
I was having same issue, I had added virtual host ending with .local which was causing 5 seconds delay in lookup.
To fix this I updated host file.
sudo nano /etc/hosts
And added my site with IPv6 address along with ::1 and 127.0.0.1.
::1 mysite.local
127.0.0.1 mysite.local
fe80::1%lo0 mysite.local
Switch off the
PHP-Cache
as shown below screenshot.
Below in the screen shot you can see
Related
This is my problem:
- I downloaded and installed XAMPP;
- I changed the listen port from 80 to 100 (to not interfere with Skype);
- in browser i typed: localhost:127.0.0.1:100
WAMPP page appears. So far so good. I opened NetBeans and tried to run a PHP application and I got Error 404.
Apache service is running (at least XAMPP reports soand the Apache icon is showing).
I use Win 7 on laptop, 64 b.
So, what can I do to successfully run the application.
Tank you,
Eugen
Do you have
Listen 81
in \xampp\apache\conf\httpd.conf ?
Or do you have the vhosts properly configured?
<VirtualHost *:100>
....
Do you have mod_rewrite enabled in httpd.conf?
LoadModule rewrite_module modules/mod_rewrite.so
I need help to configure xdebug, for debugging projects from IDE netbeans.
These are the features of my components:
XAMPP 1.8.2
PHP: 5.4.16
netbeans: 7.3.1
Apache: 2.4.4 (Win32)
this is the final part of my php.ini file:
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9-nts.dll"
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 1
;xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
;xdebug.trace_output_dir = "C:\xampp\tmp"
when I run phpinfo(), there is no xdebug installed, and when I debug a project from netbeans, it says "Waiting For Connection (netbeans-xdebug)".
can someone help me to configure it?
Have you rectified the issue ? If not then please try this.
1.) php.ini file content
[xDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
;xdebug.remote_host="localhost:81"
xdebug.remote_host=192.168.1.5
;xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"
xdebug.remote_host=192.168.1.5 - This is the IPv4 address of my system, I changed to this because I couldn't debug with localhost and 127.0.0.1.
in NetBeans IDE, open Tools-> Options -> PHP -> Debugging. The values of debugger port and Session Id should match with the port and idekey specified in php.ini.
Now save php.ini, restart Apache and try to debug.
Thanks Johnson
When Netbeans starts a Debugging session, it starts two Listeners, one on 0.0.0.0:9000 (all IPv4 IPs the system has), and the other on the IPv6 interface.
If Netbeans and the Web Server are on the same system, ideally XDebug would be configured to send the data back to 127.0.0.1:9000, on which NetBeans would be listening on (and only per session)...
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
If for whatever reason XDebug is not able to report back to 127.0.0.1, or Netbeans is not listening on 127.0.0.1, you can configure XDebug to send the data back to the $_SERVER['REMOTE_ADDR'] of the original request...
xdebug.remote_connect_back=1
This way you don't have to specify the exact IP (i.e., as in the above answer the LAN IP: 192.168.1.5). The downside here is that any source can connect.
If you have further trouble, this...
xdebug.remote_autostart=1
... will also start the debugging process for all requests, and not just for the ones with the proper session start query or cookie. The downside here is that all requests will initiate debug data collection and reporting back (making everything slower, and generating more data).
Though from what I've gathered, the majority of these "Waiting For Connection (netbeans-xdebug)" issues on Windows (with XAMPP, Wamp-Server, etc) are usually a result of Windows Firewall and McAfee (or other firewall and anti-virus software) blocking the connection...
Source: Netbeans "Waiting For Connection (netbeans-xdebug)" Issue
I am a .Net programmer and very new to PHP.
Recently I was trying to host an open source PHP application on my machine(Windows). After the Struggle for 5-6 days I will list the steps which worked for me.
I uninstalled every previous installations of XAMPP and NetBeans and proceeded with fresh installations.
This might not be the solution for everyone but it worked for me and I hope it helps someone.
install XAMPP
install netbeans for PHP.
Open IIS and stop it. It is running on port 80 by default.(I am running XAMPP on port 80 i.e. default, Running on other port might need additional configuration settings)
Open XAMPP control panel and start Apache. If port 80 is free no problem should arise.
Open localhost in browser in should display XAMPP home page.
open phpinfo() link on the left pane and copy all the contents on page.
Go to: http://xdebug.org/wizard.php and paste all the content in TextBox and click Analyze my phpinfo output. It will diplay you the Xdebug file suitable for your configuration.
Download the given Xdebug dll and copy it in C:\xampp\php\ext (Xampp being the default Xampp installation directory)
Goto XAMPP control panel, click on Config button in front of Apache and select php.in,
Find line similar or exacly like,
;zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
(Semicolon means it is commented)
Remove the semicolon and replace the path with the path of dll you just copied like:
zend_extension = "C:\xampp\php\ext\php_xdebug-2.3.2-5.4-vc9.dll"
Similarly find lines
;xdebug.remote_enable = 0
;xdebug.remote_handler = "dbgp"
remove semicolons in front of both lines and make remote_enable = 1
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
Restart Apache server.
Copy your website code under C:/XAMPP/htdocs/(your_website)/
that means your index.php should be at C:/XAMPP/htdocs/(your_website)/index.php
Open Netbeans select New project -> PHP -> PHP project from existing source and select the folder you just copied in htdocs folder.
Set it to run on Local web server.
Set a breakpoint on first line of index.php and debug.
That's it.
Additional settings were suggested on various different posts but above mentioned steps worked perfectly for me.
I want to mention something here about xdebug.remote_host
xdebug.remote_host="127.0.0.1"
Is Not valid. It may work in some cases, but the quotes can also cause issues. Most people don't have issues when using IP addresses in quotes, but this sets a bad precedent. It makes people think that if you want to use a hostname or URL you need to put it in quotes. This is incorrect, urls in quotes will not work.
If you want to debug using a url, you can do this by just putting the url after the equals like this:
xdebug.remote_host=subdomain.mydomain.com
I also want to mention that if you have a port number, don't add it. This doesn't work:
xdebug.remote_host=subdomain.mydomain.com:9000
This is what you want to do:
xdebug.remote_host=subdomain.mydomain.com
xdebug.remote_port=9000
If you do this, I also caution you make sure remote_connect_back is disabled. Like this:
xdebug.remote_connect_back=0
or you can ommit it entirely, like this:
;xdebug.remote_connect_back=1
If remote_connect_back is enabled, it will try and pull your IP address from the incoming connection and ignore the remote_host and port setting.
Xdebug uses plain old TCP to make connections. This is not HTTP. This means tools like Fiddler will not show any packets or information on debugging. If you need to debug, and see if the server is making a call to your IDE there are a few ways you can go about checking.
Wireshark will allow you to see TCP traffic. Also if you are on Windows, Microsoft Message Analyzer can also monitor TCP.
But, if all you are trying to do is remove your IDE is a possible cause of remote debugging problems, I suggest instead you start a local TCP server.
This is a great free java program to start a TCP server: http://sockettest.sourceforge.net/
In the IP Address section, just list 127.0.0.1 or leave it at 0.0.0.0. Then list the port number, which is usually defaulted to 9000 for xdebug.
Once the TCP server is running, open your remote webpage with an xdebug_break(); function call in it. This will tell xdebug on the remote server to start debugging on whatever server and port you listed in your php.ini.
Watch the socket server and see if you get a connection. The first data sent should look something like this:
<init appid="APPID"
idekey="IDE_KEY"
session="DBGP_COOKIE"
thread="THREAD_ID"
parent="PARENT_APPID"
language="LANGUAGE_NAME"
protocol_version="1.0"
fileuri="file://path/to/file">
If you have made it this far, remote debugging is working! Just stop the server and setup your IDE to listen on that port!
If you are like most of us, your developer machine is behind a router with NAT. This means that everyone in your office has the same public IP address. This is a problem because when xdebug contact that IP address to start debugging, it hits the router, and not your computer. The router can be configured to pass certain port numbers to individual computers, but you may not want to do that as that port will be open until you change your router settings back.
Another option is to use SSH. There is a great example of how to do this here: http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/#attachment_1305
My preferred option is to use Ngrok. Ngrok is a great tool for redirecting http, https and TCP traffic. In order to use the TCP redirect function you need to sign up for a free account.
Once you have signed up for an account, and added your API key to your computer run this command on the computer that your IDE is on:
ngrok tcp 9000
This will open a tcp (not http) tunnel from the ngrok server to whatever machine you ran the command on. I am using port 9000, you can change this port if your IDE is configured for a different Xdebug port.
This is what you should see:
You will need to see what the url is for the TCP tunnel that was opened. In this example it is:
0.tcp.ngrok.io:14904
For this session, the Xdebug setting on your server should be this:
xdebug.remote_host=0.tcp.ngrok.io
xdebug.remote_port=14904
The URL and port will change each time ngrok is launched. If you want to have the same url and port, you have to upgrade to a paid account. Make sure to restart apache after you make changes to your php.ini.
I just spent hours reading so many answers on this page and others like it, and nobody mentioned what ended up being the solution for me:
Make Sure Your Chosen Port Settings Match in All 3 Locations
My problem was that there are THREE places that the chosen port needs to match. Two of mine said 9001 and one said 9000. I changed them all to 9000.
That was the problem and why Netbeans would only say “Waiting For Connection (netbeans-xdebug)”.
The 3 port setting locations are:
php.ini (xdebug.remote_port=9000)
project properties > Run Configuration > Advanced
Netbeans > Tools > Options > PHP > Debugging
Check also the "windows" firewall settings.
For me it doesn't worked because my LAN network was declared as "Public network".
After i switched it to "Work network" it worked fine.
Try this setting if you have latest version of Xdebug the old version syntax has been changed
https://xdebug.org/docs/upgrade_guide
xdebug.mode=debug
xdebug.start_with_request = Yes
;xdebug.mode=profile
;xdebug.start_with_request=trigger
xdebug.client_host = "localhost"
xdebug.client_port = 9003
xdebug.remote_handler = "dbgp"
xdebug.log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.trace_output_dir = "C:\xampp\tmp"
In my case the Apache log showed a PHP warning about not having set date.timezone. Xdebug/netbeans began working as soon as I set it in php.ini and restarted apache.
date.timezone = America/Los_Angeles
This is PHP 5.5.
I'm on Windows with xampp and changed the [XDebug] section of my php.ini (at the bottom) to the following to get it working:
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
Sourced from the Netbeans wiki here: http://wiki.netbeans.org/HowToConfigureXDebug
If you have Apache running, remember to restart it after configuring XDebug and saving php.ini.
Adding this did work for me:
xdebug.idekey=netbeans-xdebug
I my case if I add following in php ini it did not work
zend_extension_ts="C:\PHP\PHP560\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll"
But If I add
zend_extension="C:\PHP\PHP560\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll"
It is working fine.
Having correctly set up the php.ini file, netbeans, port forwarding on the router, I was still getting the wretched "waiting for connection (netbeans-xdebug). I eventually noticed on the netbeans page "Do not forget to set output_buffering = Off in your php.ini file".
So I checked the /etc/php/7.x/apache2/php.ini file and sure enough it's value was 4096. So I reset output_buffering=Off and lo it worked !!!
Hope this helps someone, as the message implies it is a connection error rather than a configuration error.
check this out: Launch XDebug in Netbeans on an external request
another way is to open a new window:
try to go on Project > run configuration > advance
and switch to default, check if it opens another window in the browser
A try could be to start php -i in command window. When redirecting the output an error was
For me it was the FINAL solution because I had a wrong version of Xdebug downloaded
For me it should have been : php_xdebug-2.1.2-5.3-vc6.dll
But I had: php_xdebug-2.2.4-5.3-vc9.dll. So an error occurred from php -i
E:\Programme\php>php -i > myOutputFromPhp
yields following ERROR
Cannot load Xdebug - it was built with configuration API220090626,TS,VC9, whereas
running engine is API220090626,TS,VC6
I had the same problem.
why?
First I installed WAMP, thank Netbeans and they work together as a charm.
Later I installed XAMPP and Localhost sites were run smoothly but NetBeans could never connect to XAMPP (netbeans-xdebug).
At the same time NetBeans were working good with Wamp.
My solution was to go back to Wamp. It is better than nothing.
My PC:
Win-7-32, NetBeans-8.0.2,
wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b
xampp-win32-5.6.8-0-VC11
For Ubuntu users:
sudo su
apt-get install php5-dev php-pear
pecl install xdebug
find / -name 'xdebug.so' 2> /dev/null
it will return something like: /usr/lib/php5/20121212/xdebug.so
vi /etc/php5/apache2/php.ini
add this line: zend_extension="/usr/lib/php5/20121212/xdebug.so"
service apache2 restart
restart IDE
I spent a lot of time trying to get the optimal set up and thing this deserves its own reply, even though #Johnson T A's one it's almost correct.
He says
xdebug.remote_host=192.168.1.5 - This is the IPv4 address of my system, I changed to this because I couldn't debug with localhost and 127.0.0.1.
Well, not everybody can use a private address, or it may be dynamic, or other things. Also, in my case I was suffering from very long wait times before debugging actually started - 30 s or so every time. That was unpractical.
I'm sure everyone having these problems are at least on Windows 7 or so. The problem is related to a mix between name resolution and xdebug. To overcome them make sure that:
Port 9000 is not in use. If that's the case, change it to a unused one, both in php.ini and in netbeans.
Make sure that xdebug.remote_enableis on.
If you want to be able to debug using both localhost and 127.0.0.1 addresses, open \Windows\System32\drivers\etc and make sure that there you have the following lines:
127.0.0.1 localhost
::1 localhost
Make sure that the first line doesnt have a # before it and the second one does have it.
My working php.ini section (I don't need profiler so I disabled it):
[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.remote_enable = on
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.remote_port = 9001
xdebug.trace_output_dir = "C:\xampp\tmp"
xdebug.remote_log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = "netbeans-xdebug"
xdebug.remote_autostart = on
xdebug.remote_connect_back = on
Stop netbeans debugger. Restart Apache.
I bet you won't suffer from long waiting times anymore nor strange behaviour with debugger.
Explanation:
Althought in etc/hosts they say "localhost name resolution is handled within DNS itself", for whatever reason it doesn't work well with xdebug if you don't have it explicitely stated in that file. Explicitly putting it seems to do no harm overall, and solves this problem with xdebug. But also you need to explicitly disable the sIPv6 short notation for localhost (::1) in order for all this to work. Don't know the internal reasons but triead all the combinations and this one works for me like a charm.
I had this issue for one project, but not for others. So xdebug was correctly configured, the project settings were ok, but it still did not work.
So I just deleted the nbproject subdirectory, containing the project settings, and created a new project with the existing source. This solved the issue for me.
Select a specific browser for debugging:
Right Click on project -> select Properties
Select categories: Browser then selected a specific browser for debugging
If your xdebug is not working correctly, check your server log:
$ sudo less /var/log/httpd/error_log
To check connections, use this command:
$ sudo netstat -an
After starting debug on netbeans, if you use the netstat command, you can see the port of xdebug (probably it's 80):
tcp6 0 0 192.168.33.10:80 192.168.33.2:49901 ESTABLISHED
The port of netbeans is 9000:
tcp 0 0 192.168.33.10:52024 192.168.33.2:9000 ESTABLISHED
You can change the xdebug's port from here (From the top menu, Tools -> Options -> PHP):
If the connection is not established, it is highly possible that your connection is blocked by your anti-virus program or firewall. You can check it in your anti-virus program or firewall and remove the block as it is a safe connection.
After you make changes to your php.ini or xdebug.ini files, regardless of how you're running your web server, make sure to restart that web server (for example: service httpd restart on CentOS) or Apache will not pick up the changes you've made to that .ini file.
The xdebug package on CentOS is "phpXXu-pecl-xdebug".
Defaults on most recent Xdebugs are usually fine. It's only strictly necessary to get these two values right, somewhere in an Apache .ini file:
xdebug.remote_enable=on
xdebug.remote_host=[DNS entry that resolves to the IP4 of your debugger]
I had the same problem and tried to solve it for hours. I finally found out that the chrome extension ipflood which changes the headers to make it look like you are using a proxy, was the cause.
It works perfectly fine after I disabled it!
Also, consider whether the NTS or the TS version of xdebug is suitable for your case.
Check the Apache log for hints
For Windows users this is what worked for me:
Obtain your phpinfo() output and copy it here: https://xdebug.org/wizard
It will tell you what is the exact dll you have to download.
Copy that dll into C:\xampp\php\ext, and rename it to php_xdebug.dll
Pay attention at the version of xdebug you have installed. That was the key for me! My version of xdebug was version 3 so I had to...
Update php.ini file to have the following (for xdebug v3):
[XDebug]
zend_extension = xdebug
xdebug.mode=debug
xdebug.client_host=localhost
xdebug.client_port=9000
xdebug.idekey="netbeans-xdebug"
Restart Apache Webserver and Netbeans.
I have now a new MabBook with 10.8 and I am trying to set up all the Apache & MySQL etc.
Apache successfully runs including vhosts.
In my /etc/hosts I have all the local hosts set including 127.0.0.1 localhost etc.
When I try to coennct to one of my local vhost, e.g. alpensonne, I can connect to MySQL without any troubles. If I try to have the MySQL host to be localhost, I get the follwoing error:
Database connection error (2): Could not connect to MySQL.
I know the error (2) means username or password incorrect, but they are fine.
If I connect with
mysql -u root
SELECT password,host FROM user where user='root';
Also I have just done to be double sure:
SET PASSWORD FOR 'root'#'localhost' = '';
Is it possible that localhost uses a different MySQL socket? Maybe it then tries to connect to a different MySQL?
Ok I found the mistake...
The problam was, that I have forgot to change the php.ini file to point to the mysql.default_socket...
My default_socket was set to /var/mysql/mysql.sock
so I just created a symlink to /tmp/mysql.sock and now all works fine! :)
#shadyyx
Thanks for the proposal of MAMP, I know this of course but not such a big fan of MAMP, XAMPP, LAMP etc. for windows user its good so you can use apache instead of IIS, but for Linux, Unix and also Mac user you can use the build in apache server... so no need to use an other third party software. also you are depended then on the php version etc. I like it more to be able to configure it myself.
To elaborate on the answer from #schurtertom...
The problem is that mysql.default_socket setting in PHP.INI defaults to a different location than where MySQL actually puts that file.
Instead of editing the config files, create an alias in the location that PHP is looking that connects to the real mysql.sock by running these two commands (no restart needed):
mkdir /var/mysql
ln -s /tmp/mysql.sock /var/mysql/mysql.sock
With MySQL from MacPorts it works with this path:
mysql.default_socket = /opt/local/var/run/mysql56/mysqld.sock
In case MySQL still does not connected, run:
brew switch openssl 1.0.2s
I spend some hours to set up my IDE to debug PHP with eclipse and xdebug.. Everything is ok except the breakpoint I set on eclipse. If I double-click on a line to add a breakpoint, the debugger want not to stop.. If a add the line xdebug_break() the debugger stops well at the line...
It's maybe a problem with the configuration. Could anyone help me ?
Eclipse: Eclipse PDT 2.2.0 All In
Ones Windows 32 bits
Xdebug: 5.3 VC6
(32 bit)
PHP: PHP Version 5.3.3
PHP.ini
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:/temp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.show_local_vars = 1
If xdebug do not stop in any part of your code, add xdebug_break() to this part of the code.
There seem to be several issues that could be the root of this problem. In my case it was the fact that I thought I needed to set some path mapping.
The settings found under
rightclick-project->properties->PHP Debug
and then
server->edit->path mapping
were wrong.
I had manually added something I though was correct, but Eclipse can do this all by its self it seems. Removing the mapping made it work.
I’ve had a similar problem with Eclipse PDT and Xdebug. The cause was that Eclipse was listening via IPv6 but Xdebug tried to connect via IPv4:
chriki#machine:~$ netstat -an | grep 9000
tcp6 0 0 :::9000 :::* LISTEN
Xdebug doesn’t seem to support IPv6, yet.
After adding the line
-Djava.net.preferIPv4Stack=true
after the -vmargs line in my eclipse.ini file, Eclipse started to listen via IPv4:
chriki#machine:~$ netstat -an | grep 9000
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN
Debugging now works flawlessly.
I have fixed myself the problem.
On my php.ini, I have add the xdebug as an extension instead of a zend_extension.
php.ini
zend_extension=C:\EasyPHP-5.3.3\php\ext\php_xdebug.dll
Note: the path must be the full path instead of a relative path.
The debugger works great. Yummy!
I had the same problem. The solution is to open correct file and add breakpoint in it.
My local server is on my virtual Z: drive (I'm using denwer instead of WAMP). Z drive points to my D:/webserver folder. So I can open my file as 1) Z:/myproject/script.php and as 2) D:/webserver/myproject/script.php
For some reasons debugger stops on breakpoints only in openned Z:/myproject/script.php file.
How to test my solution??? Do next:
Open any php file you want to debug
Add xdebug_break() to any line and save file
Run debug
In my case after debug process has started my phpDesigner IDE open correct file in IDE and stops at xdebug_break() line. So in this new opened file you can add breakpoints and they will work. Use opened file for debug.
Similar problem here when I migrated from Xdebug 2 to 3.
There is a documentation for that but the most important points are:
Xdebug's default debugging port has changed from 9000 to 9003.
To make sure that just Step Debugging is active, instead of:
xdebug.remote_enable=1
xdebug.default_enable=0
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.coverage_enable=0
You now only do:
xdebug.mode=debug
The xdebug.remote_autostart setting has been removed. Instead, set
xdebug.start_with_request=yes
I was having the same problem, PDT would start up the debug session, even breaking on the first line of the script and allowing stepping from there, but it would happily run through any manual breakpoints I had set if I clicked on Resume. After fiddling around with it and reading a bunch of other replies, I fixed it.
I had been trying to setup a Path Map (in the PHP server configuration) as my project path and web server paths were different, but this was not working for some reason so I ended up adding an alias to the apache config to match the location PDT was asking for. However, I had not removed this path map setting. When I removed the path map, breakpoints started to work!
Probably a symptom of something else not working properly ( the path map setting ) but breakpoints and debugging are all working for me now :)
This problem popped for me after moving some of my local project folders around. I could get xdebugger to break at the beginning of the file, but it would skip the rest of my breakpoints.
If you are using Netbeans, check that your Project Url ( Project Properties->Run Configuration ) points to the correct location. With the Project URL pointed to the right folder, breakpoints starting working as expected.
Just to mention the simple solution for me, when my freshly installed and configured xdebug didn't work with PhpStorm: I simply forgot to restart apache after updating the php.ini file.
I had the same problem for days (!) since I realized that the problem was the most trivial one.
Configuration:
(Windows 7 Host)
Ubuntu 12.04 on VirtualBox Machine
LAMP installed manually
Eclipse Indigo + PDT
php5-xdebug
/etc/php5/apache2/php.ini
[XDebug]
zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_output_dir=/tmp
The Debugger did't stop at breakpoints and neither at xdebug_break();
...it was due to the default Apache DocumentRoot folder's /var/www permissions
I changed it to /home/user/Documents/www.
Quick answer: remove all white spaces on the path to your php script.
Context:
There is a bug on PDT plug-in version 3.7.0 which prevents the debugger from stopping at breakpoints.
And it happens when the path to your script contains a white space!
It has been fixed but I guess the target version, which is 4.0.0, has not been released yet.
The comment which saved my day is at https://bugs.eclipse.org/bugs/show_bug.cgi?id=489646#c7 ("Comment 7").
If you are using Eclipse, it may be that the debugger configured for a specific launch (see Debugger tab) is the Zend Debugger, and NOT XDebug. Fix your debug launch and try again. That solved the problem for me.
Unfortunately I cannot post the screenshot. However, in Eclipse, you can go to:
Debug Configurations > PHP Web Application > then select your launch > Debugger Tab > use the Server Debugger drop down to select XDebug > hit the Apply button and retry.
I had the same problem and either one of two things fixed it...
I removed a duplicate zend_extension definition in my PHP.ini
or more likely I just upgraded to the latest xdebug version from here:
http://xdebug.org/download.php
(I was running xdebug that came with XAMPP v1.7.1)
THIS STARTED AGAIN... tried all different versions of xdebug dlls, etc... turned out that what was causing this to not work was having the Expressions window open... so keep it closed when you debug stuff... you can add a watch temporarily and then close the Expressions window before you "step"...
bogus...
1- check xdebug config on php.ini
2- eclipse->project->properties->phpDebug->
Enable project specific setting
phpDebugger->configurattion->port
or
widndow->preference->php->debug->installedDebuggers
3-widndow->preference->php->
Interpreter->version
executables-> path to php-win.exe
point : for each debug lib (xdebug,zend_debugger,...) you can have a default php executable.
4-your application server work on different port with 80 .
widndow->preference->php->
PHP servers
I add the same problem on fedora release 20 Heisenbug, php-ZendFramework2-Debug-2.3.9-1.fc20.noarch, php-pecl-xdebug-2.2.7-1.fc20.i686, and eclipse Version: Mars.1 Release (4.5.1). I used the previous answers, discovered that eclipse use ipv6, I changed as described within eclipse.ini for -Djava.net.preferIPv4Stack=true. Same for xdebug.ini, and still not working, until I discovered that I had 2 xdebug.ini files, one in /etc/php-zts.d/ which is the wrong one, and one in /etc/php.d/ which is the one used by apache. I modified it to include the following setting
; Enable xdebug extension module
zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_mode=req
xdebug.remote_autostart=1
xdebug.idekey=
restarted the network sudo service network restart and now breakpoints are detected and I may debug as expected.
I have fixed this too.
Using zend_extension instead of extension.
zend_extension_ts="C:\xampp\php\ext\php_xdebug.dll"
I'm on windows, eclipse Oxygen. After spending fair amount of time, I discovered that simple delete and recreation of Debug Configuration helped.
I had the same issue using eclipse-php-oxygen
The issue lies on eclipse.
I have installed eclipse-php-luna-SR2-win32 and tested xdebug and it works fine.
Installed:
xampp-win32-7.0.30-0-VC14-installer.exe
Java 8 Update 171
The following are my settings on php.ini:
[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.6.0-7.0-vc14.dll
;zend_extension = C:\xampp\php\ext\php_xdebug-2.5.5-7.0-vc14.dll
;zend_extension = "c:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000
I hope this will help.
Br,
Ali
For me the problem seemed to php 7.2 with Xdebug v2.7.0beta2-dev, notice the beta part. This was installed using puphpet.com. I tried php 7.1 and the problem vanished. Took me hours to find this!
This has been pissing me off for about 3 hours, just worked it out. So before you put a gun to your head, try this. When Eclipse starts, choose a new workspace, and setup your project again!
After I did this my break points got hit again!
My break points were working fine, then all-of-a-sudden they stopped working.
I Tried:
removing all break points
cleaning project
re installing eclipse
NONE of the above worked for me!
BTW I am using window 7.
I hope this information saves someone's life!
BTW: here are the steps you take to setup, centos 7 with xdebug and vmwere, with a window 7 client with eclipse:
download vmwere
downlaod and setup vmwere with: CentOS-7-x86_64-Everything-1511.iso
disable Firewall
systemctl disable firewalld
systemctl stop firewalld
systemctl status firewalld
connect via ftp
ifconfig to find out Ip
ifconfig
eno16777736: flags=4163 mtu 1500
inet 192.168.170.128 netmask 255.255.255.0 broadcast 192.168.170.255
inet6 fe80::20c:29ff:fec4:b8ca prefixlen 64 scopeid 0x20
ether 00:0c:29:c4:b8:ca txqueuelen 1000 (Ethernet)
RX packets 254 bytes 20919 (20.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 95 bytes 10225 (9.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
192.168.170.128 is the ip
setup LAMP
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service
mysql_secure_installation
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
yum -y install php
service httpd restart
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring
php-snmp php-soap curl curl-devel
service httpd restart
yum install phpMyAdmin
on windows open cmd, type ipconfig
find
Ethernet adapter VMware Network Adapter VMnet8:
Connection-specific DNS Suffix . : localdomain
Link-local IPv6 Address . . . . . : fe80::94b8:9e5c:c772:3d47%19
IPv4 Address. . . . . . . . . . . : 192.168.170.1 [ this is the widnows ip to allow ]
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway .
in /etc/httpd/conf.d/phpMyAdmin.conf change:
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
to:
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip 127.0.0.1
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
<IfModule mod_authz_core.c>
# Apache 2.4
<RequireAny>
Require ip [ WINDOWS IP TO ALLOW GOES HERE ]
Require ip ::1
</RequireAny>
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from [ WINDOWS IP TO ALLOW GOES HERE ]
Allow from ::1
</IfModule>
service httpd restart
change $cfg['Servers'][$i]['auth_type'] = 'cookie'; to $cfg['Servers'][$i]
['auth_type'] = 'http';
service httpd restart
/etc/selinux/config change
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=enforcing
SELINUXTYPE= can take one of three two values:
targeted - Targeted processes are protected,
minimum - Modification of targeted policy. Only selected processes are
protected.
mls - Multi Level Security protection.
SELINUXTYPE=targeted
to
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled
SELINUXTYPE= can take one of three two values:
targeted - Targeted processes are protected,
minimum - Modification of targeted policy. Only selected processes are
protected.
mls - Multi Level Security protection.
SELINUXTYPE=targeted
reboot centos
IN WINDOWS POINT BROWSER TO: http://192.168.170.128/phpmyadmin, should be all good
copy website to: /var/www/html/[ WEBSITE NAME ]
chmod -R 777 html
in etc/httpd/ add ( this allows permalinks to work with post name )
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
yum install php-devel ( to allow pipsize )
make php file with: and copy to website root run it and copy the htl into https://xdebug.org/wizard.php then click analysis source button
https://xdebug.org/wizard.php will give Instructions like this: ( follow them )
......
Download xdebug-2.4.1.tgz
Unpack the downloaded file with tar -xvzf xdebug-2.4.1.tgz
Run: cd xdebug-2.4.1
Run: phpize (See the FAQ if you don't have phpize.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib64/php/modules
Edit /etc/php.ini and add the lines
zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host=192.168.170.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
.....
service httpd restart
run file and you should see an XDebug section, if so the
server is ready to go!
Download Eclipse Neon
File > Open projects from file system
Finish ( and wait )
Window Preferences > php > servers > new
Server Tab
Server Name [ what ever you like ]
Base Url [ IP or name of your server ]
Document Root [ Location on your hard drive where all the code is, must be same as what you have on the server]
Debugger Tab
Debugger: Xdebug
port: 9000
Server Mapping tab ( click add)
Path on Server: [the whole path to your website] EG: /var/www/html/website
Path in Workspace [find the project you added with: Open projects from file system]
go to eclipse main window > click drop down arrow beside the bug icon > debug configerations
Server Tab
File: [ this should be the first file in your local project that will be
run when you app opens ]
URL: turn off auto generate : uncheck it
URL first text box: [ The IP or name of your server where you website is running ]
URL second text box: [ If your website is not in the root direcory, the direcory where it is goes here ]
Common Tab
Display in Favorites Menu
Click Debug ( checkbox )
window > prespective > open prespective > php
Put a break point in the php file that gets hit first ( by clicking on the vertial scrollbar on a line of code )
Finally click the debug icon in eclipse, and your break point should get hit ( the line of code with the break point on it will go green )
Open up Centos 7 on Vemware to the world
Change VMeere network setting to bridged
Add a rule to router to port foward any traffic to the vmweare IP that cetnos is running on
Add an inbound rule to the widnows firewall allowing http
PS: I dont have time to check my gammer and speiing, deal with it
I have a strange problem in php MySQL:
php connects with 127.0.0.1 but not with localhost.
How to solve this issue?
Try ping localhost in a command line, it may be resolving to ::1: the IP6 equivalent to 127.0.0.1
To fix it, add (or uncomment) the line:
127.0.0.1 localhost
in C:\WINDOWS\system32\drivers\etc\hosts
localhost must be defined in your hosts file, which it is by default on Windows and most OSs.
Check the following text file and see what's up:
C:\WINDOWS\system32\drivers\etc\hosts
Please note "hosts" is the file, no extension, it's not a folder. This file should be pretty much empty, if you see entries either your AV/spam blocker added a ton of entries that point to 127.0.0.1 or nasty malware has written garbage in there, despite, newer entries are below older ones. Localhost should be the first entry in that file.
For macs, here's the solution:
Connect to MySQL using localhost instead of 127.0.0.1 on a MAC. For a long while now I’ve been connecting to MySQL on my development platform with 127.0.0.1 because for some reason localhost didn’t work. Turns out it’s because 127.0.0.1 uses TCP/IP and localhost uses sockets. The php.ini file points to the wrong place for the mysql.sock so all you have to do is change it, restart apache and voila!
Open php.ini: /private/etc/php.ini
Find the following line: mysql.default_socket = /var/mysql/mysql.sock
Replace with: mysql.default_socket = /tmp/mysql.sock
Restart apache: apachectl restart
Note: Depending on your setup, you may also have to update these lines in your php.ini:
mysqli.default_socket = /tmp/mysql.sock
pdo_mysql.default_socket = /tmp/mysql.sock
Note: If you don’t have a php.ini file, you need to copy the provided default called php.ini.default
sudo cp /private/etc/php.ini.default /private/etc/php.ini
via http://madproject.com/general/connect-to-mysql-using-localhost-instead-of-127-0-0-1-on-a-mac/
Also have a look inside the mysql database which defines the user access privileges. You can define there from which source hosts a given user is allowed to connect. You can consult http://dev.mysql.com/doc/refman/5.1/en/connection-access.html for more details
I remember that being a longstanding and documented feature of Mysql on Windows. Something about the way local sockets work or something.
Try:
IE-->Tools-->Options--> Connection --> LAN Settings Check Bypass Proxy for local addresses
If MySQL connects to 127.0.0.1 it does so via TCP/IP whereas if it connects to localhost it does so via a socket.
Is PHP looking in the right place for mysql.sock? Make sure php.ini and my.conf have matching locations
Is localhost resolving to the IPv6 address, as opposed to the IPv4, and MySQL is not listening on the v4 address?
The solution is make localhost resolve to the v4 address, OR make MySQL listen on the v6 address.
If you not on windows also test if mysql is connecting via socket, locally it normally does.
Force tcp with the mysql client
mysql -usomeone -p --protocol=TCP
vs. socket (default on linux)
mysql -usomeone -p
mysql -usomeone -p --protocol=socket
The latter didn't work for my someone#127.0.0.1