Cogito, ergo sum

Here's hoping my musings can help you out!

Archive for October, 2008

Stewart and Colbert Vs. Hannity

Posted by mnshankar on October 29, 2008

I have never liked Hannity. I seriously do not know why anyone would support him/call into his radio program. Such a waste of airwaves!

Here is a video exposing Colbert’s genius.. Enjoy!

http://www.newshounds.us/2008/06/21/stephen_colbert_ridicules_hannity.php

I just had to share this video accurately depicting Hannity’s interviewing skills!

http://www.comedycentral.com/videos/index.jhtml?videoId=185184

Posted in News and politics | Leave a Comment »

404 Error due to .htaccess file

Posted by mnshankar on October 27, 2008

On my work computer (development), I have Windows, Apache, Mysql, PHP setup to run Zend Framework. For the life of me I could not understand why my .htaccess file was failing to route requests properly, even though I followed all the instructions exactly (including setting AllowOverrides=All, ensuring mod_rewrite was loaded etc).

I was using an Alias block in my .httpd file to use a different virtual directory

Alias /myweb "C:\web\myweb\htdocs"
<Directory "C:\web\myweb\htdocs">      
    Options Indexes FollowSymLinks MultiViews ExecCGI      
    AllowOverride All      
    Order allow,deny      
    Allow from all
</Directory> 

The .htaccess file in my C:\web\myweb\htdocs folder was:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^.*$ index.php [NC,L]

All redirects were resulting in a 404 (Page Not Found) error. After lots of trial and error, I found out that the error was due to a missing RewriteBase directive!

The following htaccess file fixed the problem

RewriteEngine On
RewriteBase /myweb
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Posted in Zend Framework | Leave a Comment »

fastcgi.impersonate

Posted by mnshankar on October 26, 2008

I just discovered that there is a setting in PHP.ini that makes web folder access rights in Vista/IIS7/PHP a breeze! Open php.ini and look for the setting fastcgi.impersonate. Set it to 1 (Uncomment it if the line already exists)

fastcgi.impersonate = 1;

Restart the web server.

This directive enables PHP applications on Windows to impersonate the authenticated user making the request enabling PHP scripts to execute as that user (and not as an IIS process).

Once this is done, you do not need to add the IIS_IUSRS group to every folder that you want IIS to access! Yeah!

Posted in Zend Framework | Tagged: , | Leave a Comment »

Zend_Session Error (ps_files_cleanup_dir)

Posted by mnshankar on October 26, 2008

While running your Zend Framework application, if you receive an error that looks like :

Zend_Session::start() – D:\Web\library\Zend\Session.php(Line:426): Error #8 session_start() [function.session-start]: ps_files_cleanup_dir: opendir(C:\Windows\TEMP\) failed: No such file or directory (2) Array

The solution is:

1. Edit your php.ini file and set your save_path variable to a physical folder on your computer
session.save_path = “D:\Web\session”

2. Remember to give the IIS_IUSRS builtin group R/W permission to the folder

3. Restart the webserver

Posted in Zend Framework | Tagged: , | Leave a Comment »

Zend Studio – Turning on Autocomplete for an imported project (Zend Framework)

Posted by mnshankar on October 18, 2008

 

One of the best benefits of using Zend Studio for your Zend Framework project is getting the autocomplete feature. However, when you import an existing project (using ‘import’->’existing projects into workspace’, the feature does not get turned on.

Here’s how you can get it working:

1. Create a new PHP project

image

Give the project a name (and a new directory)

image

On hitting the Next button, you will be prompted for the PHP include path libraries. Select Framework_1_6

image

image

Now, a PHP project that is linked to the Zend Framework libraries is created..Right click on the folder and select ‘Import’

image

Select the ‘File System’ option

image

Navigate to the folder that contains the files and folders that you want. Check the entire root folder

image

Voila.. you now will now have autocomplete and tooltip help on all Zend framework components!

image

Posted in Zend Framework | Leave a Comment »

Granting ‘Write’ permissions in IIS(7)

Posted by mnshankar on October 18, 2008

Often times you may need to grant the web server ’Write’ or ‘Modify’ access to folders (for logging, loading files, creating graphics etc). The way to do that is to grant the required permissions at the folder level to the GROUP that the default IIS user belongs to.

The default built in GROUP under which the IIS process runs (in IIS 7) is IIS_IUSRS.

Bring up the properties of the folder (right click+properties). Click on the ‘Security tab’:

image

If you do not have the IIS-IUSRS group in the ‘group or user names’ list, click on the ‘Edit’ button and then the ‘Add’ button. Type in iis_iusrs in the object name field and hit the “Check Names” button:

image

Then, make sure that the ‘Modify’ and ‘Write’ permissions for the IIS_IUSRS group is checked..Hit the ok button when done.

image

Posted in Computers and Internet | Tagged: , , | Leave a Comment »

The PDO extension is required for this adapter but the extension is not loaded

Posted by mnshankar on October 12, 2008

 

This error (thrown by Zend Framework) indicates that your php.ini file is not yet ready for Zend_Db. The fix is easy:

  1. Open php.ini
  2. uncomment the line
    extension=php_pdo.dll
  3. uncomment the line (depending on the database you are using)
    extension=php_pdo_mysql.dll
  4. Restart your webserver and reload the page in question

The error should be resolved :-)

Posted in Zend Framework | Leave a Comment »

htaccess equivalent (Zend Framework with IIS7)

Posted by mnshankar on October 12, 2008

The Zend Framework relies on a web directive to redirect ALL requests to an index.php page. On an apache server, this is fairly easy to implement using the following statements in a .htaccess file in the public facing folder:

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php

A new feature in IIS7 called ‘URL Rewrite’ makes this easy to realize on WIMP/WISP setups. The GoLive (Production) version of the plugin is available here:

(X86)http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1691
(X64)http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1692

The plugin provides a really neat feature to directly import and convert well formed .htaccess files into their IIS equivalents. Using your IIS manager, navigate to the virtual folder (pointing to your public facing folder). Click on the ‘URL Rewrite’ plugin and then the "Open Feature" option.

UrlRewrite1

Now, click on the "Import Rules" option

Rewrite_import

In the dialog box that appears, select the .htaccess file saved on your computer and click on the "Import" button.

rewrite_select

If all goes well, the equivalent IIS rewrite rules will be created! The above procedure actually creates a web.config file in your public folder that looks like the following (Note that you can actually just copy this web.config to your folder instead of going through the above steps):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Imported Rule 1">
                    <match url="\.(js|ico|gif|jpg|png|css)$" negate="true" ignoreCase="false" />
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Posted in Zend Framework | Leave a Comment »