Learning PHP after years of Java

April 17, 2010
 by 

Its been nearly 6 months since my new gig as a lead engineer at Transpond and I havent posted anything about software or much of anything else for that matter. I’ve been busy with many other projects as well as learning and writing PHP. Well, mostly writing as the learning curve isnt bad at all. The more I was able to block Java and what I know of it out of my mind the faster I was able to learn PHP.


Anyway, there are tons of books and blog posts about how to write PHP so Im not going to go into that. What I have compiled though is a list of things that helped me get over the hump. Although Java and PHP have a lot of similarities, their life cycles are different. Here are the things the differences that stood out the most in my mind.

Classes

Now that PHP is fully object oriented we can use classes as well as objects. Lots of new open source projects out there seem to take advantage of them; however, a lot do not, especially older ones. What I find to be very common throughout PHP are the untyped array objects with lots of nested arrays. This appears to be very standard. The sooner you get over this fact the sooner you will be able to code. The point of a dynamic language is to be able to build quickly and not deal with POJO’s.

Instantiation

Just like Java, classes in PHP have constructors and even destructors; however, they are not declared as you may think. You will need to use the special notation for these functions, __construct and __destruct respectively. Also, be careful when building more complicated stacks or frameworks. Objects get destructed at unusual points in a requests lifecycle so getting your debugger running can come in handy.


What is also interesting is that classes cannot be static in the way we would normally think about them. You can make a class that has all static methods which effectively makes a class static but you cannot use the static keyword for a class declaration.

Imports (require or include in PHP terms)

Unlike Java, PHP is file based not package based. This makes for some interesting issues at first. Trying to grok this idea and deal with file paths can be daunting. What we found to be helpful was name spacing which is somewhat recent to PHP. We use that in conjunction with __autoload() which makes class loading very simple. Essentially we can dynamically load classes easily based on their namespaces and not their file location as much (our autoloader handles that).

Methods, functions, and void (or lack thereof)

As you probably already noticed, methods are called functions. These function do not need to declare what type of object they will return, as this is a dynamic language. In fact, the same method could return nothing (void), and object, or a string. This puts the burden of good engineering on the caller.


Functions in PHP (methods in Java) are however similar in the way they are declared. They can have public, private, and protected declarations, as well as static, abstract, and final keywords. This makes the transition from Java pretty simple, however; there is something strange I noticed. Member variables cannot have the final declaration which I find to be frustrating but there are obvious ways around it. The main reason for this being, most objects are passed by value so modifying a member variable is harder than in Java. I will go into this more later.

Conclusions

So far I am really enjoying PHP. The environment is very simple and straightforward, there is a ton of support for it, and there is a plethora of open source projects to choose from. All of this makes for a quick development time and a quick ramp up time. As I mentioned before, the sooner I stopped thinking about how Java worked, the sooner I was about to pickup PHP.


Building a workshop workbench

January 19, 2010
 by 

Every shop needs a good workbench and its about time I built myself one. I sourced most of the parts locally from the $75 solid maple butcher block top to the $40 shelves with drawers I got at a local salvage yard. The only things I bought new were the three Rockler vises which I have yet to install. The picture above is of everything all mocked up.

I have assembled the bottom section out of 4×4′s and 2×4′s secured with long galvanized deck screws. The base frame itself is 45″ long and 23″ deep. The butcher block will overhang 3″ on the front and back, and 12″ and 18″ respectively on the left and right. This will accommodate the vice setup I will be installing but I will post more on that when its complete. For now, you can see more pictures by clicking on the image above.


Flintstones art car is coming together

August 18, 2009
 by 

With Burning Man less than two weeks away my buddy Aaron and I are getting close to completion. All the finish work adds up but its the most exciting part. All the details are what makes this car authentic. Just recently Aaron finished rounding and staining the canopy supports and I finished rewiring the thing. All the seats are now upholstered and I just finished painting on the faux stone on the car.

In the picture above you can see that we now working the side logs what I think we have figured out. Below you can see all the switches and lights. We hollowed out bones to cover the switches and shells cover the indicators but glow at night.

For more pictures check out my Flickr page.


