Need help getting started with modern web development

NickelPlate

Senior member
Nov 9, 2006
652
13
81
Hi Folks,

It's been a long time since I did basic web sites using authoring tools such as Front Page, Coffecup HTML editor etc.

My work requires me to start learning to develop using PHP and MySQL and I am a complete noob on both topics although not a stranger to programming. I need a way to get started and want to set up a windows based development environment on my local PC. Even though Linux/Ubuntu seems to be the most popular choice for this sort of thing, I want to stick with Windows because that's what I'm familiar with. The learning curve already is seeming pretty steep without having to learn a new OS.

Step 1 is I apparently need web server software and Apache seems the popular choice (I don't know anything about Apache either). However they (Apache or whomever "they" are) don't provide binary installers for their latest version only source code which needs to be compiled first using any number of tools. I have Visual Studio 2010 which supposedly can accomplish this but I'm not sure what "source" file to download from the Apache web site at the below link. There are two Unix source files, a Netware binary and a link to "other" files none of which jumps out at me as being the correct one.

http://httpd.apache.org/download.cgi#apache24

I've run across other websites where people have apparently accomplished this feat and offer these installers but I'm a bit leery downloading them from untrusted sources. It's a shame I can't seem to find a package installer for Windows which provides/installs everything without having to go through all this manual installation hassle that requires all sorts of prerequisite knowledge. How does one get started learning?

Any other suggestions for a complete newb like myself are appreciated :).

Thanks,

NP
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
Using Linux is going to make learning this so much easier for you. It's the more popular configuration, so you'll be able to research and get more results/tutorials.

Install vmware player and install Ubuntu 12.04 or other version. Then you can run Linux as a virtual machine on Windows. This is probably the 'hardest' part of getting it running. Ubuntu won't be hard, and there is still Netbeans which you can use as an editor or Eclipse.

Then you'll have access to lots of tutorials that will show you how to get started with php/mysql under Linux.
 

NickelPlate

Senior member
Nov 9, 2006
652
13
81
Thanks for the response Ace. I did manage to get XAMPP installed and works pretty good. I went through some basic php/mysql tutorials and am off and running. I'm just using this as a development/educational platform which is why I wanted Windows, and another distribution package I found for anyone who is interested WampServer.

http://www.wampserver.com/en/

I'm not going to set all this up myself in the end though. I just need an environment to learn php scripting and connecting to and managing mysql databases. Once I get my work's application to a point where it's useful, we'll just go to an online hosting service most of which run Linux in a far more secure environment than I could ever manage myself.
 
Last edited:

Cogman

Lifer
Sep 19, 2000
10,283
134
106
Thanks for the response Ace. I did manage to get XAMPP installed and works pretty good. I went through some basic php/mysql tutorials and am off and running. I'm just using this as a development/educational platform which is why I wanted Windows, and another distribution package I found for anyone who is interested WampServer.

http://www.wampserver.com/en/

I'm not going to set all this up myself in the end though. I just need an environment to learn php scripting and connecting to and managing mysql databases. Once I get my work's application to a point where it's useful, we'll just go to an online hosting service most of which run Linux in a far more secure environment than I could ever manage myself.

Like aceO07 said, you are actually making things harder for yourself by relying on a windows setup for this stuff. It really is a lot easier to do this stuff in linux (learning curve of a new OS and all). The LAMP setup is so common that it isn't even funny. (seriously, I started out doing exactly what you are doing now. Looking back on it, the main thing it taught me was that setting up an AMP architecture on windows shouldn't be done.) It has little to do with security and everything to do with ease of use.

But that is besides the point. From a language standpoint, PHP is a pretty nasty language. I get that you need it for work, however, I would question calling it "modern" as far as web development goes. We are starting to see more Python, Ruby, and JVM languages (Java, Groovy, JRuby, etc) on the web. PHP is a dying web language IMO.

Now for suggestions.

It is VERY easy to write very bad PHP. I would suggest that you do your best not to. If there is one programming principal I would suggest following almost dogmatically, it is DRY (Do not repeat yourself). If you find yourself hitting copy/paste, you are likely making something less maintainable.

For web stuff, it is very important that you separate concerns as much as possible. If you have PHP/HTML/Javascript/and CSS all in one file, you are doing it wrong. Keep things as separate as possible.

