How to get Visual Studio Development Server to work with PHP? - php

I'm a .NET specialist working with a PHP/Flash programmer to deliver an app via IIS. After jumping through 17 hoops of fire and defeating a gargoyle in a gruesome battle to the death, I managed to get my IIS 7.5 server to cooperate with PHP, and now if you browse to my public web site, you can see the Flash objects happily doing their behind-the-scenes stuff with PHP, whatever that may be.
But... when I'm debugging my app using the VS Development Server, that still apparently doesn't know how to cope with PHP: I'm getting the same HTTP 405 (Method Not Allowed) errors that I was getting on IIS before aforementioned gargoyle breathed its last ("The HTTP verb POST used to access path '/php/blah.php' is not allowed.").
So, what do you have to do to get the VS Dev Server to play nice with PHP?

My PHP Debugging Setup
I'm a .NET developer who has been swimming in the PHP pool for the past few months.
Spoiled by the VS.NET IDE, debugger, and strongly typed platforms, I was determined to create a PHP development environment that closely resembles my .NET debugging experience.
NOTE: It may be easy to setup PHP debugging in IIS for new PHP applications. However, the steps listed below break down some very involved steps as I found required to debug in WordPress and Joomla. Only follow these steps if you aren't having any luck with getting debugging to work.
Disclaimer:
The full set of steps to complete this setup are quite involved. I'm throwing this together ad hoc in hopes it will help others in need of setting up a professional development environment with little background in Linux based systems.
These steps are not guaranteed to work and may be very sensitive to environment settings. I spent a lot of time going through the effort of trial and error until I got this working.
Along the way, I have to give credit to a few good online resources you should review to get started. These do not address debugging or development setup. I'll provide details below.
Step by Step Guide: Installing XAMPP and WordPress on Windows
Since I'm new to posting here, I can't add more than one link. Just Google the following references:
- Google: sixrevisions tutorials web-development-tutorials using-xampp-for-local-wordpress-theme-development
Securing Your XAMPP Installation
Google: robsnotebook xampp-builtin-security
DEVELOPMENT SETUP
WAMP Stack vs IIS for PHP:
First, I did not use IIS to host my PHP application. I wanted to keep these web servers separate and use one of the available WAMP Stacks to develop against. This allowed me to manage and study configuration settings that would be used on Apache and Linux. If I was deploying the PHP App to a Windows host, I would have chosen an IIS setup. Again, this was a choice based on creating similar configured environments with a Linux host.
What is WAMP Stack?
For those unfamiliar, a WAMP Stack stands for a distribution package of Apache, MySQL, and PHP running on Windows. Other flavors include LAMP (for Linux), MAMP (for MAC), and others. There are several flavors within the community that provides WAMP Stacks to work with. I originally found BitNami interesting to work with. However, I was not happy with the Control Panel used to manage the different services within the Stack.
Selecting XAMPP for Windows
At the end of the day, I went with a package called XAMPP (Cross Platform Apache, MySQL, PHP, and PERL). The second P in XAMPP provides PERL support that is lacking in the other WAMP Stacks (WAMPServer, bitnami, and a few others). I also like XAMPP because it has what appears to be a more active community and the stack has been very stable for me. Additional standout features of XAMPP to consider is support for hosting an FTP Server, apache based mail server. The option to run MySQL and Apachi as services or local running app is easily toggled with a click of a button.
Setting Up XAMPP for Development
Setup of XAMPP is straight forward. My experience is with the previous release 1.7.3. They just released 1.7.4. Go to:
Google: apachefriends xampp-windows
and scroll down the page till you see the install links. If you want to work with a release that has matured with some time, you can still find 1.7.3 at the following link:
Build Link: www (dot) apachefriends (dot) org (/) download (php) ?xampp-win32-1.7.3.exe
Installing XDebug for PHP Debugging
This applies to installing PHP on WAMP with Apache or on IIS. Selecting the correct version of this dll isn't straight forward.
First, go to:
Google: xdebug org download (php)
and review the various versions available.
The versions are not very intuitive to parse. Follow this guide to understand it:
Breakdown of XDebug Name: [php_xdebug-2.1.0-5.3-vc6.dll]
- XDebug version 2.1.0
- Compatible with PHP 5.3
- VC6: Use for Apache ver 1 or 2
- VC6 indicates compiled with legacy Visual Studio 6 Compiler
- VC9: Use for IIS
- VC9 indicates compiled with Visual Studio 2008.
- NTS (not listed in the name above) indicates Non Thread Safe.
- The version listed is thread safe.
PHP.ini Config Setting
NOTE: Since I've not set this up on IIS, I'm not sure what the specific settings are to apply. However, this is document throughout the web.
For WAMP/XAMPP:
Locate \php\php.ini file.
Comment out line by adding semi colon to start of line.
;zend_extension = "php\ext\php_xdebug.dll"
Locate [XDebug] Section
Use settings similarly listed below and set to your path:
[XDebug]
;Common Settings
zend_extension = "P:[Fully Qualified Path]\xampp\php\ext\php_xdebug-2.1.0-5.3-vc6.dll"
xdebug.profiler_enable = 1;
xdebug.profiler_output_dir = "P:[Fully Qualified Path]\xampp\tmp"
xdebug.profiler_output_name = "xdebug_profile.%p";
xdebug.remote_enable = 1;
xdebug.remote_host = "127.0.0.1";
xdebug.remote_port = 9000;
;Make sure your IDE setup on port 9000. Some will default to 7870.
xdebug.trace_output_dir = "P:[Fully Qualified Path]\xampp\tmp";
;************
;Needed for IDE Support
;************
xdebug.idekey = "vsphp";
;This value can be arbitrary or may require something specific for your IDE.
xdebug.remote_autostart = 1;
xdebug.var_display_max_depth = 5;
Debugging with IDE
I use 2 IDEs to develop in PHP:
phpDesigner7
Google: mpsoftware phpDesigner
VS.PHP (a PHP plugin for VS.NET 2010).
Google: jcxsoftware vsphp
I want to love VS.PHP in VS.NET 2010, however, it's not the greatest experience in step through debugging. phpDesigner7 has been much better for debugging and access to local variables, intellisense, and using running eval commands during debugging. VS.PHP is so close to being great, but you will be frustrated if you have little patience. I still prefer it as my development editor of choice, even for PHP.
Regardless of IDE, most IDEs provide internal debugging support without any of the extra steps I listed above. However, these applications will launch the php app in a private webserver using IDE specific php.ini settings.
I'm doing a lot of custom integration with WordPress, Joomla, and .NET applications. Therefore, I need the debugger to use the php.ini settings for my various platforms. For me to debug these platforms, I configure my IDEs to essentially run in remote debug mode. The IDE and web server coordinate run time execution with the help of XDebug acting as a broker and providing the necessary debugging symbols to the IDE debugger.
Configuring IDE for Debugging
Final step is to configure your IDE so the debugger can connect to the web server.
The 3 settings to look for are as follows:
PHP-CGI: P:[Fully Qualified Path]\xampp\php\php-cgi.exe
PHP.INI: P:[Fully Qualified Path]\xampp\php\php.ini
Listen Port: 9000
Different IDEs may label these settings differently and require additional settings. These should be the most important ones to look for.
NOTE: Use [php\php-cgi.exe], not [php\php.exe] for debugging. The php-cgi.exe is required to run php.exe on windows.
I hope this gets you started with attaching your IDE to the web server, setting breakpoints, and doing a lot with line by line debugging.

