Pretty URLS in Yii

February 4, 2010

Pretty URLS are easy to read and helpful in SEO.

To take the benefits of pretty urls in Yii, please follow the below guidelines:

1) Open “main.php” configuration file of Yii.

It is located under your_application/protected/config/ folder

2) Paste the below lines in  “components” array

‘urlManager’=>array(‘urlFormat’=>’path’, ‘showScriptName’=>false,),

3) Create “.htaccess” file in your application where “index.php” file is located

Add following lines to “.htaccess” file :

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

4) If your application is not showing pretty urls, then check whether your Apache configuration file i.e httpd.conf has the following module :

LoadModule rewrite_module modules/mod_rewrite.so

Remove “;” semicolon preceding the above line.

Save and restart the Apache server

Installing Yii in wamp on Windows XP

February 3, 2010

I was successful in installing Yii  in wamp on Windows XP .

The versions are as follows:

Operating System : Windows XP Professional Version 2002 , Service Pack 2

Apache : 2.2.8

PHP : 5.2.6

MYSQL : 5.0.51b

Yii : 1.1.0 (January 10 2010)

Follow the following steps for installation:

1) Click on “Start”

2) goto “My Computer”

3) Right Click and select Properties

4) You will see “System Properties” window

5)  Select “Advanced”tab

6) In “Advanced” tab, click on “Environment Variables”

7) Select “Path” in “System Variables” section

8) Click on “Edit” on selevtion “Path” in “System Variables” section

9) “Edit System Varibale” window will appear with “Variable name” and “Variable value” fields

10)  Enter “C:\wamp\bin\php\php5.2.6” at the end without double quotes.

11)  Click on OK, OK and OK.

13) Click on Start > Run > cmd

14) It will take you to the command prompt

15) C:\>cd wamp\www

16) C:\wamp\www>mkdir myYii  (myYii is the name of the application you want)

17) C:\wamp\www>cd yii\framework

18) C:\wamp\www\yii\framework> yiic webapp c:\wamp\www\myYii
Create a Web application under ‘C:\wamp\www\myYii’? [Yes|No] y
mkdir C:/wamp/www/myYii/assets
mkdir C:/wamp/www/myYii/css
generate css/bg.gif
generate css/form.css
generate css/ie.css
generate css/main.css
generate css/print.css
generate css/screen.css
mkdir C:/wamp/www/myYii/images
generate index-test.php
generate index.php
mkdir C:/wamp/www/myYii/protected
generate protected/.htaccess
mkdir C:/wamp/www/myYii/protected/commands
mkdir C:/wamp/www/myYii/protected/commands/shell
mkdir C:/wamp/www/myYii/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir C:/wamp/www/myYii/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir C:/wamp/www/myYii/protected/controllers
generate protected/controllers/SiteController.php
mkdir C:/wamp/www/myYii/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir C:/wamp/www/myYii/protected/extensions
mkdir C:/wamp/www/myYii/protected/messages
mkdir C:/wamp/www/myYii/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir C:/wamp/www/myYii/protected/runtime
mkdir C:/wamp/www/myYii/protected/tests
generate protected/tests/bootstrap.php
mkdir C:/wamp/www/myYii/protected/tests/fixtures
mkdir C:/wamp/www/myYii/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir C:/wamp/www/myYii/protected/tests/report
mkdir C:/wamp/www/myYii/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir C:/wamp/www/myYii/protected/views
mkdir C:/wamp/www/myYii/protected/views/layouts
generate protected/views/layouts/main.php
mkdir C:/wamp/www/myYii/protected/views/site
generate protected/views/site/contact.php
generate protected/views/site/error.php
generate protected/views/site/index.php
generate protected/views/site/login.php
mkdir C:/wamp/www/myYii/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir C:/wamp/www/myYii/themes
mkdir C:/wamp/www/myYii/themes/classic
mkdir C:/wamp/www/myYii/themes/classic/views
generate themes/classic/views/.htaccess
mkdir C:/wamp/www/myYii/themes/classic/views/layouts
mkdir C:/wamp/www/myYii/themes/classic/views/site
mkdir C:/wamp/www/myYii/themes/classic/views/system