For example, it is tempting to write code that creates a table and computes the value of each cell in that table. That is bad. You are mixing business logic with UI logic. The better approach is to have code that creates the data, code that creates the table, and then you feed the table making code with the data making code. The more you separate concerns like this, the easier it will be in the future to do something like change the way a chunk of data is calculated, or change what a table looks like.

Testing. Get in the habit of testing. I'm not a "everything should be tested" sort of guy.. I do, however, find a lot of value in good tests and in writing code that is testable. Tests should be flexible. If a tests fails, it should mean "This code is really REALLY wrong" not "Bob changed a variable name". Write your tests and your code in such a way that swapping out logic will be easy and natural.

While, btw, leads me to this point. Minimize the number of concerns any chunk of code has. Methods that are 100+ lines long are a pain to test and maintain. On top of that, they tend to grow steadily with time becoming ever increasing pains to deal with.

Good luck, have fun, and don't be afraid to play with stuff.
 

NickelPlate

Senior member
Nov 9, 2006
652
13
81
Thanks Cog. I'm curious what makes it so much easier to setup on Linux though? I literally had XAMPP up and running in minutes which surprised the heck out of me after struggling all weekend with trying to manually install all the components needed. Within the first hour or so I managed to get a basic php script written to connect and display some data from a mysql database which ultimately will be updated from remote machines out in the field and displayed on a web portal. I suppose the reason for choosing php is it's so common with most hosting providers I've been told. So far it seems not too dissimilar from from C which is what I'm most fluent in.

My main job function is not web development but I got nominated because I'm the engineer :p. I spend most of my time these days writing embedded microprocessor code in C for M2M applications and have a fair bit of controls programming in Codesys and ladder. A lot of your suggestions are good ones though and common practice in embedded systems too. I write a lot of stuff using state machine principles and write with portability and scalability in mind.

Cheers!
 
Last edited:

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
Cogman, did you have any experience with Linux when you started testing? There is a world of difference between "Use other OS which I already know" and "Learn new OS too".
 

beginner99

Diamond Member
Jun 2, 2009
5,284
1,708
136
Thanks Cog. I'm curious what makes it so much easier to setup on Linux though? I literally had XAMPP up and running in minutes which surprised the heck out of me after struggling all weekend with trying to manually install all the components needed. Within the first hour or so I managed to get a basic php script written to connect and display some data from a mysql database which ultimately will be updated from remote machines out in the field and displayed on a web portal. I suppose the reason for choosing php is it's so common with most hosting providers I've been told. So far it seems not too dissimilar from from C which is what I'm most fluent in.

My main job function is not web development but I got nominated because I'm the engineer :p. I spend most of my time these days writing embedded microprocessor code in C for M2M applications and have a fair bit of controls programming in Codesys and ladder. A lot of your suggestions are good ones though and common practice in embedded systems too. I write a lot of stuff using state machine principles and write with portability and scalability in mind.

Cheers!

I'm gonna say for development it does not matter that much if you do it on Windows. The down side is that you might encounter strange issues when moving your code to Linux due to the simple fact that these are different OS and might be running different versions of Apache, PHP and MySQL.

Since you mentioned hosting you need to be aware that depending where you host you won't have control over all settings (Apache, PHP and MySQL) and that can even influence your design.

What I consider problematic is that you are hosting so I assume the app will be freely visible to the internet? This means security will be a huge concern.

You will need to consider this:

https://www.owasp.org/index.php/Top_10_2013-Main

which is in itself a huge topic. The most important part IMHO is SQL Injection. First because it is well known and any half-intelligent 10 year old kid can use it to do harm.
This can at least partially made easier by using a framework. However that required that the hoster allows installing the framework of your choice and that you actually need to learn the framework.
 

beginner99

Diamond Member
Jun 2, 2009
5,284
1,708
136
Cogman, did you have any experience with Linux when you started testing? There is a world of difference between "Use other OS which I already know" and "Learn new OS too".

I basically had 0 experience with Linux and found it 10 times easier to install a LAMP on Ubuntu Server (no GUI) than WAMP. (if you ignore WAMP, XAMPP etc. which are not usable for production). Installing PHP and Apache on Windows was a pain and often it was difficult to find your extensions that were compiled in the exact right way you require for the right apache or php version.
 

