When version control systems fail miserably

When I began using version control system software, the world was mostly stuck with RCS, if you wanted to use free software that is. Next came CVS, PRCS, SVN (Subversion), Bazaar, Git, Mercurial, and many others. There were, of course, also many commercial version control systems available such as ClearCase and Perforce. So now we have several excellent pieces of software when it comes to version control.

In most cases, users of these version control systems seem to fall into two categories. Those that prefer to work locally on their own machine or in their own environment, and those that work in a shared environment. Regardless of which category you fall into, the theory behind many modern version control systems is that you never work against the immediate source, but instead use some sort of local version, be it “working copy” or “cloned repository”.

With the advent of integrated development environments such as Eclipse and Netbeans (and many others), support for version control systems is often built-in or provided via some plugin. You get immediate notifications when your source files have been modified (by yourself), when a conflict occurs, you can check files in and out of the repository, etc.

I — and others — seem to have run into a problem with the way things are being done, and I cannot seem to find a solution to this problem, other than resorting to the command-line interface of the various tools (svn, hg, git, etc).

Here’s my beef:

I keep a stable, production level, copy of a project at /home/prod/stable. It is reachable from the web (because that’s where I use the application) as http://www.somewhere.com/prod. It is also under version control at /home/repo/prod[..]

Now, I also keep my development version on that same server, also reachable from the web (because I don’t think duplicating my runtime environment on every single computer I may work on the project from is a grand idea). So for this, I have /home/prod/dev and http://www.somewhere.com/dev; I can choose to have a complete “duplicate” repository at say /home/repo/branches/dev, or just a working copy at /home/prod/dev. The crucial issue here is that I keep my live development files on the same server as the repo, but I code using NetBeans or Eclipse (or anything based on Eclipse) from my laptop or one of my workstations.

This combination seems impossible to get working if I want to use the built-in version control system support in either of these two IDE:s. I’ve gone through Subversive, Subclipse, SVNkit, Git, and Mercurial — and none of them, in combination with NetBeans or Eclipse, can handle this.

So I’m asking myself (and you) .. what’s f-ing problem?!? Why can’t NetBeans and Eclipse just treat the remote project as any other project? Why can’t I simply be allowed to create a remote project, and then specify the appropriate parameters for version control and be allowed to utilize the power of version control from within the IDE?

Using something like SSHfs to “trick” NetBeans and Eclipse into thinking it’s a local project won’t work either due to the really poor performance of SSHfs (Ubuntu 10.10). Obviously, the solution needs to handle not just me working on the same project from many locations, it also has to support other developers working on the same project, from many locations. All Eclipse-based editors (EclipsePDT, Zend Studio, Aptana, etc) suffer from the same problem since they use the same plugins.

Searching the web for this issue, I’ve come across many requests for this, but not a single solution; which, given the nature of Internet, is a pretty rare thing. I could never in my wildest imagination (and it’s pretty far out) had thought that I’d be having a beef with something as common as a remote server or remote file system in the year 2010 πŸ™

Why Netbeans 6.9x+ is an awesome PHP development environment

I’ve been doing some form of coding since around the advent of the IBM PC and VIC-20 and have obviously come across many editors and IDE:s for a number of platforms. Things have come a long way since Edlin. I cannot recall every single editor and IDE I’ve been toying with, and I’m not sure it’s relevant to this post, but some of them include A/Edit, Emacs, TSE/Qedit, Brief, SlickEdit, vi, and many derivatives of these. Having been a DOS programmer for quite some time, I’ve also been working in the various Borland IDE:s.

In the past 10 years I’ve mostly been using Emacs, and every now and then I’ve been sneaking a peek at various other Linux based editors. For the past several years I’ve been giving both Eclipse and NetBeans a go. There are a number of IDE:s out there that are based on Eclipse (Zend/ZDE, Aptana Studio, Eclipse PDT to name a few), so in many cases they share their core behavior, look ‘n’ feel, pros and cons.

