Venturing Into PHP World!

Sunday, April 30, 2006

Object face of PHP

With PHP 5, the true object-oriented programming can be used. I was reading the book on PHP and started comparing it with Java. Coming from Java, it's very natural for me to compare PHP with Java. When one spends more than 10 years in java technology, it's very natural that every programming has to be done in object oriented fashion. The whole thinking process can only be object-oriented.

I was very happy to note that PHP has tried to follow all the OOP in it's new avataar. Now, it's easy to think and implement OOP in PHP without any hesitation. Except the constructor. I don't know why PHP had to do this. Because in Java, the constructor has the same name as the class name. But in PHP, the constructor is defined as __constructor. This is unique, but nothing very exceptional. This can be forgiven.

Another point is the access scope of methods and variables in PHP. In Java, if you don't define the access of the variable and method, then the default is the package level visbility. Because PHP does not have package concept, hence the default visibility is public. So it would be a good programming practice to not to leave out the access scope definition. Always define the access scope for each variable and method.

I am also a little confused about the static variables. In Java, there is a classloader that can load the static variables and methods without the instantiation of the class. I don't know how it works in PHP because in PHP every php file is running in it's own scope. I would try to clarify more about it as I go along.

Saturday, March 25, 2006

Upgrading to PHP 5 and MYSQL 5

The next step is upgrading to PHP 5 and MySQL 5 in my linux machine. The easiest solution is to get XAMPP for Linux (previously called as LAMPP). The 1.5.1 version supports Apache 2.0, PHP 5 and Mysql 5. They have detailed instruction on how to install it. However, this is not an upgrade package. You have to manualy migrate your existing information with this one.


Technorati Tags: XAMPP, LAMPP, PHP, MYSQL

Success with Subversion

Finally I had success with Subversion.

I upgraded the subversion to 1.2.3. Also I installed appropriate mod_dav for it.

But I think the trick is understanding two things:
  1. Difference between SVNParentPath and SVNPath
  2. Difference between project and repository.
Now here is the basic point. SVN does not understand projects. All it understands is repository. So if you want to make one repository and keep multiple projects under it, that would work. Also you can create one repository for each project.

However, depending on this selection, you have to use SVNPath or SVNParentPath in httpd.conf. If you are using one repository then use SVNPath. Using SVNParentPath would result in 403 Forbidden error. If you want to use multiple repository, then use SVNParentPath.

It took me long time to figure it out. May be if I woudl have understodd this before, it would have worked for me in the older version too. However, I am running a better version, I assume.:)

Technorati Tags: Subversion

Thursday, March 23, 2006

PHP framework comparison

Here is a link to the site that compares 10 of the 40 frameworks for PHP. Worth a read!

Framework Comparison


Technorati Tags: PHP, Frameworks

Sleepless with Subversion

i was happy with Perforce. Because Perforce gives a 2 client/2user version for free. Being the only developer, it should work out fine. But I thought in case going forward, if more friends of mine would like to help me out, then I would run out of perforce license. So I decided to give subversion a try because I am not kind of not happy with CVS and the way things work with cvs..:) After googling and reading, I kind of like subvrsion. But also I got warning that it would be tough to install.

My current server is mandrake/mandriva(why did they change the name?) 10.2. It came with a subversion 1.0.1-dev. And boy that started my sleepless night!

After all the configurations done, I can't view the repository and it gives me 403 forbidden access.

After spending considerable amount of time with all th permutation and combination, I lost hope on that. I decided to upgrade to the newer version. The compatible version with mandrake 2006 is Subversion 1.2.3.

When I tried to install it, it gave me some error about libkrb5support.so.0 missing. Now I have to install everything about kerbo complier etc.

I will update when I am done with it.

Technorati Tags: Subversion, Mandriva

Wednesday, March 15, 2006

PHP MVC Framework

While searching in google, I stumbled across the MVC framework for PHP called "Mojavi". The current stable version is 2.0.0 and the upcoming version is 3.0. Please check the links on the right side to visit the web site.

Technorati Tags: PHP, MVC, Mojavi

Bringing back the life!

Well, I got busy with lots of other stuff and hardly got any time to get back to PHP. During this time, PHP has moved to PHP 5 and now everybody is talking about object-oriented PHP.