Restoring a victorian staircase

August 10, 2009
 by 

This week my father flew to San Francisco to help me, and teach me, to build a banister and repair a staircase. We tore down the wall that used to be there, replaced all the treads, and put in a matching banister and railing that we copied from the upstairs banister. For the past five days of the build I have been blogging over on SanFranVic.com where you can follow the story and see all the photos.


Building a maple recycling center

July 19, 2009
 by 

Since space is always at a premium, especially in my kitchen, its important to use every inch as best as possible. Instead of having two separate trash bins it made more sense to combine them into one piece of furniture and gain table top space. So I searched the internet to find something that would fit but unfortunately nothing came up. So it was off to the shop to solve the problem.

With the help of my roommate, we built this trash and recycling center out of maple plywood using simple dowel joinery. We finished it in a cabernet color and added some simple hardware like magnetic latches and handles from our local hardware store. All in all the project only took a few hours total and solved a big problem.


Lighting for my friends wedding

July 6, 2009
 by 

My long time friend Caroline and her fiance Regan asked my housemate Brian and I to do the lighting for their wedding because they had seen our renovation work on sanfranvic.com. We were both honored and excited to help out. Not only did it save them thousands of dollars from hiring a lighting expert it allowed us to give them something they will always remember.

The light array was pretty simple and only took a few hours to setup. We hung up five strands of 32 foot strings of ping pong ball lights from the reception house to a rope 10 feet up that we ran parallel to the house. That rope was held up by two pieces of 10′ galvanized steel conduit that was anchored to the ground with a few pieces of rope and some stakes. The hard part was just getting the lights up and taught so they were high above everyones head. I’m happy to say that even after the storm that came through they still stayed up and everything went off without a hitch.

I’d like to thank Caroline and Regan for having me and I was honored to be a part of your wedding. I was happy to help and even happier to give you a present that you’ll always remember and cant be returned. It was a great time and something I wont soon forget.


Flintstones themed art car for Burning Man

June 16, 2009
 by 

This year, my friend and campmate Aaron and I decided to take our skills and build something for ourselves, on top of our usual Duck Pond duties. We had been talking about an art car for a while and my friends old one just kinda fell into our lap. Above you can see a picture of what we are working with.

We bought this cart as well as a trailer with benches on it that was setup to hold about 6 to 8 people. It was owned and operated by my friend Andy under the name ‘Liberace’. It’s seen many trips to the playa with them and before that it was owned by someone in the Space Cowboys. Pictures of its past life can be seen here on Flickr.

The cart is of an unknown manufacturer, displacement, and any real history. All names and logos are long gone and stripped off. What I do I know is its a simple bidirectional 2-stroke motor with a small single barrel carburetor and a centrifugal drive mechanism. The part I found strange was that there is no idle. When you lift your foot from the gas the motor turns off. Just as well, its more environmentally friendly and wastes less gas. Nevertheless, I’m pretty happy with it as it is a simple drive mechanism and much easier than the car I usually work on.

The inspiration

As you can see from the picture above its a pretty uninspired looking cart. Rather than slap some color and fur on it and call it a day, we wanted to create something different with a lot of attention to detail. Something that would grab the attention of passerby’s on the Playa. The Flintstones idea, like many good ideas, came to us out the blue when we were thinking of other ideas.

The picture above is our inspiration photo. I found it on one of my favorite maker sites, instructables.com. A family had made it for their kid and its a perfect jumping off point for us to follow. I also got the ideas for the fake wooden side rails made of foam from them. The article can be found here.

The idea

As I mentioned before, our idea is to be very authentic and detailed. We are using real bones for handles, twine to hide modern bolts or materials, and all of our electronics will be hidden. We are also using real wood and branches wherever possible to complete the look. Below is a sketch of the vehicle.

(click image to see a larger version)

Our car is going to be mostly operating without the trailer behind it. Although we will take it out from time to time, its mostly a personal transport/ice hauling vehicle. On the back, we will have a bench seat and removable foot rest for when we are not using the trailer; however, when the trailer is in use we will remove it and not allow people to sit back there as it is dangerous. For more pictures of the trailer please see my Flickr page.