Your application has been created successfully under C:\wamp\www\myYii.

Thats all. You are ready to use your application by accessing the URL : http://localhost/myYii/

Yii PHP MVC framework

February 1, 2010

Yii(Yes it is) is a php mvc framework  in competition with the existing frameworks such as CakePHP, Zend Symfony etc.

Soon it will gain popularity as it has many features such as :

  • MVC design pattern
  • DAO and Active Record
  • jQuery-based JavaScript support
  • I18N and L10N
  • Page, fragment and data caching
  • Error handling and logging
  • Theming
  • Web services
  • Console applications
  • Authentication and authorization
  • Web 2.0 widgets
  • Form input and validation

Following are the Performance comparison :

  • Yii: 673 requests/second
  • CodeIgniter: 206 requests/second
  • Zend: 83 requests/second
  • CakePHP: 79 requests/second
  • Prado: 75 requests/second
  • Symfony: 50 requests/second

People who are interested in using the frameworks should definitely try this 🙂

To know more about this framework, follow the given link:

http://www.yiiframework.com/

solved IPN link issue in virtuemart on GoDaddy shared linux hosting

December 14, 2009

Whenever seller accepts a payment, IPN link was not updating the status of the order in virtuemart.

The project is hosted on Godaddy’s shared linux hosting.

Shared linux hosting gives us php.ini file.

In that “set allow_url_fopen = on “.

By default it is off.

solved cron job setting on GoDaddy shared linux hosting

December 14, 2009

I was struggling with setting the cron job for php script on GoDaddy hosting server.

The example which GoDaddy gives to set the path of the cron job script is as follows:

/web/cgi-bin/php5 “$HOME/html/cron/yourscript.php”

But unfortunately, the above example does not work.

To make it work, remove “5” from php5 and remove the double quotes as follows:

/web/cgi-bin/php $HOME/html/cron/yourscript.php

Co-Founder of WordPress

December 9, 2009

Thanks to Matt Mullenweg, Co-Founder WordPress, for providing wordpress blogging patform.

How to display wordpress posts in Facebook

December 7, 2009

I came across 2 ways for displaying wordpress posts in the wall section of facebook.

A) 1) Displaying posts in wall of Profile section:

go to Settings > Application Settings

Click on Notes

Click on Import Blog link in Notes settings on Right side

Enter a website or RSS/Atom feed address in Web URL field

Click on Start Importing

Click on Confirm Import

The posts from the wordpress will be displayed on wall section in face book.

2) Displaying posts  in wall of a particular page

Click on Edit Page

Click on Edit link in Notes

Click on Import Blog link in Notes settings on Right side

Enter a website or RSS/Atom feed address in  Web URL field

Click on Start Importing

Click on Confirm Import

B) Add an application named Social RSS

Using this application, you can pull the wordpress posts to the wall and boxes section.

Path of the important configuration files in Linux

December 2, 2009

Apache:

/etc/httpd/conf/httpd.conf – apache configuration file

/var/log/httpd/error_log – apache error log file

/etc/hosts – host configuration file of apache

PHP

/etc/php.ini – php configuration file

MYSQL

/etc/my.cnf – mysql database server configuration file

Nginx

/etc/nginx/nginx.conf

/var/log/nginx/error.log

How to start MYSQL database server in Linux

December 2, 2009

/etc/init.d/mysqld start – starts the mysql database server

/etc/init.d/mysqld stop – stops the mysql database server

/etc/init.d/mysqld restart – restarts  the mysql database server

How to start Apache server in Linux

December 2, 2009

Linux commands :

Apache:

/etc/init.d/httpd start – starts the apache server

/etc/init.d/httpd stop – stops the apache server

/etc/init.d/httpd restart – restarts  the apache server