Now I am trying to get back on track and learning PHP again. While doing that, I am also trying to learn integrating flash with PHP. It would be very interesting going forward. Hopefully, I can give enough time for this. And also would try to update this blog as often as I can.

Currently the books I am trying to read are :
It's very interesting that the first book one can use to learn PHP too. Just skip the sections that relates to Flash. At least I am doing that. Do I really need any other PHP 5 book to learn?

Sunday, May 01, 2005

What's with "$" sign?

Well, now that I have started doing some coding, on thing has started bothering me a lot. The "$" sign. Why? Whys is there a $ sign before any variable? Is php interpreter can not distinguish variables and function etc? Many other languages don't have it. But why PHP? I know Perl has the same thing.

This draws one conclusion: was it written for UNIX only or started out from UNIX. But it does not provide a strong support. Because C was developed form UNIX only and C does not have $ sign. Interpreted languages like ASP does not have it. But then what forced it in PHP?

The $sign writing is not only irritating, but it makes the code look more geeky and hacky. However professional you try to make it look like, but still the $ bites!

Thursday, April 28, 2005

Choosing the right IDE

I tried playing around with three different types of IDEs.

The first one is Komodo from ActiveState. I wanted to try it because it has perforce source control support. However, I don't know, it was kind of difficult for me to use it. I read that it is based on the VS.Net interface. But I guess I haven't had a chance to use VS.Net for a long time. Plus I am so used to Eclipse. I took me a whole lot of time to get used to this software.

Because I wanted to use Phing to do some basic code generation and building, I wanted to write a build.xml. But surprise! Komodo does not support writing an XML file. Those who don't know what Phing is, here is a short introduction. Phing is similar to Ant. Using Ant in java we can automate a lot of build processes. In the same way, Phing can be used. So Phing is built in the similar way. The build file syntax is more or less same as we write in Ant. As Komodo does not support writing this type of file, it got a negative point from me. And I had to abandon it.

Second one I tried is not an IDE, but a plug-in for Eclipse from Xored called TruStudio. Being an avid user of Eclipse, I found it very comfortable to go back to Eclipse. So I installed the plug-in and restarted Eclipse. Once back in Eclipse, I could create a PHP project and added my source directory etc. One thing I could not find is to add additional libraries that I need like Phing, Propel etc to build the project. There was no option to add such. One minus point for TruStudio. I could create my build.properties and build.xml file because Eclipse has native support for it. I know it would allow me add all the tasks that Ant supports, not Phing. But because Phing supports many of those similar tasks, I can live with it.

Now as I said, I am using Perforce as my source control, I wanted to add a task for adding source file to source control. Ant has an optional task called P4Add to do this. I wanted to create a similar one for Phing. Doing this is very simple in Phing. I just have to create a new PHP file under task directory with appropriate package structure in place. And then I would define a taskdef in the build.xml and I am ready to use the task. But when I create a PHP file using TruStudio, I found that it created a blank file. No template for PHP. I though I could define one. But no. There is no option to do that. Second and major negative point for TruStduio. Unless somebody tells me how to do that, I think I am done with TruStudio. It's struck out of my list.

The third one I tried is PHPEclipse from phpeclipse.de. It's a plugin like TruStudio for Eclipse. I installed it and so far so good. I could use it and it is fitting into my requirement till now. I could add additional library path for build. There is template defined for new php files. Looks pretty promising to me.

So I think I am gonna stick with PHPEclipse until I find a major shortcoming with it.

Setting it up

So I decided to create an web application for my personal site. After working with Java for so long, at first I decided that I would use java for that. But java seems to be overkill for that. It's not an enterprise level application. It's just an application which is going to be modular and only thing it needs to do is store data in database. Don't mistake me. I like java. But it's heavy-weight for my requirement. I thought why not use PHP- A new language which is looking promising year after year.

With PHP 5 looking more object oriented, I decided I should go ahead and give a try. So far I have done the following:

  1. Downloaded XAMPP package and installed.
  2. For the IDE, I am still toying with Eclipse + PHpEclipse / TruStudio. I have Perforce and eclipse has a nice plugin for it. Plus I am so used to Eclipse.
  3. MySQL as the database server.
  4. Phing to use as build script.
  5. Propel as the persistent layer.

I have not yet started doing anything. But I have the idea of building it the n-tier way. So I am going the same way: adding layers.
Client <-->PHP<-->Propel<-->Creole <-->MySQL

Hopefully this would work out.