Posts Tagged ‘PHP’

Entering the world of version control

Saturday, August 20th, 2005

Doing PHP development for several years now, I never really understood version control and how to integrate it with my web-application development. For “traditional” programming, it is clear. You create a repository, all the developers keep in sync and commit their updates. But being the whole development team yourself and have code that for 100% depends on the database stopped me from even try to set up a version control system.
Until last week. I just finished a project and was starting a new one, when I decided that this was the ideal moment for fiddling around with version control. I happened to have a golden oldie compaq proliant 1850R with RAID 5 disks AND a fresh install of freeBSD 5.4. Ideal for the task of becoming a CVS server….eh… cvs? subversion?

Being a total version control newbie, I did my googling and reading.
In one sentence: CVS is old and insecure, Subversion is hot and the talk of the town. CVS compares to Subversion as telnet to ssh.
And the fun thing? installing and setting up took me 1,5 hour. Using ports
there are basically two ports to install: Apache2 and Subversion.
Below are links to the pages I used for setting up my subversion server, but here are some hints/notes: (not a howto or tutorial! read the pages!)

Create a svn user and group, and adjust the umask of that user. I used: umask 002.

Build apache2 with WITH_BERKELEYDB=db42.
I have changed httpd.conf to have apache2 runs as svn user and group, this spares you from read/write issues when using Subversion with webdav.

Build Subversion with -DWITH_SVNSERVE_WRAPPER -DWITH_MOD_DAV_SVN.

Su -l to the SVN user, create the repository and import your initial project layout, confiure apache to serve the repository with webDAV and…you’re free to go!

It kicks ass!
I do my webdevelopment on my mac offcourse and I found svnX to be a fantastic client wrapper. 2, 3 hours after installing and setting up my first version control, I found myself wondering how I ever lived (eh..ok developed) without it.

The links I used:
onlamp – Setting up a Secure Subversion Server
the SVN book (free!)

macdev center- making the jump to subversion
onLamp – top ten tips for Subversion users
OS X Subversion client package (you need this for being able to use a gui front-end as svnX.
svnX
Versions Systems link collection

And because I always forget the exact procedure:
Apache+SSL on freeBSD

Recent addition is this article from RedHat, a introduction suited for both CVS users and those new to version control.

CVS is out, Subversion is in found with digg.com

Visual Programming with Java

Saturday, July 23rd, 2005

For my Open University course I have started with “Visual Programming with Java”.
I know it’s more fun as Discrete Math :)
And it’s quite fun to finally “learn” programming, as I’m a autodidact. The level is very very basic, but that doesn’t matter to me. In the last years my experience is that it can be very helpfull to really learn the basics.

The real fun is that I have to use windows again. The course uses Borland Jbuilder 8, with a license which only runs on windows XP according to the manual, but I use it on my very old windows98 machine without any problems.
And oh boy, what is an IDE fun. Programming like playing with LEGO.

“You have forgotten a semi-colon right here”.
Oh…thanks :)

Instead of digging through 2500 lines of code where that missing T_SPACE is…
Java is also fun to work with. Very straightforward and easier than C (no memory management / garbage collection needed). I really can tell know where PHP has it’s roots. It really helps me getting some insight in OOP concepts, which are used in PHP 5 as well.

btw…writing this on windows, WordPress really looks better in Firefox as in Safari…damn.

Migrated to PHP5

Sunday, April 10th, 2005

I did it!

For over a year I glanced at PHP5, but put it aside as too unstable/experimental (a year ago) or too dangerous to migrate due to incompatibility issues.

Some of my projects where however advancing to a point, that procedural programming became to limited. And more and more I found myself looking at (Object Orientated Programming) OOP.
And being a absolute rookie in OOP, I decided that if I had to learn OOP, I wanted it to learn in PHP5 rightaway, instead of starting in PHP4.

Well, 2 weeks ago, I decided that the time has come. I downloaded php5, installed it on my development server and….it just worked?!

A closer look learned that JPgraph -scripts broke and some my legacy code also.
Fortunately, there are two configuration options who both can be set in a htaccess or virtualhost configuration:
zend.ze1_compatibility_mode
and
register_long_arrays

Enabling those two directives in the appropiate virtualhost config made all the scripts 100% working again!(yeah yeah I know, ditch the legacy code and wait for jpgraph 2.0, but we don’t live in a perfect world, do we?)

The last week I find myself coding in PHP5 OOP style for the first time, using the new mysqli extension (prepared statements kick ass!) and enjoying php5 very very much!

MyFirstWidget™

Tuesday, March 29th, 2005

Having an ADC-select account, I have access to the latest release builds of Tiger.
On Easter-Sunday, I decided to do something usefull with my tiger-seed and downloaded the Dashboard SDK.

Being used to PHP, it took some frustrating tries with javascript, but some hours later I was looking at my first widget.
It basically uses Curl to fetch PHP generated content over a HTTPS connection.
Shown are the last five lines of a access-log from a webapplication.
It works like a charm and refreshes every time dashboard shows up, or with the command+r keycombo.

If Tiger is released and the NDA is lifted, I’ll probably post the widget for download…untill then, some screenshots:
widget front
the front, some content blurred for privacy reasons

widget backside
and the backside, i simply love the animation :)

Upgrading mysql on OS X 10.3 Server

Sunday, March 13th, 2005

With the latest discovery of some remote vulnerabilities in mysql and PHP, I had to upgrade my production server.
And to be clear, I don’t like updates.
Esp. not on mission critical apps. Updates tend to break things, you see:)

But running php 4.3.6 and mysql 4.0.20 was getting…unwise.

Upgrading PHP is easy, with the (imho) great installer of entropy.ch.

installer -verboseR -pkg ~/php-4.3.10.pkg -target /

Don’t forget afterwards to restore your httpd.conf and to edit /usr/local/php/httpd.conf.php to add:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .html
AddType application/x-httpd-php-source .phps

MySQL is somewhat more tricky.
The version supplied by Apple is well…historic.
I like to compile MySQL from source (esp. because that takes 8,5 minute on my Xserve :) and install it to /usr/local/mysql-(version).
After that I create a symlink from /usr/local/mysql-(version) to /usr/local/mysql.
Take some care replacing the apple supplied mysql-binaries with symlinks to the up2date /usr/local/mysql/bin/ counterparts.
After this, upgrading mysql from source is painless.

The most recent upgrade:

# cd /usr/local/src
# gnutar -xzvf mysql-4.1.10a.tar.gz
# cd mysql-4.1.10a
# ./configure --with-openssl \
--prefix=/usr/local/mysql-4.1.10_a \
--localstatedir=/usr/local/mysql-4.1.10_a/data\
--mandir=/usr/local/share/man/\
--with-mysqld-user=mysql
# make
# make install
# cd /usr/local/
# mysqladmin -u root -p shutdown
# cp -R mysql/data mysql-4.1.10_a/data
# chown -r mysql:wheel mysql-4.1.10_a/data
# ln -s /usr/local/mysql-4.1.10_a /usr/local/mysql
# mysqld_safe &

That’s all. If something goes wrong, just restore the symlink to the “old” mysql-(version) and you’re safe.
Be aware of the new password hashing mysql uses from 4.1.1 of. I used the –old-password switch untill I’ve upgraded all my clients.