15 October 2009 View Comments

Move your .htaccess directives to httpd.conf

htaccess

htaccessLast week I was searching the net for a program or application to  move some of our .htaccess directives into Apache’s configuration files. The reason I was looking for this is to improve the performance of the site. When we have directives in the .htaccess file, the performance hit on Apache on when it serves each URL is accessed.

If you have a .htaccess file in your web folders, Apache will have to parse the directives in this file and see if there are any .htaccess files in the parent folder. All this happens before your html or php file is hit by Apache. You can read more about the overheads of .htaccess in  this article. This article .htaccess vs httpd.conf by Dawid Golunski shows that he saw apache served about 6.6% less requests/second when .htaccess was used.

A quick Google search landed me on Paul Reinheimer’s blog where he’s created a php script just for this purpose. His htaccess to httpd.conf script parses all the htaccess files from the current folder and all sub-folders and creates a configuration file with the directives for you to place in your Apache’s configuration file.

Just download his script from this link, and place it in your web-root directory which you want to generate the Apache configuration file and run the following command from the command prompt:

php htaccess.php >~/site.conf

After you run that command, you should have a file site.conf in your home folder. You can open this file to get all the directives for you to place in the Apache configuration file. Once you’ve placed this in the apache configuration file, you’ll need to restart Apache for the changes to take effect. Before you restart, make sure you remove your .htaccess file from your web folders.

When I converted a WordPress’ .htaccess file using this script, here’s the output I got

<directory var="" www="" blog="">
	<ifmodule mod_rewrite.c="">
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
	</ifmodule>
</directory>

I just put this into the apache2.conf and restarted it, removed the .htaccess from the webroot in /var/www/blog and all the rules worked as they should. As with any script, if you have more complex directives in your .htaccess, test your sites thoroughly before pushing your changes into the production server.

The only (minor) disadvantage I found with this method is that the apache server has to be restarted to make changes to your rule-sets you put in the configuration files. It seems apache just has to be reloaded and doesn’t have to be completely restarted to get the changes to the configuration to take effect (thanks Keleo for the tip). Also this conversion will not be possible if your site is running on a shared webhost where you don’t have access to the apache configuration files.

Links:
Paul Reinheimer’s Article .htaccess to httpd.conf
Paul’s htaccess.php Script
htaccess vs httpdconf – Benchmarks

Reblog this post [with Zemanta]

12 October 2009 View Comments

Bangalore PHP Users meet on October 31st

Bangalore PHP Users meet on October 31st

We got the final dates for the Bangalore PHP user’s meet. The Meet up’s happening on the last Saturday of this month – the 31st of October. We’ve already got more than 30 PHP’ers who have RSVP’ed that they’ll be attending this meet. We may be having a few people come in from Chennai also who want to make it to the event.

If you’re interested in joining us on the 31st, head over to http://www.meetup.com/Bangalore-PHP-Users/calendar/11578824/, signup and RSVP ‘yes’ to the event.

We have a proposed list of talks over at this page. If you’re interested in giving a talk at the event, let me know or simply add it to that list. We’ll finalize the talks as we get closer to the event. Remember that the PHP meetups are not just about the talks, it’ll be a great place for you to meet others in the same field of work. Get to know how others are using PHP and related technologies and discuss issues you’re facing with others how may be able to help.

This month, Microsoft has providing us the venue for us to meet, and so we’re meeting at their office which is just off the Intermediate Ring Road. Hope you see you at this month’s meet.

Links:
Bangalore PHP Users Oct Meetup Calendar
Proposed list of talks for the event

6 October 2009 View Comments

Banglore PHP Users Meet up October ’09

PHP Bangalore User Group

PHP Bangalore User GroupWe’re in the process of getting a meet organized for PHP professionals in Bangalore. The purpose of this meet is to share knowledge with the community, discuss issues you’re facing with others in the same field and help you network with other PHP professionals. This is not a one-off event, but we’re planning on making this a regular event. We haven’t really finalized the frequency of the events, but you can let us know of your preferences when you meet up with us this month.