watdaflip

Member
Feb 11, 2013
25
0
0
I haven't checked for anything better in years, but my go to PHP tutorial site is http://www.tizag.com/phpT/

PHP is back end programming, it's only half of what you have to do with web development.

Modern web development will involve HTML (most likely HTML5), CSS, and Javascript for client site dynamic functionality. You can use Java and Flash for front end assets as well, but JS will fit your needs in most cases. (Personally, I'd avoid Java applets completely, especially since Oracle bought Sun, especially with recent security issues).

In addition to these different technologies/languages, you have worry about browser compatibility. Javascript and CSS in particular have set standards which browser should abide by, but not all of them do (or at least not all version do). You need to determine your target market for the website, as well the what browser and version they might be using so if it's worth supporting. Supporting a browser might involve browser specific fixes, many of which you can find from a google search, finding people who have had similar issues.

You can choose to support only modern browser, or legacy browsers such as ie 6 & 7, and Firefox < 4.x

As far as runtime environment, even if you don't have to worry about getting servers up and running with Linux, it might be worth your time to get a dev environment running on Linux as it's very possible there might be bugs on that environment you can help fix. For instance, with my job, if I didn't have any knowledge of Linux, having 75+ servers running PHP on a linux machine and a bug comes up from code I deployed, it would suck to not have any knowledge to help fix it. It might not apply to you with your job, but it can definitely be helpful to assist in debugging what is happening on your production servers. I would seriously recommend developing on a mac/linux if your production servers are going to be running linux. If you will be deploying on Windows/ISS, then you should be set with a WAMP setup.
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
Thanks Cog. I'm curious what makes it so much easier to setup on Linux though? I literally had XAMPP up and running in minutes which surprised the heck out of me after struggling all weekend with trying to manually install all the components needed. Within the first hour or so I managed to get a basic php script written to connect and display some data from a mysql database which ultimately will be updated from remote machines out in the field and displayed on a web portal. I suppose the reason for choosing php is it's so common with most hosting providers I've been told. So far it seems not too dissimilar from from C which is what I'm most fluent in.

There wasn't an XAMPP when I first got into this stuff. So from that perspective, there were a lot of different binaries that you had to get and place in the correct directories. Random files also needed to be configured differently on windows than on linux. On top of that, most documentation available at the time assumed that you were running a linux system, so there was a lot of annoying things in the window system that you had to care about that were practically undocumented.

With most modern distros, the installation of those products boils down to running the package manager and telling it to install the packages you care about. Yeah, there was SOME configurations that you needed to do, but it was configuration that needed to be done on both windows and linux.

My main job function is not web development but I got nominated because I'm the engineer :p. I spend most of my time these days writing embedded microprocessor code in C for M2M applications and have a fair bit of controls programming in Codesys and ladder. A lot of your suggestions are good ones though and common practice in embedded systems too. I write a lot of stuff using state machine principles and write with portability and scalability in mind.

Cheers!

Gotcha. I wasn't sure where you were coming from. IMO the general principles are really about the only tutorial you need. After that, most languages are really pretty easy to pick up after a couple of tutorials.

Just be careful with SQL injections (as someone else mentioned) it is one of the biggest problems of the Internet even today and it is very easy to do. The issue is that writing code that can be injected into is generally much more intuitive than writing code that is safe from injection attacks.
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
I basically had 0 experience with Linux and found it 10 times easier to install a LAMP on Ubuntu Server (no GUI) than WAMP. (if you ignore WAMP, XAMPP etc. which are not usable for production). Installing PHP and Apache on Windows was a pain and often it was difficult to find your extensions that were compiled in the exact right way you require for the right apache or php version.

Yup, that was pretty much my experience. Getting everything in the right place and then setting things up was just a pain. Once it is done, it wasn't too bad, but getting to the "it is done" stage was just yucky.

I did this in the era when perl was a big web language as well, so I had both perl and PHP installation steps going.

It wasn't until much later that I got into linux. At that point, it was pretty shocking how easy installing those system were compared to the windows alternative (Even compiling things from source was much easier).
 

AyashiKaibutsu

Diamond Member
Jan 24, 2004
9,306
3
81
Just be careful with SQL injections (as someone else mentioned) it is one of the biggest problems of the Internet even today and it is very easy to do. The issue is that writing code that can be injected into is generally much more intuitive than writing code that is safe from injection attacks.

As long as you cleanse your database parameters you won't really need to worry about that. I know using parameterized sql statements in c# cleanses it. I suspect it does in java as well although I haven't really looked into how my code isn't injectable (using a lot of code someone else wrote). Main thing is to just make sure raw user input never gets sent as a sql statement.
 

Cogman

Lifer
Sep 19, 2000
10,283
134
106
As long as you cleanse your database parameters you won't really need to worry about that. I know using parameterized sql statements in c# cleanses it. I suspect it does in java as well although I haven't really looked into how my code isn't injectable (using a lot of code someone else wrote). Main thing is to just make sure raw user input never gets sent as a sql statement.

If you are sending in data, you should always use parameterized sql. Every library that I've seen which does SQL stuff supports this. It doesn't even really cleanse the string so much as signal to the DB "This is what I'm executing and this is the data that is coming in". The separation of data and commands is the key that keeps things safe.

However, rolling your own (something like "replace("'", "''")") is doomed to failure. There are just WAY to many ways that someone can encode their data to bypass that sort of cleansing.

In general, when it comes to user input/output you should try and avoid doing your own thing, you will almost assuredly get it wrong or miss some corner case.
 

NickelPlate

Senior member
Nov 9, 2006
652
13
81
Good discussion so far. Thanks for the info on the SQL injection. Interesting reading and I had no idea but I'll be sure to read more about it. My hope eventually once I get this working on a basic levl is to hand it off to someone who knows more about it than I do to not only pretty it up (because it's going to look like an engineer did it :)), but also make it more secure.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Take the time to learn some PHP, then adopt a framework. Chances are, someone has already done what you want to do.
 