You will not be able to make Visual Studio Development Server work for PHP. However you can easily use IIS Express (http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx) which will not only give you PHP, but also install WinCache, URL Rewrite and other features that are super important for PHP development.
Also, note that other platforms like Classic ASP are supported as well, where in Cassini they are not.

One option is to not run cassini and instead just get IIS installed on your dev box and run everything through there.

Related

How to launch and debug php using VS Code?

I'm new to VS Code and the php world. My experience is more with heavyweight IDE such as Visual Studio. However, I have a need to setup a php environment on my dev machine and am having some trouble getting it to work properly.
My environment is a Win 10 dev machine. I am using VS Code and php ver 5.5. I have properly installed the xdebug extension and verified it is properly installed. I have also installed the php-debug extension in VS Code.
The challenge I'm having and have been unable to find any useful information through google is launching the php website from within VS Code and then being able to debug it.
A few things I have tried, but haven't worked.
I installed the iis-express extension to VS Code which allows for running any folder through iis express. https://marketplace.visualstudio.com/items?itemName=warren-buckley.iis-express
This works, but the website doesn't display properly. IIS returns an error message saying the site is not properly configured. It's apparently missing a mapping or something along those lines.
I followed this blog. http://blog.denouter.net/2015/05/run-php-from-visual-studio-code.html and am able to run the website using the built in php web server.
Installed webmatrix and let the windows platform installer correctly install and wire up iis express to work with php. The same folder works fine when running from webmatrix.
Installed the php-debug extension to VS Code. https://github.com/felixfbecker/vscode-php-debug
Here is what I think I'm missing. I believe I need to launch the website from within VS Code for the debugging to work. I can't figure out how to "launch" the php website from within VS Code. The php-debug extension from VS Code only supports launch. It doesn't support "attach" mode. I suspect this is why when I run the website outside VS Code, the debugger doesn't work. Let me be clear, the debugger is working when I hit F5, it just doesn't ever stop on any breakpoints.
To summarize: How can I launch and debug my php website from within VS Code? I'm looking for a detailed step by step guide.
Thank you
I am the author of vscode-php-debug. You do not need to "launch the website" from inside VS Code. When you start the "Listen for XDebug" configuration from the debug section, VS Code (or rather, my debug adapter) will listen on port 9000 for XDebug. You need to run a web server like Apache, IIS or nginx locally on your PC and configure it to serve PHP files - this has nothing to do with VS Code. Then simply open a web browser and navigate to localhost and XDebug will connect to the debugger, stopping on breakpoints.
The two necessary settings in php.ini are:
xdebug.mode = debug
xdebug.start_with_request = yes
(Do not forget to add the subtitle [XDebug] before the settings.

How to set up remote debugging with phpstorm and Xdebug

I've seen other questions/answer about this topic but none of them seem to have the same issue I have, so here we go:
What I'm trying
I'm using phpStorm 8 to develop PHP websites (CakePHP 2.5.1 in this specific case). I have a copy of the website on my computer, make whatever changes there and upload the new version to the production server via the integrated FTP tool. So far all pretty simple, no issues at all.
Now I would like to start using Xdebug to debug the websites using the production server (PHP 5.3.28), so I'm trying to set up remote debugging with phpStorm and Xdebug.
What I have done so far
I have installed Xdebug 2.1.3 on the production server, and it seems to be working. To test that I've done whats recommended in this other SO question, and all those things work.
This is how the config in php.ini looks like:
zend_extension="/usr/local/src/xdebug-2.1.0/modules/xdebug.so"
xdebug.profiler_enable='0'
xdebug.profiler_enable_trigger='1'
xdebug.profiler_output_dir='/home/username/debug'
xdebug.remote_enable='1'
xdebug.remote_connect_back ='1'
I'm not setting the remote_port variable because I'm fine with the default port (9000). Also, I'm not setting the remote_host IP because I'm using the remote_connect_back option to allow multiple IPs, as explained here.
I've also tried 2 different approaches to set all this up:
I followed this Zero Configuration tutorial, but at step 7 I never get the Incoming Connection dialog.
I also followed this different tutorial but in the Integrating XDebug with PhpStorm step I don't have the choose XDebug from the Debugger drop-down list option on step 3
What I need
If someone could help me figure out what I'm missing or doing wrong that would be great!
I would have added this to the comments, but don't have the needed rep.
Have you set the preferences correctly in your project? Were you able to configure and validate your deployment server (under Deployment)?
After that, set up the server under PHP > Server and validate it as well.
Don't forget to check the firewall on your host.
Make sure that you can get XDebug working without PHPStorm, then circle back around and integrate it.
These are the php.ini settings, other than the driver path, that I am using for my CLI project:
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_autostart = 1
xdebug.remote_host = 192.168.100.1
Most importantly, listen to LazyOne. Specify your remote host. And don't run debuggers on your production gear. Spend some time learning about Virtual Machines. My recommendation is to check out VirtualBox, Vagrant, and SaltStack. Used together, these tools will allow you to debug your code in an environment that is as close to production as possible without adding the burdens and risks involved with your debugging tools.

Any working php debugger, PDT? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Honestly, I am tired of searching and trying various php debuggers and IDEs from netbeans to jetbrains PHP storm, Eclipse indigo, WAMP, (old zend server community edition) etc!
I need a working set of IEDs and debuggers so I can start developing my work!( I by the way want to develop php scripts in Windows)
Problems:
php storm: weird IDE]
PHP Tools for Visual Studio: it says it is free, but you can try it for free for 30 days
PDT Eclipse: too old, no updates, broken links. Working with Zend itself is creepy
Netbeans 7.3, still not easy to work with. So many settings Xdebug not working
I need something like PHP development tools for Eclipse Juno, any suggestions?
What combinations of IDE(netbeans, phpstorm, Eclipse, Visual stodio) + (Zned server, XDebug) do you guys use? I am really tired of this product not being compatible with one another.
I would really give PhpStorm another try. True, it takes a bit of time to get used to, but it offers a lot of features that are hard to find in other IDEs
Regarding debugging and testing, read these walk-throughs on debugging:
http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
And unit testing:
http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm
Simple Texteditor
Apart from a proper IDE, I always have a 'regular' text editor 'on the side', for example to have a quick 'scratch' file to write down some notes, or to make minor changes in a file without having to open your entire project.
There are many nice editors, Sublime Text, NotePad++ and UltraEdit are some examples.
Test and development environment
Although using WAMP/XAMP is convenient to set up, it is not the best environment to test your project. Most PHP websites will be hosted on a Linux/Using environment, which is quite different from a Windows environment in many ways, some are:
Linux/Unix file systems are Case Sensitive, whereas Windows is not
Linux/Unix uses a slash / as directory separator, Windows uses backslashes \
Some parts of PHP rely on functionality provided by the operating system. Therefore PHP will produce different results on Windows than on Linux/Unix
Linux/Unix uses a different permission system
If you develop and test your websites on WAMP you will encounter unwelcome surprises when you try to deploy the website on the actual hosting environment. Some problems may not even present themselves instantly, which will even be worse (customer calling in the middle of your Holiday telling you that the 'flush cache' admin-panel flushed not only the cache, but also all uploaded content)
So, in order to properly develop and test your website, your development environment should match the targeted hosting environment as close as possible
Inform with your hosting provider what their environment looks like; What Linux distribution are they using? (CentOS? Ubuntu?) What versions of PHP, Apache, MySQL?
Set up your test environment according to this. Either by setting up a development server and installing Linux on that, or running a Virtual Machine on your workstation, for example VMWare or Parallels Desktop (a virtual machine may save you some time, because many pre-installed, ready to use LAMP disk-images exist)
Client side testing
Preferably, make sure you have some computers or virtual machines with a clean install of your targeted audience (Windows XP, Vista? etc) sometimes a clean install is missing plugins/functionality that you assumed are present, causing problems (no Adobe Reader installed? No Flash? Old version of Windows Media Player?)
If your targeted audience are business users, be sure to test your website in the actual environment. Think of pitfalls like Caching Proxy Servers, Firewalls, multiple IP-addresses, disabled JavaScript and Thin Clients (using Remote Desktop). Sometimes those environments are still using Internet Explorer 7 (even 6) because of company policy.
Dreamweaver is by far the best php writting tool, the color code is amazing and the auto complete features are irreplaceable. The only other program i have seen come close in the field of auto complete is zend and that lagged like no other. plus it has built in ftp AND it makes it pretty easy to move on to javascript (IMO)
As far as server software i personally favorite WAMP, but everyone will have their own preference
you can find dreamweaver(trial) here
Wampp is here (pretty sweet webpage):
For PHP, I'd use Notepad++ all the way due to dynamic typing instead of static.
Notepad++ is quite light-weight and won't be in your way.
What sort of debugging do you need? Heavy unit testing and profiling or just print_r type of debugging? Have you tried http://www.firephp.org/ ? It's an extension to Firebug that works really well with AJAX.
There is no Eclipse juno PDT . The latest one is for indigo and that one crashes from time to time.
I use Dreamweaver and Xampp, and occasionally Notepad+++ and Xampp.
As stated in the thread, Dreamweaver has a great color code system and is very user friendly. I suggest it.
xampp
Notepad
I suggest use of Nusphere php ide , its too great for php, it has auto complete features and in built server and you can debug run time, you can also set browser foo debugging your code , its true php debugger, i am using this debugger since last 3years ,its amazing and it has inbuilt ftp feature so you can also debug your ftp file.
Here is link Nusphere

