Text

Please don’t create something that uses PEAR

This weekend I was looking into testing PHP code and wanted to try out some libraries. After looking around I decided PHPUnit, SimpleTest and Testify where looking nice.

Testify has great looks and is very simple, but licensed under GPL and I don’t want to GPL every project where I drop the Testify projectfiles into. So Testify is out.

Then I looked into SimpleTest. Installation was a breeze, just dropped the files into my project. Read some “Getting started” docs and I was running some tests. Nice!

But then I was reading a lot of people complaining that SimpleTest is way behind PHPUnit. So I decided to try out PHPUnit and was surprised that they already advice to use PHP 5.4 with their newest version. Great! Lets install it!

The installation guide told me to use PEAR, I didn’t have PEAR installed on my Mac so needed to install it. There was a link to the PEAR install guide, I followed it and it wanted to install PEAR into my home folder. Not a good idea, so time to Google.

Then I found that there was already an installer on my Mac. I runned it and now I have PEAR. Nice!

Next step; Run the installation commands for PHPUnit. Some output on the console and everything seemed fine. Well, not too bad!

But when I wanted to run the test PHPUnit threw a bunch of errors on me. Not cool! Looking up these errors on Google showed not a really clear solution, but after combining some StackOverflow posts I tried to add a include path in my php.ini. So I added:

include_path = /usr/lib/php/pear/

to my php.ini and tried again. It worked, finally time to some real testing!

PHPUnit looks great, nice features and good docs, but I’m not looking forward to ask my co-workers to install PHPUnit using PEAR. Every time I have to use PEAR (and yes, I’ve used it before to install some extensions) it guarantees troubles. Always some strange errors you have to solve.

So if you have a choice when creating a library, please create something that’s just a drop in library and do not make a PEAR based library/tool.

Text

Idea: Domain name as a easy to remember phonenumber

Phone numbers are hard to remember, you have to save them in your phone to make sure you can reach your friends and important companies again. You can’t guess a phone number, the numbers are just random. That’s quite annoying if you need to call your bank or another company you don’t call often and haven’t saved in your phonebook.

Nowadays phones are connected to the internet and mostly I lookup a phone number on the company website or check if someone mailed their phone number to me if I need to call them. But it would be way easier if I could call them on their domain name instead of first surfing to a domainname to look up the phone number.

I think this would be great, especially when calling a company, that I could reach them by just punching in their domain. Need to get PayPal support? Just call paypal.com and there you are. Never look up a phone number again.

We could implement this in the DNS system that is already used to look up where to send email and where to find the webserver for a domain. With subdomains you can give different people/departments their own “phonenumber”, call sales.paypal.com to get a sales person or call home.mathijskadijk.nl to call me on my landline at home.

I hope something like this will once be implemented, I think it would be great and will make calling someone just a bit easier.

Text

Custom font and special characters in TCPDF

Summary: When using TCPDF (or any other PHP PDF library) use this website to convert your fonts when you have troubles with special characters.

For a client project we have to generate a lot of PDF files. At first we used DOMPDF, but it was painfully slow (taking up to 10 minutes for a ~30 page document) and driving us crazy with the incorrect rendering of special characters like ß, € (euro sign) and £ (pound sign).

So we decided to rewrite the whole PDF part of our webapp with the TCPDF library. This made the generation a lot faster! (12.5 seconds now vs. 10 minutes with DOMPDF) On MacOS X with preview the special characters where also looking good, even with a custom font like MyriadPro. Great!

But when we tested the PDFs in Windows with Acrobat Reader all the special where going crazy once again. The width of the characters seemed to be interpreted as 0, so everything around this characters was printed right on top of the special character.

After searching for a while I found a Stack Overflow question asking why the pound sign wouldn’t show up when using a custom font with TCPDF. It seemed a lot like my problem and the first answer was spot on.

When converting your font with the TCPDF addFont-methods it is possible that there is going something wrong and the special characters won’t work correctly. For me using this free and easy font-convert website did the trick. I threw my fonts at it and it converted them perfectly. All the problems disappeared at once.

Note that you must fill in the “final name wanted” with care! For “Myriad Pro bold” I had to use the fontname “myriadprob” for regular it is just “myriadpro”, italic is “myriadproi” etc. Without the proper names TCPDF will not recognize your fontfiles!

Hope this will save you some time and a lot of frustration. :)

Text

XCode build button disabled

Just a moment ago I was coding on a Mac App new project in XCode and after renaming some folders I wasn’t able to build my project anymore. The “Build and Run” button in XCode was disabled and all other build related actions like “Clean” and “Build and Archive” were disabled also.

Just reverting the changes in the folders did not fix my problem. It took some time before I figured how I could fix this, so I’ll post it here as a reminder for myself and hopefully it will help other people with the same problem!

Fixing it is really simple:

  1. Open the “Project” menu from the menubar
  2. Choose “Manage Schemes…”
  3. Your corrupt scheme should be in red, remove it
  4. Click the “Autocreate Schemes Now” button
  5. Done!

After this you should be able to build again!

Text

More and updated iPhone libraries/frameworks

ASIHTTPRequest died, so on to AFNetworking!

My previous post was about 4 nice libs/things about iPhone development. About a day after that post I read a post on the ASIHTTPRequest authors blog where he tells the world he won’t update ASI anymore. Too bad, but he “killed” ASI for a good reason I think.

Anyway, I needed a new shiny networking lib and I found it. AFNetworking from the Gowalla people is the new thing. It’s simple, elegant and powerfull, but only iOS 4+. It’s really worth checking it out and if you don’t need to support iOS 3 you should use it. I personally love the build in support for parsing JSON responses.

The only thing that seems missing is really good caching, but I have to look into that further and it’s developed at quite fast. So I think that problem will be solved shortly!

CoreData made easy; MagicalRecord

Then there is a little gem I found for all of us using CoreData. (Discovered it on Twitter, because Thomas Fuchs did tweet about it.) MagicalRecord will make basic fetching operations way easier and provides an easy way to customize NSFetchRequests when needed.

Knowledge on how CoreData works is still needed, especially for the somewhat more complicated things. But it makes fetching/counting all object literally a oneliner. A must have!

AQGridView; For all your grids :)

Last but not least an library I forgot to mention in my previous post. AQGridView, a wonderful UITableView-like class that you can use to create gridviews on the iPad. Really simple and nice to use. You should check it out and use it whenever you need to display stuff on a grid!