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?
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.
Related
I've been developing a PHP application using the Zend framework for awhile on a Linux-based hosting provider, and it's gone along more or less swimmingly.
The time has come to be able to develop locally on my Mac, so I configured Apache to run PHP, grabbed the source code, and symlinked /Library/WebServer/Documents to the public/ folder in my Zend web app.
That was fine. The controllers were executing and loading the correct scripts, which seemed to parse and render correctly. Except, I wasn't able to connect to my local MySQL database. I realized that I hadn't copied /etc/php.ini.default to /etc/php.ini, so I went ahead and did that. I then updated this line:
pdo_mysql.default_socket=/tmp/mysql.sock
and restarted Apache. Now, suddenly, none of the PHP executes. Instead, the raw PHP is sent back to the browser.
The effect is more or less the same as if I was trying to load a .php file directly with an Apache instance that didn't recognize the .php file extension. Based on what I've experienced, I'm guessing that maybe somewhere in php.ini there is a setting that is causing this to happen (when I rename php.ini and restart Apache, the scripts once again parse and render correctly, but again I can't hit the database) but I'm not sure where to look. Does anyone have any thoughts?
In case anyone is reading this, here's the answer that I finally discovered:
short_open_tag = On
The above needs to be set in php.ini, particularly because all of my controllers, models, helpers, etc were using short tags (e.g. ), as is common with Zend applications.
I am trying to set up a PHP server on my localhost to run with the Eclipse PDT.
I want to be able to view the PHP site I am developing on something like http://localhost/MySite/index.php so that I can Run it straight from Eclipse.
I am using IIS 7.5 (windows 7 home premium) for the PHP server.
So far I have followed these instructions, but have not been able to get it to work:
Install CGI option in Windows Features
Install IIS Manager in Windows Features (so I can run inetmgr.exe)
Download the NTS-version of php and extract the zip to C:/php
Rename php.ini-development to php.ini and set the extension_dir variable
Run inetmgr and create a new website to run PHP applications (I removed the DefaultSite):
Site Name: My Site
Physical Directory C:/dev/MySite
Application Pool: DefaultAppPool
Bindings:
Host:
IP Address: All Unasigned
Port: 80
In inetmgr: Click on handler mappings and add a new Module Mapping:
Request Path: *.php
Module: FastCGIModule
Executable: C:/php/php-cgi.exe
Now I have many problems:
In IIS Manager, when I click Edit Site > Test Settings, there is a yellow exclamation-mark warning: Authorization: Cannot verify access to path (C:/dev/MySite):
The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.
When I try to load any .php file directly from the webroot (C:/dev/MySite) it displays as plain-text in my web browser
When I try to Run my project in Eclipse, it goes to http://localhost/MySite/index.php and there is a 404 Error: Website Not Found
When I go to http://localhost/ in my web browser, I also get a 404 Error.
If you download PHP 5.4.x you will be able to use the built-in web server for all of your development needs.
In your php folder, you would run:
php -S localhost:3030
Now you will be able to browse to http://localhost:3030/index.php
If you were using the Aptana IDE (or anything comparable), you would set this up like so:
Your run configuration would be:
I don't personally use Aptana (I did a few years ago); however, I thought it would be interesting to try this to find out if the integration would be seamless or not. I have to say, I am pretty impressed at how Aptana gets out of your way so you can do just about whatever you want.
Finally, if you are wondering about the "$HOME/local/php/versions" listed in my "Start command", I drive multiple PHP versions with a tool called php-version. Please be aware that this tool targets Linux/Mac users; however, if more people are interested, I may do a windows/powershell port (NOTE: I am the author).
I'm afraid I don't have an answer to you're question, but I wanted to share...
I never was a fan of running PHP on IIS or Apache. So I built a portable, no-install-required copy of nginx that I could move around with me or use on my Windows machines. (Just download the flavors of PHP, Nginx, and MySQL you want and start it). One of the reasons is that most production sites run nginx anyway, so this way I'm closer to what my server actually uses (unless you are on "shared-hosting" which still uses the Apache).
Second, I'm not sure why you need to "run" it from Eclipse. When you write PHP you usually are dealing with a lot of variables to get pages setup. I would say you need to worry more about adding Unit Tests to make sure things work right, and using a browser like Firefox (with firebug) for testing any requests you might be making. Things like AJAX, or dealing with session cookies often require more control than what Eclipse can give you.
Bottom line, I'm not sure why you think you need to do this.
I am strictly a LAMP dev but an ad agency I work with is courting a government agency whose RFP requires that their site be delivered via a Windows server.
What advice do folks have on this? Are there specific pitfalls? It seems like I have heard that file uploads and folder permissions are very different on Windows servers.
Any advice would be greatly appreciated.
IME, IIS can behave very oddly at times.
The permissions model is primarily ACL based - so its certainly possible to design a system which mimics the way Unix works - but (just as with Unix) get the permissions model right - and don't tinker with permissions / ownership in your code.
And of course you'll get yourself tied in knots if you try to move up directory hierarchies and cross over 'drives'.
Add to that a complete absence of the services you might invoke via popen(), and the POSIX tools.
Yes, people keep telling me its a nice place to visit but I wouldn't want to live there.
OTOH, a self-contained set of PHP files will run quite happily there.
PHP on a windows server is definitely trying on your patience. Problems that I've run into are making sure that IIS is configured to use the correct php.ini file, and as you said, writing to files on the server as well as folder permissions.
That being said, if you can get it working correctly, it's not a bad production environment.
I would suggest getting your dev environment as similar as possible to what production will look like. That way you run into as few problems as possible when you deploy.
I can see some pitfalls for using PHP on IIS
Since IIS is multithreaded unlike
linux which is multiprocess. Some
PHP scripts might be unsafe.
Because of this PHP should be installed and
run as a CGI extension. CGI is
slower than IIS's ISAPI and worse
when compared to Apache's mod_php.
Another pitfall I can think of is URL rewriting. IIS, versions below
v7 do not support url rewriting.
Configuration of PHP with IIS is really a pain. But when you do configure it, make sure you use the same configuration, exact mirror images everywhere you are developing because a lot can go wrong with just one glitch.
I want to start learning PHP. I have had a look at the various options available to install the PHP+MySQL+Apache combination. But it all seems too cumbersome and a lot of editing to the CONF files always leads to one problem or the other. So I had a couple of questions to ask:
1) How will something like WAMP help me? If I install WAMP, will that be enough?
2) Isn't there some Eclipse like IDE ( coming from a Java Background ), that allows WAMP to be integrated with it? ( Or is typing on Notepad the only option available )?
Please help me out by explaining things a little elaborately. Thank you so much for your time and patience.
i personally use xampp and netbeans for my local web development. you can actually set up the netbeans project wherever you want, so you can just place all your files in the htdocs folder of xampp (at C:\xampp) and edit the files in the folder directly. This will allow you to immediately see any changes you have made by reloading the web page.
xampp allows you to run apache (with mod_php installed and configured) and mysql on your local machine and even includes a handy panel to let you start and stop them at any time.
netbeans has a lot of tools for easy development and support for frameworks like Zend. You can also use it for many other languages should you wish to expand.
I prefer WAMP because it doesn't try to do anything fancy with configurations... when you install it, you get PHP, Apache, MySQL, and phpMyAdmin with each of their default configurations and extensions loaded. It's the same as installing them separately, only they're all in one convenient directory, and you get the handy tray icon to restart services and enable/disable extensions.
As for an IDE, I use Eclipse PHP Development Tools (PDT), but I've heard good things about Netbeans too. Eclipse can do everything Scott described Netbeans being able to do as well. You also might want to look into Aptana which was branched from Eclipse PDT but is now maintained by a different team.
you can go ahead and install xampp from apachefriends, it comes with an apache web server, mysql database, phpmyadmin and a control panel for both servers, and installs fairly quick and with the default settings you will be pretty much set. Not sure what integration you'd want between the editor and the webserver though. if you mean code folding, autocomplete and all that stuff, eclipse has a php-friendly version, and so does netbeans (these 2 are the most popular choices as far as i've seen)
Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.
Have you posted the issue on the Xinc bug tracker? Xinc itself should run fine as it runs both as a daemon and as a web app. As you alluded to, the issue may be that the daemon is not running in a chroot'ed environment where as the web interface is, leading to either side not grabbing the files.
#dragonmantank
In Xinc's case, I hope you used PEAR to install it.
pear list-files xinc/Xinc
This should do it, and show you where your Xinc install put its files. So even though Xinc is "just" one big PHP script, it's still spread out into rc scripts and all those other things which are necessary to make an application run. I'm sure you don't need to add all paths listed there, but probably some in order to make it run.
Aside from Xinc itself, I think it also needs phpUnit and a bunch of other PEAR libs to run, so what I'd propose is this:
pear config-get php_dir
And then you need to add that path (like Henrik suggested) to the chroot environment.
Having never used xinc myself, I can only hint as to how I usually get to chrooting apps.
First step would be to gather information on everything the app needs to run; this I usually accomplish by running systrace(1) and ldd(1) to find out what is needed to run the software.
Go through the output of
systrace -A -d. <app>
ldd <app>
and make sure that everything the app touches and needs (quite a lot of apps touch stuff it doesn't actually need) is available in the chroot environment. You might need to tweak configs and environment variables a bit. Also, if there is an option to have the app log to syslog, I usually do that and create a syslog socket (see the -a option of syslogd(8)) in order to decrease the places the app needs write access to.
What I just described is a generic way to make just about any program run in a chroot environment (however, if you need to import half the userland and some suid commands, you might want to just not do chroot :). For apps running under Apache (I'm sure you're aware that the OpenBSD httpd(8) is slightly different) you have the option (once the program has started; any dynamic libraries still needs to be present in the jail) of using apache to access the files, allowing the use of httpd.conf to import resources in the chroot environment without actually copying them.
Also useful (if slightly outdated) is this link, outlining some gotchas in chrooted PHP on OpenBSD.
First step would be to gather information on everything the app needs to run; this I usually accomplish by running systrace(1) and ldd(1) to find out what is needed to run the software.
I'll give this a try. The big issue I've found with xinc is that while it is a PHP application, it wants to know application installation paths (yet it still spreads stuff into other folders) and runs some PHP scripts in daemon mode (those scripts being the hardest to get running). So, for example, I told it to install to /var/www/xinc and then made a symlink of
/var/www/var/www/xinc -> /var/www/xinc
and it partially worked. I got the GUI to come up bit it refused to recognize any projects that I had set up. I think the biggest problem is that part of it is running a chroot and the other half is running outside.
If all else fails I'm going to just have to build something as we program inside chrooted environments since our production is chrooted. We've run into issues where we code outside of a chroot and then have to back track to find what we need to make it work inside a chroot.