Archive for May, 2011

Tip for a SVN project

Monday, May 9th, 2011

Ok, this is the scenario:

There is a huge project hosted on a SVN repo. I’m to start a new project based on that one… No, I’m not allowed to create a new branch. And I must upload this project to a new SVN repo.

So checking out the project is easy. Now that I have the project in my Mac I want to be able to check it into the new SVN repo, the only thing is that when I checked out the project it downloaded to mi machine with a whole bunch of “.svn” folders.

Now, there are 2 different ways to get a clean copy of a project from a repo.

1. Do an export instead of a checkout, this will give you a project copy without the annoying “.svn” folders.

2. Do a regular checkout and then delete all the “.svn” folders.

On my humble opinion it’s better to do an export. If you do a checkout you can delete the “.svn” folders manually but be aware if you have lots of folders because an “.svn” folder will be created within each of your project’s folder so if you have a project with 10 folders and each one with two subfolders you’ll have to go into each f them to delete the “.svn” folders manually… it’s easy but it might take a lot of time and resources you might not have.

To speed up things it’s better to do the following:

Go to your project’s folder and run the following command:

find . -name ".svn" -type d -exec rm -rf {} \;

It will search for all directories called “.svn” and delete them as well as it’s contents.
I found this to be very useful and I really use it frequently but I keep forgetting it so I’m posting it here 😀

Forms and encoding

Sunday, May 8th, 2011

Ok, Zend Framework has lots of components to do almost anything.
One of the coolest is the form component, it reduces the time spent coding a form and it’s validation and you can then reuse the form code wherever you want and it will behave exactly the same.
One thing was annoying me. When in a form element label you use accents the label, once parsed, will display either weird characters or the raw html code.
For example take a look at this code:

            'label'=>'Correo Electrónico*',

I wanted it to read: Correo Electrónico, but instead of ‘ó´it was displaying a weird character or the raw html code for an accented ‘o’ (ó) so I was wondering how can I solve this. It didn’t take me a lot of time to figure this one out, the solution was simple and elegant. When declaring a form element there is a flag that will handle if the label gets escaped or not.

The only thing I did was to change the element declaration from the former to this:

            'label'=>'Correo Electrónico*',

That’s it, it works.
Oh, BTW, I have my encodings set to ‘utf-8’, if you have ‘iso-8859-1’ you may leave your accents without encoding as html.

Zend Server – Mac OS issue with MySQL

Tuesday, May 3rd, 2011

So I finally decided to install a dev env in my Mac.
A couple of days I installed Zend Server on my Mac but I wasn’t too convinced about installling a dev env in my Mac so I uninstalled Zend Server as I thought was the proper way to do it: Drag the Zend Server from apps to the trash.
So yesterday I finally made up my mind and decided to go along with a dev env. Since the first install went smoothly I thought it would only require me to do exactly the same thing…. WRONG!!!!
I downloaded the package and ran the installer, no error messages were displayed, I even opened the Zend Server console and it worked, I even tested a few scripts and it was doing fine.
Next thing I wanted to do was to create a database in MySQL and this is when my headache started.
First time I installed Zend Server I realized it wasn’t enable to work as a network server, by default you can connect to it by a socket which is fine if the server will only run on your machine… Honestly I didn’t have any problems with it… the problem was that apparently MySQL wasn’t working.
Ok, calm down, don’t panic. I thought it had something to do with socket permissions… WRONG!
mmmm ok, what exactly can be the problem?
I opened a console and typed:

sudo [path_to_zend_bin]/ restart

Apache did ok, Zend Server GUI (Lighthttpd) did ok but MySQL didn’t…. it showed the following message:

ERROR! MySQL manager or server PID file could not be found!
Starting MySQL
. ERROR! Manager of pid-file quit without updating file.

What in God’s name does that mean????
I searched it in Google, apparently I’m not the only one experiencing the issue. It looks that there were a lot of different solutions but none of them worked for me :(…. Now I really wanted my Zend Server to work, and I’m stubborn so I kept searching, went to the forums (official MySQL forums) and nothing. By that time I was both mad and sad. I tried deleting files, reinstalling, changing owners and NADA!
Finally, since it was already to late and I was falling asleep I decided to leave it for “tomorrow”.
I even dreamed about this not being solved hahahahaha.
Anyway the next day I relaxed, saw a couple of videos on youtube and finally came up with the most easy solution to this in a blog.
In a few words this meant that me dragging the Zend Server app to the trash can is not the proper way to uninstall it. I have to use the following command:

sudo /usr/local/zend/bin/

It was the only thing I didn’t try so I typed it and hit enter…. this got the job done!!! :O
OMG! it was sooooo simple, I felt stupid hahahahahaha
So I’m posting it here to remember it.