In order to kick start this effort, I’ve started a meetup community to help get things organized. If you’re interested in the meet up this month or the future, please join the group at : http://www.meetup.com/Bangalore-PHP-Users/

For this month’s meet, we’re in the process of choosing a venue for the event. For this we would like to get an approximate count of people who’d be interested in joining us. Once you’ve joined our Meetup group, head over to the poll here and let us know if you can join us this month: http://www.meetup.com/Bangalore-PHP-Users/polls/207590/

We’re tentatively planning the meet in the last week of October. We’ll have the final dates once we close on the venue. Our community members are already hard at work coming up with talks for the event. You can take a look at the proposed list of talks over at this page. If you also have ideas for talks at the event, please feel free to add your talk to this list.

See you there at the meetup. I’ll keep you all updated about this event on twitter and the Meetup group. So stay tuned.

29 September 2009 View Comments

Simple Cloud API for Cross-Cloud Implementations

Simple Cloud API for Cross-Cloud Implementations

Zend has launched the Simple Cloud project which allows PHP developers to write Cloud based apps without having to bother about the different cloud based solutions available. This works like an abstraction layer for various cloud solutions like Amazon, Windows Azure, Rackspace Cloud Hosting and a few more.

Initially this project aims at providing standard cross-cloud simple APIs for

  • File storage- including Windows Azure blobs, Rackspace Cloud Files, Nirvanix Storage Delivery Network and Amazon S3
  • Document Storage- including Windows Azure tables and Amazon SimpleDB
  • Simple Queues- including Amazon SQS and Windows Azure queues

From Zend’s press release, “Zend Cloud will also provide adapters for local services to make offline coding and testing against cloud services as easy as connected development.

These APIs will be appearing soon on the Zend Framework as the Zend Cloud component. They will provide the basic functionality across the various cloud hosting services, but if you do need vendor specific functionality in your code, Zend Framework will provide vendor-specific libraries as well. They’ve already got Nirvanix, Amazon EC2, S3 and SQS covered. Microsoft’s proposed the WindowsAzure services for Zend Framework. IBM and Rackspace are also working with Zend to get their services covered. With these integrations in motion, they estimate that ZendCloud adapter with these features will be available in the Zend Framework by end of Q4.

An initial Simple Cloud API proposal and reference implementation is available now for community review and participation at http://www.simplecloud.org.

Links:

Zend Press Release – Zend Teams with IBM, Microsoft, Rackspace and Other Cloud Leaders on Open Source Initiative to Drive Cloud Application Development
MSDN Interoperability Blog – Microsoft, Zend and others announce Simple API for Cloud Application Services

Reblog this post [with Zemanta]

14 September 2009 View Comments

Fastrack with PHP on Windows

php.iis.net

interopThis article is the start of a series of articles on how PHP interoperates with other technologies. When people think of PHP, the first thing people think of is LAMP. But PHP is not limited to the run just under Apache, you can have PHP run under various configurations, including the command line. Here’s the first article in this series which shows you how to get PHP working in IIS.

A few weeks back I had attended the Virtual Tech Days events, specifically the Interop sessions. I was quite interested in seeing what Microsoft had to offer for PHP developers. Going through the oveview of the programs, they seem to have come up with quite a few solutions for PHP developers. One of the important integrations for PHP is the ability to run PHP directly from IIS, as a FastCGI app, without having to install Apache in Windows. [...]

Tags:
21 August 2009 View Comments

PHP worst practises

PHP worst practises

PHP LogoYou’ve read a lot of PHP best practises articles and topics all over the internet and try your best at following them during your development. How about the worst practises in PHP development? There’s a nice article on the PHPDev Blog which tells you about a few practises (which I’m sure most of us haven fallen a prey to during our careers) which should be avoided at all costs.

Some of the practices include in the article are “I don’t need no documentation” syndrome and “My code is the way to go” when other better alternates are out there. Why don’t you head out and read the full article there?

