Zend Framework long names for Controller Actions

I started working on Zend Framework some days ago. Recently, I encountered an issue with the Controller actions.

I wanted to have a controller action with name getRecordsByCountryAction in one of my controllers. To my surprise, this did not work despite the fact that it was in accordance with the camel Case convention of naming. 
I spent some hours googling on this issue however could not find the solution, Finally, I found that, the long names will not work as usual short name camel cases. 
The long name has to be accessed using ‘-’ or ‘.’ in the small case words of the action name in browser.
So my action would become ‘get-records-by-country‘ or ‘get.records.by.country‘ when I have to access it from browser. My full url request would be ‘/admin/country/get-records-by-country/country_id/2′
Somewhat confusing! yet working.
Happy PHPing.
Posted in Zend Framework | Leave a comment

My Vacations at McLeod Ganj

Hi,

I just returned from my 2 days short vacations at Dharamshala, McLeodGanj. I really needed a break after so long period of work load and pressure. I with my two friends Anuj Jain (Bonny) and Gaurav Luthra planned the trip on Wednesday.
Posted in Personal | Leave a comment

Creating Apache Virtual hosts in windows vista

On my way to start Zend Framework development, I found that I have to create the virtual host in my windows vista machine. I Googled for this thing and finally got my virtual host ‘zf.local’ working with it document root set to ‘D:/htdocs/zf/public’ Directory (Usually, I create my document host D:/htdocs).

The steps needed to accomplish this task are listed below:

As I decided to have my virtual host name as ‘zf.local’, It was neccessary that I put an entry of the same domain the hosts file, otherwise my browser might have requested my ISP’s DNS server to locate ‘zf.local’. So what I did is I opened my hosts file which is located at ‘C:\windows\system32\drivers\etc\’  folder. I double clicked on that file, I added the line

127.0.0.1  zf.local

I pressed Ctrl+s to save. But to my surprise, notepad gave an error that the file is opened in read-only mode; so changes cannot be saved. What now??

Then the funda of vista permissions came to my mind and then I opened the notepad as administrator (see pic)

So, I opened the notepad as administrator and then browsed to my hosts file which was located at “c:\windows\system32\drivers\etc\” folder. When the file got loaded in the notepad, I added one entry for new hostname  as

127.0.0.1                    zf.local

Saved and quit the notepad. Till this time, I am ready with “http://zf.local” showing my localhost listing in apache. Next, its time to add the different document root for this server name. For this, I had to edit two files

  1. c:\amp\apache\conf\httpd.conf : in this file, the inclusion of vhosts file is commented by default. So I uncommented that line to become “Include conf/extra/httpd-vhosts.conf”
  2. c:\amp\apache\conf\extra\httpd-vhosts.conf : this is the actual file where we will add the virtual hosts entries. I opened the file and put the following para in it

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot “d:/htdocs”
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName zf.local
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot “d:/htdocs/zf/public”
</VirtualHost>

Saved the file and restarted my apache server. And that’s it, I am done.  When I browse “http://localhost”, I am getting the listing of localhost and when I am browsing “http://zf.local”, I am getting the spash screen of Zend Framework which means I am once again successful. :)

Remember that the first virtual host entry is quite important coz without it, “http://zf.local” will show you the zend framework splash screen only and you will never get the “http://localhost” listing.

Thanks to google :)

Keep PHPing

Posted in Uncategorized | Leave a comment

Am Zend Certified Engineer now!

Finally, after an experience of 4 years and hours of studying, I am a Zend Certified Engineer today. The exam is not as tough as I expected, at the same time its not an easy one.  For studying, I would recommend php|architect ZCE study guide. It covers all the topics, But the one book that helped me a in detail and advanced study in PHP5 unleashed from the author ‘John Coggeshall’. He has covered the more details that any book on PHP on the planet may have covered.

Its worth taking this exam as I learnt a lot new things about PHP now.

Find me on Zend yellow pages @ http://www.zend.com/en/store/education/certification/yellow-pages.php#show-ClientCandidateID=ZEND012882

Posted in Uncategorized | Leave a comment

Multiple attachments not going with PHPmailer v5

A bug in the PHPMailer v5 has been stopping me from sending multiple attachments in a mail. It was quite a confusing thing coz it I checked everything in my PHP code time and again. Somehow, after googling for this, i got my answer; it is actually a bug in PHPmailer v5.

This is how I recified the bug.

  1. Open the file class.phpmailer.php
  2. Goto line number 1236
  3. Change
    7=> 0
    to
    7=>count($this->attachment)
  4. Save the file and try.

Thanks for the contributors, it saved my time.

Posted in Uncategorized | Tagged , , | Leave a comment

Planner 0.14.4 complete progress issue

I have been using the Planner for quite a long time. Its a very good software for Project Management and Planning. Over the time many improvements have been made in the project. The latest stable release you can find at http://live.gnome.org/planner is 0.14.4. I upgraded from 0.14.2 on my Vista Laptop. Everything is fine, however a strange thing I noted is that the complete progress of any task does not move beyond 75%. I tried on subtasks and individual tasks, but invain.