One thing I’ve learned, the hard way, is that there are just about as many “My editor is better than your editor”-battles being fought as there are “My language is better than your language”-battles; programmers and developers truly seem to enjoy trying to outdo each other when it comes to proving their arsenal of tools to be superior to that of others. I’ve never understood this part. If you can solve the given task, with all its parameters, with whatever tools you prefer, go and do it. If someone else can manage the same thing with some other tool, good for them. Listening to these arguments is like listening to two five-year-olds battling it out trying to convince the other that a given color is prettier than another. Of course, one could just turn a deaf ear and not listen πŸ™‚

Now let’s talk a little bit about Eclipse and NetBeans.


Free CakePHP E-Book – Super Awesome Advanced CakePHP Tips

There are a few books out for CakePHP development. The main problem with them is that they’re fairly old. There’s also a book on the way (2010) that has not yet been released. And then there’s Matt Curry’s completely free CakePHP book for those that have managed to grasp the basics of CakePHP and want a guide to somewhat more advanced topics.

One can only congratulate Matt on a great idea and implementation; and what’s not to like about a free book about CakePHP development?

An introduction to the book here: www.pseudocoder.com/free-cakephp-book/
Matt Curry’s original blog post about it here: www.pseudocoder.com/archives/2009/05/13/free-cakephp-e-book-super-awesome-advanced-cakephp-tips/
The book’s direct download link is here: www.pseudocoder.com/Super_Awesome_Advanced_CakePHP_Tips.pdf

More about CakePHP can of course be found on www.cakephp.org

Matt has also released a number of CakePHP plugins and code snippets here github.com/mcurry.

Thanks Matt!

Preventing access to backup PHP~ files in Apache

Many Linux command-line people use the VI editor; but if you’re like me and prefer Emacs, you often run into the “problem” that Emacs creates backup files using the original filename and appending a tilde (~) to the end of the filename. E.g. “secret.conf.php” becomes “secret.conf.php~”.

There are a number of ways to go around this, of course. One way is to configure a separate directory for each user where Emacs stores its backup files, and then make that directory readable only by the user.

Why is this a problem? Well, if you’re using Emacs to quickly modify PHP applications’ configuration files, like the database configuration file, you’ll leave a trail of .php~ files. These files are typically not parsed by the PHP processor, instead they are handled by the text file handler in Apache. Meaning, if I enter the url http://myverycoolsite.com/secret.conf.php~, Apache will gladly display its actual contents, just like if you were editing the file.

This can be prevented by using the .. configuration construct in Apache like so:

<Files ~ “\.(html\~|htmls\~|php\~|phps\~|php3\~|php4\~)$”>
  Order allow,deny
  Deny from all

Perhaps not the most elegant of solutions, but it works. It will result in an “Forbidden” response from Apache. Check out the Apache documentation for more details on this directive.

You can go back to sleep now πŸ™‚

Nullifying pointers in PHP

Using pointers in PHP is quite useful at times; but it can also leave you dumbstruck with serious debugging on your hands. Consider this construct:

[code]for ($i = 0; $i < 10; $i++) { $p1 = null; if ($Buffer [$i]['type'] == 'scanthis']) { $p1 =& $Buffer [$i]['data']; } .. if ($p1 != null) .. }//for[/code]
This will in effect dereference and overwrite a given [‘data’] array member of $Buffer if [‘scanthis’] evaluates to true. But I still want to use “null” as an indicator to whether or not to do something.

So I replace the above with:

[code]for ($i = 0; $i < 10; $i++) { unset ($p1); <-- $p1 = null; if ($Buffer [$i]['type'] == 'scanthis']) { $p1 =& $Buffer [$i]['data']; } .. if ($p1 != null) .. }//for [/code]
This will destroy $p1, but not what it’s pointing to, and then it sets $p1 to null, just like before.

This is obvious when you look at it, and there are a number of other ways to accomplish what I describe above, but it had me stumped for a while πŸ™‚

Delphi for PHP

