I am trying to upgrade my programming skillset, and learn PHP & MySQL. The software I want to make to cut my teeth is for giving practice quizzes that randomly generate tests that are a subset of a larger question database. This seems like the appropriate language to be learning at this time, given my project goals and existing skillset; I am already familiar with HTML and SQL, so a lot of what I need to know is the PHP angle, which isn’t that hard either as I am familiar with C. Looks like a nice language with a lot of flexibility.
I am currently most of the way through PHP & MySQL for Dummies, which I picked up to get a good concise overview to determine if the language was appropriate for my project and career goals. I have not been disappointed! Kudos to Janet Valade! Anyway, I am itching to start in on my project and I have run into a question that I am sure some fellow doper can answer.
Valade’s book seems to indicate that you need to have a hosted server with a valid internet address up and running to develop, but I was perusing another book, Beginning PHP and MySQL: From Novice to Professional in my local Barnes&Noble (which seems to be a also be a decent book, btw), and in the section about choosing a host, it stated that there was no reason to have a host until the website was ready to go live. This implied that one could develop without a web server, but did not elaborate.
So, what is the method for developing on my local system without an active domain name? I am willing to set up Apache or whatever. I hoping to develop on a laptop that dual boots into Ubuntu and Vista for this purpose, if that makes a difference. I am given to understand that this stuff runs better on Linux.
Bonus Question for when I am finally ready, recommend a good, cheap hosting service for a page that will probably not need a huge amount of bandwidth. , most of the data would be just PHP/HTML with ASCII or unicode without any more graphics than are needed to make the page professional looking and understandable.
Perhaps as my second project, I could make that Amazon link widget for the SDMB. Could have used it twice right here in this post!
So, as long as I have you on the line, what do you think of the second book I mentioned. It seemed to give a good overview of a lot of xtra goodies? Or is there one you would recommend to get me down to the nitty gritty?
If you set up a web server such as Apache on the local system, you can use http://localhost or http://127.0.0.1, and treat it just like any other HTTP server. Or if you want to use a real-world DNS-style URL you could put an entry in your local hosts file like
(in Windows, that file is typically at \windows\system32\drivers\etc\hosts)
I’ve set up Apache on Windows and it’s pretty much the same as on Unix-style systems. Same config file arrangements etc. I guess Windows development may be slightly behind *nix.
Does that mean I can develop with confidence in Vista then move the code over to linux? Because I am about to start a thread, perhaps in the pit, about how after all the propaganda that I have heard about how linux runs good on lesser hardware, and Vista is a big old hadware hog, Vista runs much better on my HP laptop with centrino duo 1.8 with 2 Gb than Ubuntu does.
I don’t have a problem with using linux, and want to learn it, but the fact is, for instance, I like to open multiple tabs and windows in my browsers. Ubuntu slows to a crawl when you open up a few sites under Firefox, but Vista just keeps on humming. Seems to handle virtual memory better, or something. Anyway, that should be another post.
And to Valade’s credit, she never pretended for her book to show you all the ins and outs, and had a limited space to get in the key concepts, but this does seem like a bad omission. It would only have taken a paragraph, as it did in this thread! I blame the “dummies” credo: *"we will teach you to do A, B and C, and it sounds impressive on the back cover, and we might even give you some idea of why you are there, but we are primer, you dummy, if you want to know what you are doing, buy a ***real **book!"
And if that info is in the book somewhere, I didn’t see it, and if so, apologies to Valade. Perhaps it is in an appendix about setup.
I haven’t read that book, but for most things I like the books published by O’Reilly. I’ve heard good things about Learning PHP & MySQL, though I haven’t read it. (I don’t work much with PHP.) Generally, I find a good tutorial to be sufficient to get started, then start referring to the manual for the gory details. Both PHP and MySQL have excellent reference manuals on their respective websites.
In general, yes, but beware of hardcoding platform-specific things like pathnames. Most programming languages have ways to do file handling and such in a platform-independent manner (it’s usually a little extra work). I don’t know what the right way to do it in PHP is, though.
Optionally, you can install IIS. Your version of Windows might or might not include it, but if it does you install it by going to the Control Panel in Windows, then bringing up the Add/Remove programs thing (AKA “Programs and Features” in Vista), select Components on the left (AKA “Turn Windows featuers on or off” in Vista) and then find Internet Information Services (IIS) and check the box. Press Okay and it should ask you to insert your Windows installation CD. Do that and press Next and you’ll have a running server on localhost.
IIS will create a folder at C:\inetpub\wwwroot. All the files underneath there appear at http://localhost.
You’ll still need to install PHP and MySQL separately, but at least one step would be done.
Well, remember that you’re not dealing with compiling binaries for a target platform. PHP is compiled on-the-fly to Zend bytecode and anything written in PHP will run anywhere there’s a PHP interpreter.
Most of the PHP addons, like the MySQL API, are open-source and so there are binary versions available for most platforms already.
You’ll only need to deal with higher level runtime errors like the aforementioned filesystem differences.
You might find XAMPP useful. It’s a webserver designed to be an “easy to install distribution for developers to get into the world of Apache”. It includes Apache, MySQL, PHP, and mod_perl, as well as other features.
I’ve found it very easy to set up and use. On Windows (I’ve not tried other versions), once installed you just need to click a start button for each component (apache, MySQL, etc), to get it going.
I second the XAMPP recommendation. Also, I’ve moved PHP code between Windows and Linux for years without issue. The only occasional discrepancies I see are in the behavior of certain PHP date functions on Macs. That shouldn’t happen to you.
I used WAMP way back when, when I was just getting into server admin stuff on a very informal basis. It works great, and you’re up and running quickly, but Lobsang’s right, you don’t get to learn much about setting up the actual server.
As far as I know, WAMP also isn’t geared for production use - perhaps because security updates are not applied automatically… meaning any new vulnerabilities, you won’t be protected from unless you reinstall WAMP.
But since this is a server serving locally, WAMP works great.
You might want to grab your oldest junkiest PC and turn it into a Ubuntu server, on your LAN, just for this purpose. It’s very easy to set up and you will learn most of what you will need to know to work on a hosted Linux server.
You can get a simple server set up in about an hour. In your case, you will probably want to check “LAMP Server” (Linux Apache MySQL Php) on the “Software selection” screen (page 16 of my document).