Wednesday 16 May 2012

Learning PHP the hard way

I have been given a challenge: to learn PHP well enough to demonstrate my programming prowess.
Most people will have no idea what PHP is, and probably care less. Not to worry, read on and you will possibly learn more than you are interested about.

Fair warning

Most of the material in this post (and many others I have been known to write) is a touch on the technical side. If how to program computers is not your thing, stop reading now or you may (will) be comatose before you reach the end (yes, I've been told about what was said).

My development environment

I had the choice of using my macbook directly, or using one of my linux virtual machines. I decided to opt for the macbook - manly because the start up time of the vm's is a little slow at times.

Apache configuration change

To get the macbook to work nicely meant I had to configure the built in web server to use php. This was easy (for once) and just involved uncommenting one line in the apache configuration. StackOverflow showed me the lines to change.

Sharing the local site

This allows me to use a browser to see what my code is doing (or how badly it is going wrong). This guide is for the previous version of OSX, but worked well enough for Snow Leopard.

I set up a symbolic link from my public share folder to my project folder. This will probably turn out to be the wrong way to do it, but for now it will suffice.

A Default project structure

It is probably best to follow the way someone else recommends, at least for learning how to code in PHP, and this is the tutorial I followed to set my folder structure up.

A Favicon

Following the error log for apache tells a developer lots of things that are wrong with the code. I quickly noticed that a common complaint was that the favicon file was missing, so I thought I should learn how to make one.

Bugs, I have a few

I need to read up on how to include the folders into the project, because I'm getting this error when viewing the page:
PHP Fatal error:  require_once(): Failed opening required '/header.php' (include_path='.:')

That is going to wait until my next session, because I sat down to check my email at 5pm, and it's now coming up to 8pm and all my girlfriend has seen of me tonight has been my back. I hope we weren't meant to be going out to the pictures tonight...

So far I can't say that I've learned a lot I didn't already know, but my code is now checked into github for all the world to see.

What next?

I'm going to make something to eat, and catch up on the rest of my emails (I'd been waiting for the one that trigged this and sod's law is I was out for the afternoon when it arrived).

Musical interlude 

Or in other words, stop reading this and find something more interesting to do.

     And now, some code is here
     And so I see so far it's rubbish
     My friend, I'll say it clear
     I've made a start, that much is certain
     I've learned a little today
     Yes, I googled the data highway
     And more, much more than this will learn more my way

Thank you, and goodnight.

No comments:

Post a Comment