Zend Framework Project .htaccess with exclusion of folders


Options +FollowSymLinks
RewriteEngine on

RewriteRule ^\.htaccess$ - [F]

RewriteRule ^(blog|forum)($|/) - [L]

RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]

RewriteRule ^public/.*$ /public/index.php [NC,L]

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

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

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.