Good Resources – PHP Advent 2009

The PHP Advent Calendar 2009 is going on, and it is a tremendous resource for the community. http://phpadvent.org/2009 I highly suggest subscribing to the feed, and/or following on Twitter. It is a great read every day.

0 Comments

GBP and Euro Symbols in Excel

Have you used the Spreadsheet_Excel_Writer PEAR package to output data to a spreadsheet? In this data that is being exported, have you needed to format the data? What about numbers, and then formatting further to a currency format. The currency formats for this data: one for Great British Pounds (£) and one for the Euro (€). The formatting needs to happen with those symbols. So here is the journey . . .

Since this post is not about the querying of the data, that is not going to be covered, but rather just the issues with formatting the currency symbols for Euro and GBP in the Writer. And since this is not about the Spreadsheet writer ins and outs, if you would like to know more about that, please see Package Information: Spreadsheet_Excel_Writer
(more…)

4 Comments

PEAR and CakePHP

This post is about my experience with loading in PEAR to a CakePHP 1.2.x application. This may be the right way or the wrong way, but I got it to work throughout the application. I had to do some changes, and if there is a better way of doing this, please let me know.

First off, here is the issue. I needed to be able to export a group of records from the database to an excel spreadsheet. I have tried to use the Excel Spreadsheet add in that is listed on the Bakery. It works nice, and I had to do some modification for 1.2, but it worked. But not the way I wanted it. I have used the PEAR library Spreadsheet_Excel_Writer before and I like the type of control that I wanted, over the cells, the formatting, the merging, etc etc etc. It provides the type of control that I wanted. So here is what I did to get this to work with the CakePHP framework.

First, I have to download the PEAR library and the Spreadsheet_Excel_Writer libraries to use. Since I use a local system to help develop, I could download these libraries to the local system and transport these over to the CakePHP application. So I went to PEAR site to get the libraries. To download these I ran the following commands:

pear install PEAR-1.8.1
pear install OLE-1.0.0RC1
pear install Spreadsheet_Excel_Writer-0.9.1

URL’s are listed below:
http://pear.php.net/package/PEAR/download
http://pear.php.net/package/Spreadsheet_Excel_Writer/download
http://pear.php.net/package/OLE/download
(more…)

17 Comments

First Note of May

Today is the first of May. There is a ton of things that can be done for May. I am working on a few special projects, and hopefully will have some good stuff out there for the local small businesses around here. I am hoping to get back to work…

0 Comments

Apple iPhone Development

Just a quick post here. Not a lot of time to do anything really earth shattering in this post. I have recently purchased a book to help me start to code some apps for the iPhone and iPod Touch. I am starting out slow, then going to work my way…

0 Comments

Quick note about change

Just a quick note about the change. Needed a change to the site. So I downloaded a good theme, and changed a couple things about it. More of a minimalist approach, not as gimmicky as the old theme, and is a whole lot more "neutral" in color. Hopefully it will…

0 Comments

Regular Expressions

Here is a topic that has really flustered a lot of developers. Regular expressions is a concept that can be hard to get a real handle on. PHP has a couple of functions that can help do regular expressions. The one I focus on most is using the function:
preg_match()

This is a very useful tool, and if you look at the PHP manual for ereg(), it states that the function “preg_match” is a faster alternative to “ereg()”. Now while I am not going to get into the details of the speed and response times for both functions, as there will always be someone with a different opinion or case that shows how their way is better, and that is fine. What most people have a hard time dealing with is getting the actual match to do what is needed. There are times when It is just easier to do a Google search and get some code that someone else has already done and plug it in. But the real power is knowing what you are doing first, that way you can build your own.

For this example, we can take a look at CakePHP’s own little validation object. When you set up a model and add some validation to it, it calls this object. Based on the data that this going into the tables, it will call one of these functions. The way these functions work is by checking the input for a specific character list/set that should be contained in the text. If the entry does not match up, then it is not validated. The way CakePHp does this is by using the preg_match() function.
(more…)

0 Comments

Ideas to help code

I have caught myself doing this often, and need to always regroup and figure out what is a better way to do these types of things. I am speaking of coding in absolutes. What does this mean? Coding a type of block that is hard set to do something exactly. Like for an example, let’s say that there is a calendar application. In this calendar application, there are four languages to select from, so a code block does something like this:

// Controller file
$eng = $this->Users->Select("language", "English");
$spn = $this->Users->Select("language", "Spanish");
$gmn = $this->Users->Select("language", "German");
$fre = $this->Users->Select("language", "French");

**Note this is not using any kind of construct in CakePHP, Symfony or any particular framework, just an example of a User class with a function called Select passing in 2 variables.

As an example, the view of this same code may be something like:

// Controller File
$this->set('lang', array($eng, $spn, $gmn, $fre);

Now while this may work for the time being, it could cause a hassle later on if there are more languages that the application will need to support.
(more…)

0 Comments

CakePHP and Symfony

There are many frameworks out there that have a good deal of uses to them. In this post, the focus is on CakePHP vs Symfony. Does this mean one will be a winner over the other? Not really. I will only present what I have come to find in each of these frameworks and how I have used them in different ways.

Since this will be a comparison, most of the ideas will revolve around the tutorials that each camp has created. Plus, I will be only looking at the latest stable versions, so they are:
CakePHP: 1.2.1.8004
Symfony: 1.2

Each have their own tutorials, and they are at the following:
Symfony: Jobeet Tutorial, using Propel.
CakePHP: CakePHP Blog

First off, about the tutorials.
I really do think that Symfony has a better tutorial. It is a lot more intensive and sometimes confusing, which means it also goes more in depth about what this framework can do, and how to do it. This tutorial also brings in a good deal of real world dilemmas.

CakePHP’s blog tutorial is just a standard blog tutorial, which everyone seems to have anymore. It is a good tutorial, and it does show off some real good aspects of the framework, but it really does lack some of the “gotchas” that would really happen in the real world.
(more…)

12 Comments

Non Code Code

We all get to a point in the coding process where there needs to be "non-code" code. This does not have the same type of structure or verbiage as the construct of PHP, C# or anything else. This is our own little distinct code. It may seem like I am…

1 Comment