2010
09.01

Lately I have been considering PHP frameworks and using them to speed up development of small projects, whilst also considering the MVC (Model, View, Control) approach. Most people looking for a PHP framework seem to stick with CodeIgniter, Zend or Symfony. Each with there own advantages and disadvantages. Which one is best is all down to personal taste and its very difficult to make an educated selection of the framework thats best for you. Its baffled me infact, that I can’t put my finger on the framework that I think works for me the best.

So I plan to try and develop a small project in each of these frameworks and decide after that which one I think is the best for me.

For more complex sites, I will continue to use my own custom framework as it helps to keep down page load speeds and ease of understanding.

Check back here over the next month or so, to see what I get up too. As I will be posting all about my experiences with the frameworks.

2010
08.18

Just blogging this for future reference:-

Using several aliases on the same domain and keeping the same apache server name for all can be achieved by entering this into the apache config for the vhost.

UseCanonicalName On

If you wish to let Apache select your server name automatically the default in most configurations of apache is set to:-

UseCanonicalName Off

2010
08.13

Last night I trawled the internet trying to find the answer to how to hook up my mac os x terminal to my mamp mysql using the > mysql command in the terminal.

For mac os x 10.5.6 Leapoard users this command worked just fine.

sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql

I also noticed attempting to use the mysqldump command resulted in this error: “-bash: mysqldump: command not found”

To solve it cd into “/Applications/MAMP/Library/bin/” and run the same command and you’ll have much better luck :)

2010
08.11

Use this simple command to find and delete .svn subversion folders from within a folder or directory using mac linux terminal command line.

find ./ -name ".svn" | xargs rm -Rf

Example with folder path
find ./images/ -name ".svn" | xargs rm -Rf

2010
07.13

This week I’ve seen a real transition in my own personal way of thinking towards design and development. Particularly with how it relates to the development of our online games. After just over 2 and a half years of programming full time, I’ve noticed some really key and distinctive transitional periods in my developing lifespan.

When I first started out it was a case of get it done no matter how or what and learn along the way. This particularly involved little planning, especially planning programming techniques around the design. I would hit hurdles and obstacles all the time, but being the pragmatic problem solver that I am, I’d find ways to jump them or ways around them (thank god for google). At this stage I took little to no notice of design as my css and general knowledge of design technique was so poor that I was stuck well within the table age.

Things quickly moved on and before I knew it all the problem solving had left a lasting imprint of php, html, css and ajax in my head. Enough to be competent (at least so I thought) but not enough by far to be the master. Not knowing that at this stage is possibly the biggest downfall I had. A bit like a guy fresh out of college with his honors degree and first job, I set off to change the world and make amazing looking websites. Uh oh, I might hear you say! Uh oh, indeed. Not long after I began to see my designs not really working out as I wanted or not functioning as well as needed and browser compatibility wasn’t great (I partly blame this on the comfortability and lovability of my new mac, making me not want to look at the far more popular windows based browsers. Damn you internet explorer!).

However I buckled up, hung in for the ride and got things working, with less than sexy solutions at times. After this I began to realise the importance of planning and careful structuring of code, so much so that I even started to do it myself :) This became especially important with the development of my companies online games. Massive code bases with hundreds of thousands of lines of code and files. Making use of functions, class’s and sub version made a massive difference to how we developed and maintained our code base.

Yet recently something more radical has changed than just the methods that we used to serve up a page to a player or user. I don’t now think about going in all guns blazing to make the ‘best’ looking website in the quickest time possible, as most of the time this isn’t possible. Im more interested in simple but effective design with clever and efficient coding beneath it. Especially so with our online text based mmorpgs, users are more thickle than you think and care less about the fact that it looks good, and more about that it works good. Simple designs tend to be more backwards compatible and also more compatible with the gathering pace market of mobile and netbook gaming. So generally I now tend to think a bit like google I guess, make it work good, make it look okay, but most importantly make sure the whole experience ‘works’ for the user.

So its interesting to see how I’ve gone from struggling to stay afloat, to swimming too hard and finally to staying calmly and nicely afloat.

I wonder if anyone else will have had some interesting personal development stories….

2010
07.13

Not having had huge experience working with mysql dumping and rsync. This afternoon I was faced with the task of taking a backup of one our busy, very database intensive games using mysqldump command, but I also needed to exclude some rather over sized tables from the dump. After which I wanted to pipe over the mysqldumps to our remote secure testing server using rsync which id also never used before.

So the first things first I let our users know the site is going down in 5 mins I then sabotage our db_connect functions so that users a directed to a page with no connection attempts or db calls on it.

I then write the command to dump data and tables ignoring a few tables which id already flagged as potentially large and time consuming to dump.

My command looked a little like this:-

mysqldump -u username -p --ignore-table=database.table ignore-table=database.table -B database -K > /path/to/outputfile.sql