So Borland (or CodeGear) finally realized the web was a place where old Delphi developers may hang around on, and decided to release Delphi for PHP (!). I haven’t looked at the product myself, other than screenshots, but it sounds like someone at Borland or CodeGear got their flashbulb working a bit too late. Had this product been out a few years ago, it might have been an interesting package. As an IDE and framework platform, it may still have some merit, in particular for “quick and dirty” needs. And, I suppose, for someone who has spent a lot of time working with Delphi/Kylix and want to publish “generic PHP apps” without having to learn too many new things in order to do so, Delphi for PHP may be a good solution.

Having worked with Turbo Pascal since version 2.x (yes, I’m that old), and then Borland Pascal, Object Pascal, Delphi, Turbo C/C++, Borland C/C++, I would probably have been interested in Delphi for PHP, five years ago. But I’d say it takes a lot more than a revamped Delphi interface sporting PHP code, to get people with tools like ZDE and all the available PHP frameworks, to switch their development environment.

TASM anyone? Or perhaps Microsoft will now release MASM for PHP. Another hotseller might be Sidekick for the Web! πŸ™‚

I wish CodeGear the best of luck, and I hope this will bring forth even more competent PHP developers.

Other related links:
  Delphi Wiki: http://delphi.wikia.com
  Slashdot: Delphi for PHP released
  CodeGear: Delphi for PHP
  First impressions: Tim Anderson’s ITWriting
  Other impressions: The Joel on Software Discussion Group
  InfoWorld: CodeGear extends Delphi for PHP, Vista, AJAX
  Professional PHP: Delphi for PHP

SwiftMailer 3

Swift is a fully OOP Library for sending e-mails from PHP websites and applications. It does not rely on PHP’s native mail() function which is known for using high server resources when sending multiple emails. Instead, Swift communicates directly with an SMTP server or a MTA binary to send mail quickly and efficiently.

Early versions of Swift were comparable to PHPMailer. Swift has since evolved and matured into a fully-fledged object-oriented mailing solution. Compared with PHPMailer, the interface for Swift is both tighter and more intuitive.”

So describes Chris Corbyn his Swift or SwiftMailer project for PHP. I’ve been using it since version 2.x and can happily recommend it to any serious PHP developer out there (in stating this, I’m by no means claiming to be a serious PHP developer of course :-). Chris provides for both PHP4 and PHP5 compliant packages.

SwiftMailer is more than just a replacement for PHPmailer, XpertMailer, and other similar packages. Version three sports a much more flexible plugin architecture.

Do you PHP? Do it Swiftly.

You’ll find SwiftMailer on www.swiftmailer.org.

Javascript Terminal [Emulator | Console]

I had an idea, one of many useless ideas I’m sure, but nevertheless an idea. To test my idea I need to find a good Javascript-only (AJAX is OK, but pure client-side Javascript or ECMASCRIPT is a requirement) terminal emulator. This turned out to be just a little bit harder than I expected.

I found found a zillion links (possibly more, the counts aren’t in yet) on Google and other search engines; I found a ton of half-way solutions that were client and server based, and I found, of course, the “standard” Java terminal/console window applets. But I did not find very many pure client-side terminal emulators. Anyterm seems nice, but it requires server-side support in the form of some Apache mods, which I would like to avoid if at all possible. There is a stand-alone daemon (experimental) for Anyterm, but again, I want client-side only.

I need one that isn’t restricted in any way as far as usage goes. The “prettiest” one by far thus far in the hunt is the stuf presented at www.masswerk.at, but it has restrictions on usage that I’m not entirely sure I qualify for.

I also found JSterm, which might be a step in the right direction. Perhaps studying the code, I could make the necessary modifications myself. Then there’s AjaxTerm, but it’s Python, not Javascript.


Ho ho.. another night of past 01:00, time to hit the sack before I diminish by sorely needed beauty sleep even more πŸ™‚

Update 2006-10-07 @ 21:24

WebTTY may also be of some interest, you can find it here.