SimpleshoPHP is an example of "LAMP" software -- Linux, Apache, MySQL, PHP (or Perl). These packages are all free software and work extremely well together. You use MySQL and PHP to build the application, Apache to serve it, and Linux to run the computer than hosts it.
I've seen guides to Java and Perl that start out trying to tell me how to use a text editor. Booo-ring. In order to make SimpleshoPHP work, you need to know a little bit about a lot of stuff. I want to make this accessible even to people who have never coded an HTML page before, so I'm going to try to dot every 'i' and cross every 't' -- but I'm also going to try to set it up so you can easily skip any of the parts that are old news to you. If you've never built an application before, you can still use this one. If you've never seen a computer before, well, that's a little harder; but how are you reading this page? :-)
Unix is an "operating system." You tell your computer WHAT you want to do; an operating system tells a computer HOW to do it -- you say "save this document file," the OS figures out where your disk is and whether there is enough free space. You say "run my email program;" the OS finds it, loads it into memory, and hooks it up to your network card. Most of the big computers on the Internet are operated using Unix, and the ones that aren't should be.
Linus Torvalds wanted a copy of Unix he could run on his personal computer. He was a poor grad student and couldn't afford to buy the expensive commercial version, so he -- and a few thousand people he met over the Internet -- wrote one from scratch. That's Linux: Linus's Unix.
Here's an introduction to Unix:Unix 101. If you know how to save files and run programs, you know enough about Unix for our purposes.
If you write a simple web page and save it to your computer's disk, you can open it in your web browser and see what it will look like on the Web. That does not require a "web server" because the simple HTML markup is the same whether you get it from a server or from your own disk. But we're going to do something a bit more sophisticated with dynamic content, content that changes depending on how we ask for it. Dynamic content has to be interpreted by a web server program, not just read off the disk as a file.
Apache is the world's most successful web server program. Installing it is a bit beyond the scope of what we want to present here, but assuming you either have a PC at home where you can install Linux, or you have a web page somewhere else, we will offer some tips.
We'll cover the MySQL and PHP pieces below.
If you have only used a "visual editor" like Homesite to create HTML, you've missed a really cool experience: The discovery that making HTML from scratch is easy. Everything on this page was done using a plain text editor.
You should be comforatable writing short, static HTML pages. Here's a primer: HTML 101.
Pretty neat, huh? You put some tags into a plain text file, as simple as a letter to Mom from camp, and HTML turns it into a pretty web page. Want to add a picture, just insert a tag that points to a picture file. What's next? We need some way to let the computer find and insert stuff for us. One way to do that is called CGI. That is a way to write scripts or computer programs and let your HTML pages give them instructions. There is another way to do that, though, and for our purposes it's even simpler. It's a programming language called PHP, and it allows you to mix those commands with your plain HTML, switching back and forth seamlessly. What is truly beautiful about it is that the PHP code becomes invisible to the person viewing your web page. All they see is the result, the HTML code that PHP sends to their browser.
The PHP interpreter needs to be installed so that Apache will let it look at all the HTML pages it serves up. PHP will look for its own special tags and change the content "on the fly" so the page that Apache finally sends to your browser will not look exactly like the one on disk. It will contain the latest information about the stock in your store, for example. We will go over this in great detail when we walk through the HTML/PHP code for SimpleshoPHP.
Here's the Hands On How To for PHP 101 -- it's just a jumpstart so that you have some foundation (no Interchange pun intended) before you pick up a real PHP book.
A database is a place to put data -- think of it as a box of 3x5 cards. But it's a magic box because you can talk to it, ask it questions, and get back just the cards you want. SQL is a way to talk to a database. and MySQL is a freeware database package. Unlike languages such as BASIC, you don't have to worry about counters and loops when you talk to a database. (It's even easier to learn how to speak SQL if you haven't gotten trapped in that "procedural" count-and-loop mindset, I've found.) A SQL database is happier if you just ask it to give you a selection of data, such as "all the rows that these two groups have in common," and take the results that it gives you. Here's a beautiful example:
SELECT DISTINCT dept FROM books;
Instead of building a scratchpad and reading the entire file and testing to see if you are at the end of file, and keeping a count of the departments and testing to see if you have seen this department before and .... oh, I'm getting tired just thinking about what a BASIC program to do this would look like! It would go on for pages. That single line of SQL gives you a list of the unique departments. One line. Problem solved.
Here's the Hands On How To for SQL 101. Again, it's just the barest skeleton, a "This End Up" sticker on the outside of the box.
|
|
|
You are invited to post comments or questions on the SimpleshoPHP forum at SourceForge.net.