Finally, I consulted planner development team regarding this issue and Rhian Geleick guided me the temporary solution for the bug. The solution is

  1. Go to the installtaion directory of planner
    <INSTALL DIR>/share/planner/glade.
  2. Edit the file named ‘task-dialog.glade’ in this directory, in any of the text editors
  3. Goto Line number 236, and change
    <property name=”adjustment”>0 0 100 10 25 25</property>
    To
    <property name=”adjustment”>0 0 100 10 25 0</property>
  4. Anyone using the priority field should should also change line number 257
    From
    <property name=”adjustment”>0 0 9999 1 10 10</property>
    To
    <property name=”adjustment”>0 0 9999 1 10 0</property>
  5. Save the file and then Check in Planner. The bug is rectified.

Thanks for the Planner Team for their timely support.

Posted in Linux | Tagged , , , | Leave a comment

Enable mod_rewrite in apache

If you are using Windows OS and want to enable mod_rewrite module here is how to do it.
This is the general configuration guideline both for Windows and Linux server:

QUOTE

1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound ‘#’ sign from in front of the line)
3. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.

For Windows, find the following section in httpd.conf file:


DocumentRoot "C:/path/to/my/root"

# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# permissions.
#

Now modify the option for AllowOverride to look like this:
<Directory />
Options All
AllowOverride All
</Directory>

Posted in Linux | Tagged , | Leave a comment

Open rar file or Extract rar files under Linux or UNIX

download binary package from official rarlab site:
$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

Untar file
$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:
# cp rar unrar /bin

How to use unrar

unrar command supports various options below are common options that you need to use everyday.

Task: To open rar (unpack) file in current directory type command:

$ unrar e file.rar

Please note that replace file.rar filename with your actual filename.

Task: List (l) file inside rar archive:

$ unrar l file.rar

Task: To extract (x) files with full path type command:

$ unrar x file.rar

(D) To test (t) integrity of archive, file type command:
$ unrar t file.rar

Posted in Linux | Tagged , | Leave a comment

PHP 5.3 upgrade in Centos 5.3

I’ve finally figured out a way to install PHP 5.2.x instead of PHP 5.1 which installs on CentOS 5.3 by default. I’ve wanted to use phpMyAdmin 3.x but could not because of this. Now I can, and if you keep reading you will too. Note if you follow this how-to and do everything correctly you won’t even loose your current database. But I highly recommend you backup your database before you proceed.

 

## First lets download this following repositories:
<code>

 

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm

 

</code>

 

## Lets remove old MySQL 5, will install newer version later.
yum remove mysql

 

## Now lets install them:
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

 

## OK, Now you should be able to install PHP 5.2.9 without a problem =)
yum –enablerepo=remi update php-cli
OR
yum –enablerepo=remi update php*

 

## Now install MySQL
yum –enablerepo=remi install mysql mysql-server
chkconfig -levels 235 mysqld on
service mysqld start

 

If you get the following error when you try starting newly installed MySQL;
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

 

## Now install PHP-MySQL module
yum –enablerepo=remi install php-mysql

 

1. Try restarting your web server;
service lighttpd restart
or
service httpd restart

 

2. Type this command:
cd /

 

3. Restart your mysql server;
service mysqld restart

 

## Set root and hostname passwords
mysqladmin -u root password ‘new_pass_here’
mysqladmin -h server.yourdomain.com -u root password ‘new_pass_here’

 

When it asks you to import signature, do it. press y and hit enter. It should ask you twice.

 

I use the first one because I don’t have Apache Web Server, I use LightTPD.

 

## Now run update on your system.
yum –enablerepo=remi update

 

 

Posted in Linux | Tagged , , , | 1 Comment

How to setup a Subversion Repository for PHP Development

Being a PHP developer and a System Administrator, Setting up the development environment and Development both are my Key Responsibilities. For years, I have been away from the Source control, but as you grow, your needs also grow to get more managed and secure.

One fine day, I went through the process of version control in PHP basically Subversion. Initially, the idea sounded very good, however, a new issue came to my mind that although, the source code will be version controlled, yet, how the actual work done by the developers will be previewed?

Suppose I have some code that is not under source control system. The project is located at
“/var/www/html/x”

I have a common svn repository location at
“/var/svn/”, so Project x svn repository will be “/var/svn/x”

For achieving this, I follow these instructions

#svnadmin create /var/svn/x
#cd /var/www/x
#svn import file:///var/svn/x -m "Initial Import"
#cd /var/svn/x/conf
#vi svnserve.conf

Write these lines in this file

[general]
anon-access = none
auth-access = write
password-db = passwd

Save and Exit the vi editor

#vi passwd

Add these lines in this file.

[users]
anil = konsal

save and exit the vi editor

#cd /var/www/html
#mkdir x
#svn checkout svn://127.0.0.1/var/svn/x x
#cd /var/svn/x/hooks
#cp post-commit.tmpl post-commit
#chmod 755 post-commit
#vi post-commit

Goto the end of file

and write

/usr/bin/svn update /var/www/html/x

Save and quit vi

#cd ..
#mkdir logs
#touch logs/post-commit.log
#chown -Rv apache.root /var/svn/x

Posted in Subversion | Tagged | Leave a comment