tech7

Junior Member
Feb 22, 2013
7
0
0
There's nothing wrong with developing in a Windows environment. XAMP is a good choice to quickly get setup and hitting some tutorials but in the future you might want to look into installing Apache, PHP and MySQL yourself (it's really easy) and you have complete control over your system. I don't think having the most up to date version of Apache is a major issue - you probably won't make use of any missing features anyway. Unless there are any major reasons not to use the version available (such as security issues).
 

ButterRum

Member
Feb 26, 2013
37
0
0
It sounds like you want a development server to practice Web coding. If I understand the question, Then you do not need to worry much about the deep sysadmin. It shouldn't matter if you have Windows or Linux. You can Web program on both &#8211; however, Microsoft does have their own stuff such as ASP.net (which isn't very modern anymore).

But yeah, you can learn any programming language on Windows and port the code to a Linux server. You'd have to make a few adjustments such as file locations but nothing too drastic.

You can download stacks at http://bitnami.org

Bitnami pretty much creates your own development server on your localhost. It works great.

Also, engineers should be able to grasp higher-level languages, and I'd imagine they'd have potential to write more efficient code than non-engineers.
 
Last edited:

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
I prefer Apache Friends / XAMPP to binami -- last time I tried bitnami (admittedly a couple of years ago) their package was missing some PHP features I needed like libmcrypt.

XAMPP is run one install script and go.

For windows development, the main gotcha I've found is remembering that the Windows file system ignores case. That means:

- You can't have 2 pages HELLO.php and hello.php. Not that you should :) , Windows would see these as a single file.

- If you are sloppy, that means you could write file access code with incorrect names (HELLO.dat vs. hello.dat) that works under Windows but fails for linux when you move it to a production server.

Besides that, if you need to run something external using a shell command, you won't have the right set of programs (Windows vs. Linux).
 

rozkan

Member
Mar 1, 2013
44
0
0
NickelPlate, what exactly are you going to need to do once you learn PHP/MySQL? Because, as far as I read this thread, I don't really see why a company would try to make a web developer out of an engineer? I mean, a web developer is a usually a full time worker who write and/or maintain code. Don't tell me that the company needs a website and they figured it would be more cost efficient to turn an engineer into a web developer (because it is not). :)

Also, I see no reason to try to learn Linux while you are already trying to learn web programming. Benefits would be marginal, if any. Use wampserver to test your code, PHP will do fine in most cases and is NOT going anywhere at least for another decade.