Hi All,
I think these days lots of developers are facing problem in Google checkout i do Free-lance in google checkout so you can contact me @ prashcom (a) gmail.com.
I can develop a checkout in just 2-3 days for you. So tell me if anyone need my help. My charge is only 50$ per day.
Also if you need any assistance in Paypal / PaypalPro Checkout or any application in Ebay/Amazon you can contact me.
Thanks
Prashant Agarwal
API Developer
Tuesday, February 12, 2008
Free-lance Google Checkout
Wednesday, November 21, 2007
Tuning PHP
Here is my compilation of tips on how to optimise Apache on Linux for PHP and CGI programs. These tips can also apply to Perl and Python. Links will open in a new window.
Also read my essay Optimizing PHP for a more in depth coverage of these issues with case studies.
To tune well, you need to benchmark your Web server. You can get some benchmark figures using ApacheBench (ab) or httperf. If you are an OS agnostic like me, I recommend using Microsoft's excellent free Web Application Stress Tool (WAST - requires M'soft Windows). WAST is more flexible than ab because it allows you to define different GET parameters for each thread. This is important because it allows you to simulate multiple PHP sessions via the PHPSESSID GET parameter. Avoid benchmarks involving PHP sessions when using ab as the sessions will become an artificial bottleneck. More info on using WAST with PHP.
To monitor the Apache server, I use the command top d 1 which displays CPU and memory usage of all processes on the machine, and apachectl status.
- General rule of thumb for hardware upgrades: For PHP scripts, the main bottleneck is the CPU. For static HTML/images, the bottleneck is RAM and the network. According to Compaq benchmarks in 1999 (the original article is lost due to bitrot), a slow 400 Mhz Pentium can saturate a T3 line (that's 45 Mbps) with static HTML pages.
- A PHP script will be served at least 2-10 times slower than a static HTML page by Apache. Try to use more static HTML pages and fewer scripts.
- Enable the compression of HTML by putting in your php.ini:
output_handler = ob_gzhandlerIf you think about it, it might take you 0.1 seconds to generate 40K of HTML in your PHP page. However it probably takes 6 seconds for the user to download the page using a 56k modem without compresson. With compression, the download will probably take 2-3 seconds.
So the time taken for page generation is miniscule in comparison to the transit time of the HTML from the server to the browser. Therefore the biggest speedup you can perform for modem users is using ob_gzhandler! This feature is only recommended for PHP 4.1.0 or later. This point was moved closer to the top of the list on 9 July 2002 when i personally experienced the benefits of compression. More info...
- Your PHP scripts are recompiled every time unless the scripts are cached. Install a PHP caching product (I recommend Turck MMCache) to typically increase performance by 25-100% by removing compile times.
- Switch from file based sessions to shared memory sessions. Compile PHP with the --with-mm option and set session.save_handler=mm in php.ini. Informal benchmarks suggest that session management time is halved by this simple change. Added 1 Dec 2001. This hint should only be used for PHP 4.2.0 and above as there were bugs before this.
- An alternative caching technique when you have pages that don't change too frequently is to cache the HTML output of your PHP pages. Try Smarty or Cache Lite.
- Use output buffering (See ob_start). This will speed up your PHP code by 5-15% if you frequently print or echo in your code. Note that output buffering is already enabled if you are using the above ob_gzhandler hint. ASP does this in IIS 5. Added 26 Nov 2001.
- On Windows, FastCGI is the highest performance way of running PHP with Apache. Although PHP4 can run in a threaded environment, some global locks prevent it from making full use of threads. Also PHP is not very stable in threaded environments because many common extensions are not thread-safe. Added Feb 2004.
- In PHP4, objects and arrays should be passed in and out of functions by reference (with &), and everything else by value. In PHP5, objects are automatically passed by reference. For example the following gives best performance:
function &test(&$obj_or_array)
{
return $obj_or_array;
}
$var =& test($obj); - Be miserly and sparse with your server and web pages. Don't run X-Windows on the server and other unneeded processes. Apache Today has a guide on how to remove them.
- Don't use images when text will do. Reduce your image sizes with a software like Adobe ImageReady or MacroMedia Fireworks. Avoid dithered images as they tend to compress poorly.
- Spread the workload. Run your SQL server on another machine. Serve graphics and HTML from another low-end computer. If all static content is served from another server, then you can turn off KeepAlives in httpd.conf on the PHP server to speed up disconnects. 1 Feb 2002: I am currently using tux as the static web server, and have set it to pass all .php files to Apache which resides on the same machine. 15 March 2002: thttpd is another popular static web server.
- Use hdparm to tune your hard disk. If you are using a default Linux install, this could speed up your hard disk by 200%. This is mostly useful for IDE hard disks, but some hdparm settings work with SCSI also.
- Modify the following httpd.conf parameters to:
# disable DNS lookups: PHP scripts only get the IP address
and turn on follow FollowSymLinks and turn off SymLinksIfOwnerMatch (correction by Joshua Slive) to prevent additional lstat() system calls from being made:
HostnameLookups off
# disable htaccess checks
AllowOverride noneOptions FollowSymLinks
There are many other httpd.conf tips below.
#Options SymLinksIfOwnerMatch - A brief and quite complete set of Apache Tuning Tips by Kurt.
- If you are comfortable patching Apache 1.3 sources, try lingerd. Each Apache process currently wastes a lot of time "lingering" on client connections, after the page has been generated and sent. Lingerd takes over this job, leaving the Apache process immediately free to handle a new connection. As a result, Lingerd makes it possible to serve the same load using considerably fewer Apache processes.
- Increase SendBufferSize in httpd.conf to the size of your largest Web page. Increase your kernel's TCP/IP write buffer size. See IAgora's tuning hints.
- HotWired's: Tuning Apache Web Servers for Speed. An old article: 1997.
- Sterling Hughes and Andrei Zmievski have some good advice in their Advanced PHP presentation (don't miss the section on Squid at the end of the slides). Added 13 Aug 2002.
- Ron Chmara's advice on tuning Apache when using PHP's persistent database connections: don't set MaxRequestsPerChild too high so idle resources are released quickly.
- Caching Tutorial for Web Authors and Webmasters by Mark Nottingham teaches you how to make browsers cache content.
- If you are a brave soul, you can also apply Silicon Graphics' Accelerated Apache patches. "This project's aggressive optimizations make Apache/1.3 up to ten times faster and Apache/2.0 up to four times faster on the SPECweb96 benchmark."
- Bradley J. Bartram talks about using flood to stress test apache. Also general monitoring and tuning advice. Added 24th Sept 2003.
- Tips from the book Professional Apache.
- The Official Apache Performance Tuning documentation. Good stuff, but very verbose.
- Tips on Web-site Acceleration from SitePoint. Added 11 March 2004.
- Sascha Schumann of the PHP development team recommends compiling PHP4 with the following settings
--enable-inline-optimization --disable-debug - Hints on optimizing Linux, more Linux and Solaris.
- Set the noatime attribute for frequently accessed files. Otherwise Unix systems will record the last file access time. This is a useful setting for your web pages. Here's how to change in on Linux and Solaris. Added 14 March 2002.
- Use a Ramdisk to store your temporary files (e.g. session variable files). Ramdisk howto.
Mr Perkins points out that for Linux 2.4/Solaris, rather than creating a ramdisk, using tmpfs is more effective as it won't ask for all the ram straight away, and also if the machine becomes very busy the ram is freed and swap is used. The following command sets up the filesystem over your existing /tmp (where php stores cookie info by default):
mount tmpfs /tmp -t tmpfs -o size=64m
- Scaling Apache 2.0 (pdf). Discusses the ftp.heanet.ie website. It serves content via HTTP, FTP and RSYNC all available via IPv4 and IPv6. Includes advice on tuning OS. Added 24 Mar 2006.
- Scalable Internet Architectures (pdf), an extensive presentation that was later expanded into a book of the same name by Theo Schlossnagle. Discusses some pretty sophisticated techniques including DNS load balancing and mod_backhand. Added 24 Mar 2006.
- HP/Compaq Apache tuning guide in PDF. Very complete and includes benchmarks.
- After xenu.net was slashdotted, they published their Apache optimization tips.
- I just realised that all the above tips deal with squeezing the maximum performance from a single server. Ultimately if you are successful, the tips won't be enough. Then you will need to switch to using multiple Apache servers (a server farm) with clustering, load-balancing and caching. Using Squid as a proxy cache. Configuring Squid. Rasmus Lerdorf recommends squidGuard (added 30 July 2002).
- Deprecated is the recommendation to use Apache 2 with threaded PHP SAPI. Apparently PHP still has some global locks that prevent it from maximizing concurrency with multiple threads. Modified Feb 2004.
PHP Specific Articles
- High Performance PHP presentation by George Schlossnagle given at PHPCon 2002
- Advanced PHP presentation given by Sterling Hughes and Andrei Zmievski at O'Reilly Open Source Conference 2002.
- Optimizing PHP article by John Lim.
Associated Topics
- Security and Apache: An Essential Primer (LinuxPlanet.com)
- Using User Authentication from Apache Week.
- Dirk Brockhausen's tutorials on mod_rewrite part 2 part 3 part 4
- And you thought Apache was fast...
Friday, October 5, 2007
.htaccess on localhost
The recent problem i faced when i was trying to run .htaccess file in my WAMP configuration. The script was working fine when it was live on server (as basic configuration was already there) but was giving 404 when i tried in localhost.
After googling i found no answer so i want to help others in this small topic.
The solution is very simple :
If its Windows+Apache+Php+MySql (WAMP) type "Web-Developer Server Suite" then you only needs to search for a folder called Apache22. Under this folder we have several folders, the one which we needs to see is CONF. Now open "httpd.conf" in your favorite editor. Now here you needs to see few things :
1. if "#LoadModule rewrite_module modules/mod_rewrite.so " mod is commented then remove the '#' from the beginning.
2. Make sure "#LoadModule alias_module modules/mod_alias.so" is also not commented.
The above two by default not commented so no need to worry for the first two.
3. Now search for a word "AllowOverride" and make sure you have changed it to "AllowOverride All".
4. And you done. Just restart the Apache and will run all fine, if your .htaccess has no error :)
I hope this will be helpful for you all!!
Prashant Agarwal
Software Professional
Thursday, September 27, 2007
Google Checkout : Failed to Get Basic Authentication Headers
Google Checkout : Send failed with code: 401. Response body was: Failed to Get Basic Authentication Headers
The most common problem facing php file in Google Checkout is ResponseHandler.php. Many of us really don't know how exactly its working and behave. After few days of my r&d in Google Checkout i have the solution to fix the "Get Basic Authentication Headers" problem.
I started running ResponseHandler.php against Google Checkout running under different situations and I ran into a problem with authentication when PHP was being run as a CGI under Apache. When running as a server module (mod_php) PHP takes care of decoding HTTP basic for you (see HTTP basic authentication in PHP). When a using HTTP basic PHP will automatically populate $_SERVER[’PHP_AUTH_USER’] and $_SERVER[’PHP_AUTH_PW’] variables with the username and password that were provided. IF and ONLY IF PHP is being run as a server module (like mod_php). If you are running PHP as a CGI then those two variables won’t get created at all, ever, even when using HTTP basic authentication. And since you can’t do anything in WordPress via AtomPub without authenticating you are dead in the water. Well, not exactly.
However, there is a workaround available which can make HTTP Auth for PHP working even when in CGI mode.1. Create one .htaccess file in the folder where your responsehandler.php file is :
.htaccess file:
<<<Start--- AuthName "Google checkout Basic Authentication" AuthType Basic AuthUserFile D:\\\\www\\\\webroot\\\\projectfolder\\\\googlelibraryforcheckout/.htpasswd
require valid-user
---End>>>
2. Create one .htpasswd file in the folder where your responsehandler.php file is :
.htpasswd
$merchant_id:$merchant_key
and now you need to disable few codes from googleresponse.php file :
* googlecheckout/responsehandler.php folowing code will be disabled if
* CGI config is set to True
*
*
[CODE]
//Parse the HTTP header to verify the source.
if(isset($HTTP_SERVER_VARS['PHP_AUTH_USER']) && isset($HTTP_SERVER_VARS['PHP_AUTH_PW'])) {
$compare_mer_id = $HTTP_SERVER_VARS['PHP_AUTH_USER'];
$compare_mer_key = $HTTP_SERVER_VARS['PHP_AUTH_PW'];
}
else {
error_func("HTTP Basic Authentication failed.\n");
exit(1);
}
if($compare_mer_id != $merchant_id || $compare_mer_key != $merchant_key) {
error_func("HTTP Basic Authentication failed.\n");
exit(1);
}
[/CODE]
I hope this article will help you alot to work arround the Google Checkout's "Send failed with code: 401. Response body was: Failed to Get Basic Authentication Headers"
Regards,
Prashant Agarwal
(If you have any problem then please write here i will try to solve all queries related to php and google / paypal chekckout)
Wednesday, September 5, 2007
Its really difficult to decide which framework works best for the project
Hi All,
When i was googling i found now we have with over 40 frameworks available. So i am sure it's really difficult to decide which framework works best for our project, especially as each framework offers different functionality. So i did some r&d and able to make one table for you so you can decide what exact framework you are searching for. In these 40 framework i was only able to sort 10.
So we can look at ten popular frameworks, and compare them to each other :
| Framework | PHP4 | PHP5 | MVC1 | Multiple DB's2 | ORM3 | DB Objects4 | Templates5 | Caching6 | Validation7 | Ajax8 | Auth Module9 | Modules10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Zend Framework | - | ![]() | ![]() | ![]() | - | ![]() | - | ![]() | ![]() | - | - | ![]() |
| CakePHP | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() | ![]() | ![]() | - |
| Symfony Project | - | ![]() | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() | ![]() | ![]() | - |
| Seagull Framework | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() |
| WACT | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() | - | ![]() | - | - | - |
| Prado | - | ![]() | - | ![]() | - | - | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| PHP on TRAX | - | ![]() | ![]() | ![]() | ![]() | ![]() | - | - | ![]() | ![]() | - | - |
| ZooP Framework | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| eZ Components | - | ![]() | - | ![]() | - | ![]() | ![]() | ![]() | ![]() | - | - | ![]() |
| CodeIgniter | ![]() | ![]() | ![]() | ![]() | - | ![]() | ![]() | ![]() | ![]() | - | - | ![]() |
#1: Indicates whether the framework comes with inbuilt support for a Model-View-Controller setup.
#2: Indicates whether the framework supports multiple databases without having to change anything.
#3: Indicates whether the framework supports an object-record mapper, usually an implementation of ActiveRecord.
#4: Indicates whether the framework includes other database object, like a TableGateWay.
#5: Indicates whether the framework has an inbuilt template engine.
#6: Indicates whether the framework includes a caching object or some way other way of caching.
#7: Indicates whether the framework has an inbuilt validation or filtering component.
#8: Indicates whether the framework comes with inbuilt support for Ajax.
#9: Indicates whether the framework has an inbuilt module for handling user authentication.
#10: Indicates whether the framework has other modules, like an rss feed parser, PDF module or anything else (useful).
I hope this will help u to decide which one will be helpful for your project.
Cheers!!
Prashant Agarwal
Wednesday, August 29, 2007
Php SetCookie : Reason behind Cannot modify header information - headers already sent by..
Cannot modify header information - headers already sent by (output started at ...) is a very well known error returned by PHP. You would receive this error if you are trying to set the header of a page after the header has already been sent to the client. There are two main ways of getting around this error.
How it really works: Every file that you request from the Internet comes with a header. This tells the browser how to handle that specific file. For example it could be a page that the browser will display or an executable that it will download. The header will contain information about what type of file this is.
PHP sends the header of the web pages to the client each time a page is requested. If you change that header after it was already sent, PHP will return the "Cannot modify header information" error. Most of the time you change the header by using the header() function, as in the example below:
header("Location: http://www.example.com");
This tells the browser that it should open the URL http://www.example.com (thus get the header from there.) However if you place this line in the code after you already displayed the content, the headers have already been sent to the client. That's simply because even if you don't set your own header, each time you display anything on a page, even a blank space, PHP will send the headers for you. If you make use of the header() function after any such blank space or any other content for that matter, you'll be attempting to send a new header to the client, which is not possible.
The same applies for other functions that attempt to change the header, such as setcookie() which - because the cookie travelers in the header - needs to be placed before any output is sent to the page.
Solution #1 - no output before header(), setcookie() and other header setting functionsThus, the first solution to the "Cannot modify header information" error is to make sure you are not outputting any content at all before the call to the header() function.
Solution #2 - ob_start() The second method consists in calling the ob_start() at the very top of the PHP script like this:
ob_start();
This will turn output buffering on. With output buffering the entire PHP script will be processed before any output is sent to the client. Thus all the PHP script will be aware of all the header changes and it will not send any headers until every line has been processed.ob_start() may appear to slow down the loading time on server intensive pages, because the client will not be presented with any fragment of the page until the page is fully processed.
Prashant Agarwal
Wednesday, July 11, 2007
SEO : What should be the title tag for your business?
The html title tag of a web page's html header is the single most important "on page" element when it comes to search engine optimization. That being said, is the best use of this valuable real estate served by including your business name in the title? Chances are the answer is a resounding "no!" The title tag is an html tag which occurs in the header of a web page's code. The first thing I look at when I get a call from a prospective client is their title tag. More often than not, this tag is being used improperly, to the extreme detriment of the client.
Recently SEOMOZ.org released its rankings of the ten most important factors in search engine rankings. The title tag came in at number 1, and this is no surprise to any SEO that has been around for awhile. Google especially pays a lot of attention to title tag content, and uses title tag information heavily to ascertain the relevant keyphrases for which to rank a site. The opinion of search engine experts is unanimous on this one - keyphrase use in the title tag is the number one "on page" factor affecting search engine rankings. This is not disputed, theorized or subject to professional debate. It is a fact.
Given this fact, we must look at how to best use the title tag to optimize our site for search engines. Many sites place the business name in the title tag (or even worse yet leave it blank or with default content such as "untitled document" or "home page"). Any of these variations can be disastrous!
Let's use an example of a company that manufactures widgets. The primary keyphrase for that company would be "widgets", this being the phrase for which the company would like to rank highly for in the search engines. Now let's assume the company name is "ACME Manufacturing Company, Ltd.". Notice that the word "widgets", which is the desired keyphrase, is not extant in the company name.
So the company goes out and builds a wonderful web site to promote their widgets. However, throughout the site the title tag contains the following content: "ACME Manufacturing Company, Ltd." What is the effect of this?
First off, the effect of this is that the site will likely rank highly for the search query "ACME Manufacturing Company, Ltd.". The problem is that nobody is searching for the company name, they are searching for widgets. So all of ACME's competition shows up in the search engines for a widget query, but poor ACME is nowhere to be found. How do we help ACME rank highly for the search query "widgets"? We must optimize the title tag for the search engines by replacing the current title tag content with the desired search query: "widgets".
Generally speaking, the company name should never appear in the title tag unless you actually expect to derive most of your traffic from searches involving your company name. As this is a rare situation, avoid the temptation to put your company name in the title tag - save it for elsewhere on your page. Put your desired search keyphrases in the title tag, and leave it at that.
Following this methodology throughout your site by optimizing title tag content for each page according to the desired search query for that page will be a major step in the right direction for high search engine rankings.
About Me
- Prashant Agarwal
- I am Prashant Agarwal from Bhubaneswar India. I am software engineer in UK based company. I love to do programming and SEO stuffs. My home town is in Dhanbad Jharkhand. I have done BCA & MCA from DOEACC Delhi. I also did Java certification from NIIT. Now i am planning for MBA in IT / System from IIM.