PHP Worst Practices

14 August 2009 View Comments

Zend Framework 1.9.1 released

Zend Framework 1.9.1 released

zend_framework_logoAlexander Veremyev, a Zend Framework team member has announced the latest release of the Zend Framework 1.9.1.  This is the first maintenance release in the 1.9 series and has bug fixes for  over 30 issues. You can view the full changelog for this release over at: http://framework.zend.com/changelog/1.9.1

You can download Zend Framework 1.9.1 at: http://framework.zend.com/download/latest

22 July 2009 View Comments

Win a license for Gravity Twitter Client at mynokiaworld.com

gravity
Gravity s60 twitter client Screenshot0060
Image by roland via Flickr

Here’s a chance for you all to win a free license for Gravity, a native S60 Twitter client with a really slick interface. MyNokiaWorld is holding a contest to giveaway 4 licenses to Gravity. All you have to do is to tweet or blog about the contest or subscribe to their RSS feed to enter the contest. Easy as that. You can even just follow them on twitter to enter.

For more information on this contest and how to enter, check out the site at: http://bit.ly/gkGp4

Reblog this post [with Zemanta]

22 July 2009 View Comments

Are you ready for PHP 6?

php6unicode

php6unicodeHere’s an article from Linux Magazine showing you how to install a development snapshot version of the latest PHP 6 build on your system. They also go on to give an overview on what’s new in PHP 6  and some of the code you’ll have to change in your current source to get it working on PHP 6.

The good thing about PHP 6 is that by default all strings are treated as Unicode characters, unlike the earlier versions where a lot of the default functions in PHP used to break up unicode characters and essentially junked the data. UTF-8 is now  the default encoding for many of the PHP 6 functions, so you don’t have to worry about your unicode data getting junked. In PHP 6 you have to watch out when you’re handling binary data, you’ll have to explicitly typecast your binary data or risk getting it junked because PHP 6 thinks of it as unicode :)

$binStr = (binary)$rawdata;

You can also declare the encoding of your PHP script by the following command:

Even your OO code where you were following the pre PHP 5.3 object models will not work here, since object model compatibility is removed. So your classes should be like this:

 class newClass {
   private $variable;
   public function myMethod {
    }
 }

instead of the old notation in 4.3 which used to look like this:

 class newClass {
   var $variable;
    function myMethod {
    }
 }

Read more on this topic at Linux Magazine: Get Ready for PHP 6

Image Credits: Narno via Flickr

14 July 2009 View Comments

PHP 5.3 & Internationalization

Unicode_sample

Unicode_sampleStas Malyshev has written a good article over at Zend Developer Zone about the new intl – Internalization extension in PHP 5.3. Internationalization has been a major problem with web developers when developing sites which have to support multiple languages. The new extension eases the developer’s work drastically. Stas mentions in the article that the following modules have been implemented in the Intl extension:

  • Locale — deals with breaking locale data into components, assembling a locale string from components and displaying the names of countries, languages etc in a specified locale.
  • Collator — a means of comparing and sorting strings according to local rules.
  • Number formatter — allows you to format numbers in a variety of ways, and to parse textual representations of numbers.
  • Date formatter — allows you to format dates and to parse textual representations of dates.
  • Message formatter — allows you to compose messages from parameterized strings while formatting the data inside according to local rules and allowing choices dependent on the actual parameter value.
  • Normalizer — a means of bringing a Unicode string to a standard, unambiguous representation.
  • Grapheme module – handles parsing a string into a set of graphemes.
  • IDN – handles internationalized domain names format

Read Stas’ article to learn how to use the new features this extension provides to make your website Internationalization ready.

If you’re using PHP5.2, you’re in luck since there is a PECL package which should run on PHP 5.2.4 and newer over at: http://pecl.php.net/package/intl

Link: http://devzone.zend.com/article/4799-Internationalization-in-PHP-5.3

Image via Wikipedia

Reblog this post [with Zemanta]

Tags: ,