Optimal setup for OSX PHP development environment: MAMP + Eclipse + Subclipse + XDebug? Other?

I'm in the process of switching over to developing on a Mac (woohoo, new Macbook Air) after years of Windows. My previous PHP development setup was:
WAMP
NotePad++
XDebug
TortoiseSVN and WinMerge (linked to an Unfuddle svn account)
I've just installed MAMP Pro (evaluation copy of Pro), Eclipse for PHP Developers (Version: Helios Service Release 2, Build id: 20110218-0911), and Subclipse. I'm trying to get over the "new to Mac" hump at the same time as switching dev tools. Which is making me question my setup eleventy billion times more than usual. I've read lots of StackOverflow questions and answers, googled the heck out of dev environment tutorials. What I really want to ask is "PLZ tell me what to do to get a good dev setup on my pretty new Mac!" but since that's probably not a very well-formed question, I'll try to narrow it down some. (But if you get bored reading this question, and just want to point me to a good book or tutorial, FEEL FREE!)
MAMP: OK, I think I'm fine on this one, right? It's pretty much the defacto standard, if I don't want to hammer everything together myself from what came pre-installed on my mac. I'm probably fine with dropping $60 to get MAMP Pro, as developers I know have told me the long-term convenience is worth it.
IDE: I used Eclipse for several years... but for Java development in a Windows environment. Part of me is happy to get back to a full IDE after a few years of PHP in Notepad++. But do I want Eclipse for PHP? EclipsePDT? Something else? I picked the version I have based on several StackOverflow answers mentioning that EclipsePDT didn't necessarily play well with Mac.
SVN: I took the StackOverflow hive mind advice to install Sublipse for the eclipse integrated SVN plugin. Yay, it looks like it's working, or at least I can browse my repository.
Debugging: Zend Debug comes with MAMP, right? I've never used it, but I was only semi-happy with XDebug + Notepad++ on my Windows box, as it kept locking up and requiring a Notepad++ restart multiple times a day. Will I love Zend more? Should I stick to XDebug? (Or, wait, does Zend only work with Eclipse PDT?)
Now for the actual setup questions. Given that I've got existing Unfuddle SVN repositories, what's the best way to set up my dev environment? Put the source code into the MAMP htdocs directory, and point the eclipse workspace there? (recommended by many SO answers, IIUC) Vice versa, with code into the default eclipse workspace, and point MAMP to it? A separate Projects/myProject1 directory, pointing both MAMP and Eclipse there? I'm concerned that any of these options will work for the initial setup, but that I'll get deep into the work and discover that my debugger won't work for one configuration or another, or... I dunno, something I haven't thought of yet will cause a problem I could have avoided, if only I'd known.
OSX (also the client version) already includes everything you need to develop with PHP! Oh, and it's all 64 bit :) (on Snow Leopard and Lion)
Apache 2 is included by default and can be enabled from System Preferences -> Sharing (its name is "Web Sharing", or something similar: I'm sorry but I use OSX in another language!).
PHP is installed by default too. You just need to enable it in /etc/apache2/httpd.conf: uncomment this line:
LoadModule php5_module libexec/apache2/libphp5.so
MySQL can be installed from binary packages, downloaded from: http://www.mysql.com/downloads/
The only things you need to change in the php.ini file (/etc/php.ini) are:
pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
You need to manually set the socket location for MySQL or it won't work with PHP.
Also, remember to set a value in date.timezone.
SVN and Git are installed automatically when you install the developer tools for Lion, which can be downloaded freely from http://developer.apple.com/mac (a free registration is required).
If you need Mercurial or if you aren't on Lion (so you don't have XCode 4), download the developer tools, then an application named macports, which provides ports for thousands common UNIX tools: http://www.macports.org/ . Once MacPorts is installed, you can install the required packages with a simple command:
sudo port install subversion
sudo port install git
sudo port install mercurial
I don't use any graphical tool for these SCM, so I can't really suggest you. I prefer the old, plain command line!
Developer Tools (the package with XCode) is required also if you want to use pecl to install custom extensions (the default distribution of PHP Apple ships doesn't contain some extensions like mcrypt, gettext and intl, just to name the three most important).
Speaking about editors... The one I really prefer and love is Coda. It's not free, but it's perfect if you want to develop in PHP: http://panic.com/coda/ .
It's also integrated with SVN (but we use Mercurial so I never used that option!).
For (S)FTP, I recommend you Cyberduck, which is free (open source): http://cyberduck.ch/ . Another really good client should be Transmit, but it's not fee (it's from Panic, the same company that produces Coda): I've never tried it (I'm really happy with Cyberduck!), but I heard thousands of good opinions about it.

Is there a true all-in-one solution for PHP Development?

I'm looking for a "SINGLE INSTALLER" solution for PHP Development.
Is there anything out there which will give me a nice IDE, Web Server, Debugger, Database, etc, on a single install image (*.msi or *.exe)?
This of course would be completely opposite of Eclipse PDT, which requires you to search and locate a bunch of additional components which never quite work together.
I think you should go for a separate install for server (web, database) and one for development (IDE, debug) -> Zend or PHPed ?
I think the question is: Does there need to be a true all-in-one solution? I think not.
I agree it's bothersome to have to put dozens of pieces together, but I find a combination of XAMPP, the IDE of my choice, and a few additional bells and whistles (like Polystyle for source code formatting) totally flexible, and not too much work to install.
I don't know if you'll find all of what you're looking for in one package for Windows, but you can get it narrowed down to about two...
XAMPP for Windows comes with: Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.
Then you just need an editor with a debugger, which there are many choices, mostly non-free, such as NuSphere's PhpEd - or free - such as Eclipse PDT or gVim+XDebug+DBGp client.
True one-in-all - not yet. Maybe someone reading this will upload a version.
My tip would be:
XAMPP and Netbeans (The PHP bundle).
2 clicks to install.
3 clicks if you don't have java installed already.
Netbeans is a nice IDE for PHP, too. I use it all the time and I'm much more satisfied with than with Eclipse PDT. It comes in one neat bundle, that you can just install and use right away.
Just download the PHP bundle here
As for a web server, I can recommend XAMPP or Zend Server. They are both easy to install and do a good job. XAMPP has MySQL on board while Zend Server has some really cool optimization features for great performance.
Should it be a requirement that your development environment is easy to install? You're a developer so, you should be able to install and configure a set of (more powerful) tools that suit your specific needs.
You'll only install your bundled IDE once (every so often) so that feature no longer is of benefit when you're developing your projects. It's more likely to become a hindrance as you struggle to configure your environment.
Take a look at Komodo IDE also.
If you're on windows you can get a WAMP package for web,php,database. For IDE I do like Zend Studio 5.5. Not their latest interation based off of PDT. 5.5 has a nice debugger and a built-in web browser that you can view output. The interface is pretty fast, running your code through the debugger/browser is slower than on a real webserver, but ofcourse you get the nice perks of breaking,inspecting your code. The only drawback is that Zend Studio 5.5 is not supported anymore and the highest PHP version that works with it is 5.2.13.
Currently though I have a Virtualbox Ubuntu Server image that mirrors my production enviroment, except it has Samba installed so I can easily copy files back and forth.

Categories