The most complicated part of our project is going to be the wooden canopy. Not only is it going to be tough to turn 4×4 square pieces of wood into round looking branches, we will need a lot of support structure. We are going to be bolting the canopy into the frame rails as well as using metal pipe to support the heavier components of the canopy.

(click image to see a larger version)

Once the final structure is said and done, we will wrap all the joints and cover all metal pieces with twine to keep the look authentic. And of course we will have a burlap white canopy to shield us from the sun.

Our next challenge will be to add modern electronics without having them show and ruin the look we are going for. We are going to be adding a small 50-or-so-watt stereo and speakers in the dash as well as some other lights and switches. Below is a sketch of the fake slate dashboard we will be building.

(click image to see a larger version)

The trailer

Below is a photo of the trailer. It can hold three people on each of the side benches and two on the back bench. Time permitting we are going to tackle the redesign of it but as of now we have our hands full. Luckily for us its fully operational and ready to go, it just needs more lighting.

The lighting

We do plan on driving at night so we will clearly illuminate our car and trailer. We plan on having a few different types of lighting. The first and most blatant for safety will be amber lights underneath the car on all sides. Not only will it help others see us, it will us to get on and off. The second type of lighting will be under-canopy lighting that will be red to allow us to see while others will be able to see us. I feel that should be enough; however, we are planning on creating some lanterns with dim little flicker bulbs hanging off the canopy and maybe on the front to really help complete the look.

Our trailer will also be equipped with lighting in the case we want to take our friends out at night. It barely had lighting when we got it from our friend other than the rear red running lights. We will add amber underneath/side lights to clearly illuminate the ground below which will help us be seen. Also this will aid in our passengers ability to safely get on and off.

The conclusion

As I’ve said before, when all is said and done we want this car to be true to the theme and interesting to look at out at Burning Man. We are even creating Flintstone character costumes to complete the look. We are not just creating a transport vehicle, we are creating something interesting and artistic, melding form and function and contributing back to the community.

(Follow up post, Flintstones art car is coming together)


New headers and exhaust for the 2002

May 21, 2009
 by 

Finally, after redoing my engine, fuel and air delivery, and spark management I have gotten around to putting on a set of step headers to help the motor breathe a little harder. Since I have 4 individual throttle bodies its only fitting that I let that air get out of the motor faster as well. Also, it will help the engine run a little cooler.

Putting the headers on wasn’t all that hard although it was tricky at first getting them to fit around the tie rods. The trick was to turn the wheels all the way to left and they slid right past. Other than that, fitting the exhaust was real chore! I have always had problems with it rubbing on my rear subframe so this time I was determined to get it right. It probably took 2 or 3 different times taking it on and off after driving it around only to find that something was still rubbing. In the end, what worked best was fitting the exhaust from the collector back, fitting it just right, taking it off and pounding it place so there was no chance of movement. After a few hours of work and help from my house mate it was perfect.

Since I have installed it I have noticed a few things. First off my low end torque has improved. Not by a lot but definitely noticeable. Also, the high end power feels quite improved as well. Once I pass 4k it really screams. Finally, I have noticed my coolant temperature being much lower throughout different duty cycles. Overall, a great buy and a noticeable difference. Thanks again to Ireland Engineering for their great parts.


Gigabit Ethernet for your home

March 9, 2009
 by 

Its always been my dream to have an automated house and the first step is hardwired Ethernet. Whether you are going to be running video over Ethernet, VoIP, or just the good old Internet you really just cant beat copper. Although wireless has come a long way since 802.11b it will just never keep up. Besides the fact that copper performs flawlessly and extremely fast, there are no reliability issues that you inevitably run into while using on WiFi. If anyone out there reading has found a perfect WiFi Access Point that can run at gigabit speeds for hours at a time with 5 – 10 devices on it please let me know. It would have saved me a lot of trouble!


For the full writeup with tons of pictures please see my post Wiring For High Speed Ethernet on San Fran Vic.


Copyright © 2005-2011 John Clarke Mills

Wordpress theme is open source and available on github.