With quite a few more ignores hehe but hopefully you’ll get the gist.

I then just wanted to dump the structure of the troublesome tables.

So I did something like the below.

mysqldump -u username -p database table1 table2 -d > /path/to/outputfile.sql

Notice the -d, this is very important as it signifies no data just structure.

Now I have my two files I want to sync them accross the our test area located on another server, this time using a rsync

I used ssh with rysnc and my final command looked like this.

rsync -a -e ssh backups/ username@server:/home/google/backups

Which simply took my backups directory on the server i was connected to already and synced it with the credentials entered here. Seemlessly and with all permissions etc carried over.

Now thus I had achieved what I needed to and all that was left was to load the files into the database for the test area. By simply:

mysqldump -u username -p database < /path/to/inputfile.sql

2010
05.11

Just something I found myself looking up today so that I can do everything from the comfort of my little terminal window.

I wanted to take a backup from a table in one database and up it to another db.

Firstly I dumped the tables on my remote server to my sites webroot.

mysqldump -u root -p database_name table_1 table_2 table_3 > /path/to/outputfile/outputfile.sql

This will prompt you for your password, enter it and it should, providing everything else is correct dump to ‘outputfile.sql’.

Now you have your backup residing at your web servers webroot or wherever it is you may have chosen to store it.

This file can now be retrieved either by a FTP client or if your like me then using terminal by either using curl or scp to local.

Curl example:

curl -O http://wedpathtoserver.com/outputfile.sql

Scp (preferred via ssh):
scp username@server:path_on_server/file path_to_download_to

Once on local you will probably want to move this to your other server via uploading which we will again use Scp for this.

scp path_to_file/file username@server:path_to_upload_to

Once youve got the file on the server which the database you want to import data to resides.
Connect to the server in this case via ssh.
Then restore your file to the database.
mysql -u root -p databasename < /path/toupload/directory/outputfile.sql

This is the general format to remember

mysql -u [username] -p [password] [database_to_restore] < [backupfile]

If its a zipped backup you want to restore simply use the following command

gunzip < outputfile.sql | mysql -u root -p DatabaseName

Also remember you dont have to have the password prompt you each time you can include it in the original command by changing `-p` to `-p password`.

Very basic but will suit most peoples needs.

2010
04.21

If your like me and sometimes need to debug js in different browsers for web development. Sometimes its helpful to use debugging tools available with different browsers. Mozilla has the really useful firebug tool, which I use all the time and which is easily installed via mozillas browser plug in environment.

Safari on the other hand is a little trickier, I stumbled accross this today which certainly helped me.

Open up a terminal window on your mac and run this command

defaults write com.apple.Safari IncludeDebugMenu 1

Quit Safari and reopen, you should now see a ‘Develop’ tab along the top of your mac toolbar (where preferences is).

You can use this to do all sorts of useful profiling of your scripts on safari, which I have found most useful.
Enjoy.

2010
04.15

I have started learning the basics of game design using adobes cool flash cs4 suite. Actionscript seems to basically be php objects with a little syntax variation, so the programming side seems easy enough for me since I program with php objects often. Wondered if anyone could point me in the direction of any good forums / tutorials that flash developers get together en mass to help each other out with development problems?

Also maybe if anyone had any hints or tips then you could also put them as a comment for me to check out under here.

2010
04.12

Adding a new vhost is something I have to do on a regular basis when working on new projects locally.
Its a fairly straight forward task as well.

Download and install:- MAMP

Once you have done this navigate either with a finder window or via terminal to /Applications/MAMP/htdocs/

Once here create a folder again either with finder or terminal e.g mkdir myfirstsite

cd myfirstsite - to enter that folder and create another folder: mkdir http

Lets also add a test landing page so add a file called index.html into your http directory either in finder window or just by the following command in terminal.

Cd /Applications/MAMP/htdocs/myfirstsite/http/
vim index.html
hit ‘i’ to insert
type “Hello this is my first site”
hit escape-key + type ‘:wq’

Now we want to do 2 things, firstly add the virtual host to the httpd.conf file:

Navigate to: cd /Applications/MAMP/conf/apache/httpd.conf

Once here either open the text file in a text editor or simply enter it with: vim httpd.conf in terminal if your familiar with this method.

Scroll the very bottom and add the following:


DocumentRoot /Applications/MAMP/htdocs/myfirstsite/http
ServerName myfirstsite

Then secondly you need to add the site to the your local OS X machines host file with the following command via terminal window only.

printf “127.0.0.1\tmyfirstsite\n” | sudo tee -a /etc/hosts

After that restart MAMP by ’stop servers’ and then start servers option.

Then open up your browser pop into the address bar:- http://myfirstsite:8888/ and with any luck you’ll be on your way.