Lorem ipsum dolor sit amet, consectetuer adipiscing.

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

Kohana looks better…

Kohana PHP Framwork Kohana is exclusively for PHP 5 while Code Igniter supports from PHP 4 and up. Kohana is strinctly OOP with benefits like visibility protection, automatic class loading, overloading, interfaces, abstracts, and singletons. Code Igniter supports only $POST arrays and no GET, Kohana lets POST and GET arrays live together in harmony with […]

More

Kohana looks better…

Kohana PHP Framwork

  • Kohana is exclusively for PHP 5 while Code Igniter supports from PHP 4 and up. Kohana is strinctly OOP with benefits like visibility protection, automatic class loading, overloading, interfaces, abstracts, and singletons.
  • Code Igniter supports only $POST arrays and no GET, Kohana lets POST and GET arrays live together in harmony with the same tight security of Code Igniter.
  • Kohana’s directory structure makes a lot more sense. See, Code Igniter has one directory at the root called System. In this directory is a bunch of subdirectories of which your application directory is a part of. Kohana went and put the application directory with the system directory on the root path.
  • But Kohana is lacking in Documentation, UserBase, CodeBase, CI is having few publish booked from Wrox and Oriliy. From Hiring point of view, Developer are more in CI but we can trained them for Kohana.

CI is ahead because of following main reasons

  • Nice Documentation
  • Books Available
  • Experienced and Trained Resources Available
  • Stable

Kohana Learning

Kohana PHP ORM Guide Volume 1


kohana 101 – Programming, Technology, and Framework

Installation of FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR Installation

Introduction

The following HOWTO will show you exactly how to install the following packages on a Debian Etch or Ubuntu 7.06 system:

  • FFmpeg
  • FFmpeg-PHP
  • Mplayer + Mencoder
  • flv2tool
  • LAME MP3 Encoder
  • AMR (for 3gp file conversions)
  • Libogg
  • Libvorbis

Do some prep-work

apt-get update
apt-get upgrade
apt-get install libjpeg-progs libjpeg62 libjpeg62-dev libsdl1.2-dev php5-dev build-essential unzip

Download all the files needed

cd /usr/local/src
wget http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz

lame
Project Location:
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz

ffmpeg-php
Project Location: http://sourceforge.net/projects/ffmpeg-php/
wget http://jaist.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2

X———————————————————————————————
— Not Working —
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
— Do not use it —
———————————————————————————————–X

wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2
wget http://downloads.xiph.org/releases/theora/libtheora-1.0beta3.tar.gz

Extract all the files

tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.2.0.tar.gz
tar zxvf flvtool2-1.0.6.tgz
tar jxvf essential-20071007.tar.bz2
tar jxvf ffmpeg-php-0.5.0.tbz2
bzip2 -cd amrnb-7.0.0.2.tar.bz2 | tar xvf –
bzip2 -cd amrwb-7.0.0.3.tar.bz2 | tar xvf –
tar zxvf libtheora-1.0beta3.tar.gz
We need a codec directory
mkdir /usr/local/lib/codecs/

Install Ruby on Rails, subversion & ncurses

apt-get install subversion ruby libcurses-ruby

Run some SVN queries

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update

Copy Codecs for mplayer

mkdir /usr/local/lib/codecs
mv /usr/local/src/essential-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
We also need to secure the tmp directory
mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp

Install lame

cd /usr/local/src/lame-3.97
./configure
make && make install

Install libogg

cd /usr/local/src/libogg-1.1.3
./configure && make && make install

Install libvorbis

cd /usr/local/src/libvorbis-1.2.0
./configure && make && make install

Install flvtool2

cd /usr/local/src/flvtool2-1.0.6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

Install mplayer & mencoder

cd /usr/local/src/mplayer
./configure –enable-jpeg
make && make install

Install AMR (for 3gp conversion)

cd /usr/local/src/amrnb-7.0.0.2
./configure
make && make install
cd /usr/local/src/amrwb-7.0.0.3
./configure
make && make install

Install libtheora (for ogg video encoding)

cd /usr/local/src/libtheora-1.0beta3
./configure
make && make install

Install ffmpeg

cd /usr/local/src/ffmpeg/
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared –enable-amr-nb –enable-libtheora
Ubuntu 7.06 users please use the following configure command:
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared –enable-libamr-nb –enable-libtheora
Ubuntu 8.04 users please use the following configure command:
./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared –enable-libamr-nb –enable-libamr-wb –enable-nonfree –enable-libtheora
For Fedora
./configure –enable-libmp3lame –enable-libvorbis –disable-mmx –enable-shared –enable-libamr-nb –enable-libamr-wb –enable-nonfree –enable-libtheora

make
make install
ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
ln -s /usr/local/lib/libamrnb.so.2 /usr/lib/libamrnb.so.2

Install ffmpeg-php

cd /usr/local/src/ffmpeg-php-0.5.0/
phpize

X—————————————————————————
if phpize will not work and shows command not found, then we need to install
php-devel for the php version.
—————————————————————————-X

./configure
make
make install
You now need to add the new ffmpeg-php module to the php.ini file
vim /etc/php5/apache2/php.ini
extension=ffmpeg.so (add this line to the end of the file)

Restart & done

/etc/init.d/apache2 force-reload

Trouble Shooting

“# ffmpeg
ffmpeg: error while loading shared libraries: libavcodec.so.52: cannot open shared object file: No such file or directory”

ln -s /usr/local/lib/libamrwb.so.3 /usr/lib/libamrwb.so.3
ln -s /usr/local/lib/libamrnb.so.3 /usr/lib/libamrnb.so.3
ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52

Test Your application:

LAMP

LAMP is the combination of Linux + Apache + MySQL + PHP (PHP/PERL/Python).

Linux is a free Unix-type operating system originally created by Linus Torvalds with the assistance of developers around the world. Developed under the GNU General Public License , the source code for Linux is freely available to everyone.

Apache is the most popular web server on the net. It is very secure, fast, and reliable.
MySQL is the fastest RDBMS in the world. It is very good for web based applications as well.

PHP is an open source project of the Apache Software Foundation. It is a powerful server-side scripting language for creating dynamic and interactive websites. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft’s ASP. PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses. PHP is a recursive initialism for PHP: Hypertext Preprocessor. PHP is perfectly suited for Web development and can be embedded directly into the HTML code. The PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server) on various operating systems. It also supports ISAPI and can be used with Microsoft’s IIS on Windows.

Ref.

PHP: MVC Based Popular Framworks

  1. PHP on Trax
    1. Strictly follows Ruby on Rails syntax and functionality but written in php5.
    2. Originally called PHP on Rails.
    3. It is a web-application and persistance framework that is based on Ruby on Rails and includes everything needed to create database-backed web-applications according to the Model-View-Control pattern of separation. This pattern splits the view (also called the presentation) into “dumb” templates that are primarily responsible for inserting pre-build data in between HTML tags. The model contains the “smart” domain objects (such as Account, Product, Person, Post) that holds all the business logic and knows how to persist themselves to a database. The controller handles the incoming requests (such as Save New Account, Update Product, Show Post) by manipulating the model and directing data to the view. In Trax, the model is handled by what’s called a object-relational mapping layer entitled Active Record. This layer allows you to present the data from database rows as objects and embellish these data objects with business logic methods.
    4. URL ~ http://www.phpontrax.com/
  2. Agavi
    1. Its an open-source, LGPL licensed MVC framework for creating applications written using PHP5.
    2. Agavi is a Web Application Framework for PHP 5. While it lies in the nature of a framework to simplify the application development process, Agavi won’t do that at any cost. The primary goals are flexibility, cleanliness and structure. We won’t find HTML Form helper methods in Agavi (because they aren’t necessary, it has something better, more on that later), and it use XML configuration files because it believe that XML offer better structuring abilites than alternatives such as YAML.
    3. Every Agavi Application consists of one or more Modules. Each Module contains one or more Actions. Actions contain logic code and are totally independent of the way you’re using them, be it through a normal web application, or via a SOAP interface – the code remains exactly the same, you usually never touch them again once they are finished.
    4. URL ~ http://agavi.org/
  3. Akelos PHP Framework
    1. Its a Ruby on Rails port to PHP4/5.
    2. The Akelos PHP Framework is a web application development platform based on the MVC (Model View Controller) design pattern. Based on good practices, it allows you to:
      1. Write views using Ajax easily
      2. Control requests and responses through a controller
      3. Manage internationalized applications
      4. Communicate models and the database using simple conventions.
    3. URL ~ http://en.wikipedia.org/wiki/Akelos_PHP_Framework
  4. BareBonesMVC
    1. A one-file, no-configuration, MVC framework for PHP5.
    2. http://code.google.com/p/barebonesmvc-php/
  5. CakePHP
    1. It webapplication framework modeled after the concepts of Ruby on Rails.
    2. CakePHP is a free open-source rapid development framework for PHP. Its a structure of libraries, classes and run-time infrastructure for programmers creating web applications originally inspired by the Ruby on Rails framework.
    3. http://cakephp.org/
  6. CodeIgniter
    1. CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
    2. CodeIgniter is an Application Framework
    3. CodeIgniter is written to be compatible with PHP 4.
    4. http://codeigniter.com/
  7. DragonPHP
    1. MVC2 Framework for PHP 5.
    2. Key Features
      1. Request Dispatcher
      2. Session Management
      3. Page Controller
      4. Page Flow Routing
      5. Security
      6. Common Logger
      7. Validator (i.e. Form Validation)
      8. Dynamic Templating
      9. Modules
      10. Database Access
    3. http://www.dragonphp.com/
  8. Fusebox
    1. Framework for building ColdFusion and PHP web applications.
    2. The main features are
      1. A Fusebox application is made up of Circuits. A Circuit corresponds to a directory in your application. Within each circuit are one or more Fuseactions. A Fuseaction is a request handler. And finally, a Fuseaction does its work by executing one or more Fuses. Fuses are individual CFML templates such as display files.
      2. The framework uses XML configuration files to define the application settings as well as declaring what each Circuit does and how Fuseactions within each Circuit execute. There is a core set of XML grammar that is used to create these files.
      3. The framework is fully extensible via Plugins, which allow you to extend the core functionality without having to modify the core files. It also supports Custom Lexicons, which allow you to extend the XML grammar with your own tags. As a result, Fusebox is very flexible and can support a wide range of development needs.
      4. Fusebox does not force the Model-View-Controller (MVC) pattern or Object-Oriented Programming (OOP) on the developer. However, either or both of these development approaches can be used with Fusebox.
    3. http://fusebox.org/
  9. FUSE
    1. A powerful but easy-to-use PHP 5 Framework for MVC development
    2. FUSE provides a powerful application development engine that allows us to:
      1. Rapidly create a working Model/View/Controller structure to properly organize your application
      2. Model your database tables (often automatically) to provide application-level access to data without SQL.
      3. Offer fully functional create, read, update, and delete functions with only a few lines of code
      4. Create a user authentication (login/permissions/privileeges) scheme for your site with just a few lines of code
      5. Call PHP functions from Javascript via a custom AJAX implementation
      6. Route URIs, which eliminates the need for ugly query strings and can greatly assist with SEO
      7. Separate HTML presentation from application code with a powerful but easy templating engine. etc.
    3. http://en.wikipedia.org/wiki/Fuse_Framework
    4. http://www.phpfuse.net/
  10. KohanaPHP
    1. Kohana is a PHP 5 framework that uses the Model View Controller architectural pattern. It aims to be secure, lightweight, and easy to use. The main features are:
      1. Highly secure
      2. Extremely lightweight
      3. Short learning curve
      4. Uses the MVC pattern
      5. 100% UTF-8 compatible
      6. Loosely coupled architecture
      7. Extremely easy to extend
    2. http://en.wikipedia.org/wiki/KohanaPHP
    3. http://kohanaphp.com/home.html
  11. LightVC
    1. Lightweight PHP 5 Strict MVC Framework with decoupling of Model and other non-View-Controller essentials to promote code reuse.
    2. Features :
      1. Lightweight single-file view-controller framework.
      2. Allows usage of any model or ORM.
      3. Promotes code re-use.
      4. Highly configurable.
      5. Fast.
      6. PHP5 Strict.
    3. http://lightvc.org/
  12. MicMVC
    1. A simple framework for creating standalone MVC websites in PHP5 with RoR style models.
    2. micMVC does not require an application framework to be installed on the host computer as an application written using micMVC packages all the necessary framework code with the application.
    3. http://riftor.g615.co.uk/index.php?action=view&id=22
  13. Odin Assemble
    1. Small footprint PHP based MVC Framework. The Odin Assemble engine works with your web servers existing 404 handler to act as your “web-site.” Odin Assemble works behinds the scenes to create HTML responses that appear to be static HTML documents. Odin Assemble provides a layer of functionality nonexistent in traditional web servers.
    2. Odin Assemble was designed to work in a limited resource environment performance is healthy. For maximum performance it’s recommended you set $_page_cache_life in your config.inc.php file to between 360-600. If you have a web-site that has limited or no use of random “elements” then you can improve your web-site assemble time by increasing the $_page_cache_life value.
    3. http://www.odinassemble.com/
  14. phpHtmlLib
    1. MVC based OO framework compatible with PHP4 and PHP5 licensed under GNU LGPL
    2. phpHtmlLib is now an application development framework for developing OOP style web applications in PHP. The application framework supports an MVC style architecture, Ajaxable and Cacheable interfaces for developing rich client web applications. It still contains the set of PHP classes and library functions to help facilitate building, debugging, and rendering of XML, HTML, XHTML, WAP/WML Documents, and SVG (Scalable Vector Graphics) images as well as complex html Widgets .
    3. http://phphtmllib.newsblob.com/
  15. phpXCore
    1. A MVC design pattern based PHP content management framework compatible with PHP4 and PHP5.
    2. Main features are :
      1. Open-source
      2. MVC controller
      3. Compatible with PHP4 and PHP5
      4. Request dispatcher with good looking, custom URLs
      5. Use PEAR packages (http://pear.php.net)
      6. Fast, flexible templating (http://smarty.php.net)
      7. Easy AJAX integration (http://xajaxproject.org)
      8. JavaScript framework (http://script.aculo.us)
    3. http://www.phpxcore.org/
  16. PRADO
    1. A PHP 5 MVC framework.PRADO is a component-based and event-driven web application framework for PHP5. PRADO reconceptualizes Web application development in terms of components, events and properties instead of procedures, URLs and query parameters. PRADO is an open source project. PRADO stands for PHP Rapid Application Development Object-oriented.
    2. The design of PRADO was influenced heavily by ASP.NET and Borland Delphi.
    3. http://en.wikipedia.org/wiki/PRADO
  17. SilverStripe contains a fully fledged PHP 5.2 ORM/MVC Framework focused on building websites.
  18. Solar PHP 5 frameworkSolar is a PHP 5 framework for rapid application development. It is fully name-spaced and uses enterprise application design patterns, with built-in support for localization and configuration at all levels.
  19. OnPHP onPHP is the mature GPL’ed multi-purpose object-oriented PHP framework (plus c-module)
  20. Switch board with Routing PHP 5 MVC Framework with Routing.
  21. Symfony Framework PHP 5 MVC Framework.
  22. TinyMVC Framework Simple and lightweight PHP5 MVC (Model-View-Controller) framework.
  23. TYPO3 extension library lib/div PHP 4/5 MVC framework for TYPO3 extension development
  24. Qcodo is an open-source PHP 5 web application framework
  25. Zend Framework A PHP 5-based MVC framework.
  26. ZNF PHP5 MVC framework for enterprise web applications
  27. Zoop Framework A Mature PHP 4/5 MVC framework.
  28. Lion Framework An open-source PHP 5 framework with a push & pull MVC implementation

PHP and ASP.net

Ever since Microsoft has come up with ASP.net, there has been a widespread debate among programmers as to whether it is any better than the existing open source programming language of PHP.

If we were to make a search on the Internet on how loyalists of both PHP and ASP.net are doing almost everything by biting each other’s heads off, We will realize how hot this debate actually is. The major contention is that Microsoft products are generally considered to be superior to other products, but then there are programmers that have been using PHP since ages and never once has it let them down. While there is acclaim for ASP.net being more robust and speedier, PHP fans maintain that PHP has much better support and a very easy to understand language.

PHP Strong Points:

  1. Once again PHP is Free and that is a major advantage and often the decider between which language should be used. Microsoft has expensive licensing costs which are handed back to the user via more expensive hosting costs. Dedicated servers with our own MS SQL database from Microsoft is rare for smaller sites due to the cost involved.
  2. Ease of learning. PHP is a straight forward scripting language, there is not a great deal of learning required before we can start programming with this language. PHP.net does a lot to help for this, it is the single, most convenient API and reference guide and in my opinion better than any other for any other language that is available. ASP.NET on the other hand requires basic programming fundamentals, and an understanding of object oriented principles which may be beyond the causal coder.
  3. PHP is a very fast and efficient implementation of a programming language. It doesn’t nearly use as much memory or execution time as ASP.NET, while this may not be noticable to many websites, for people pushing the limits of their website, it is a major consideration.
  4. One argument I hear a lot of ASP.NET developers raise is that there is a great IDE to develop the software on, Visual Studio.NET. While I have to agree that it is great, it does once again come with a price. Similar alternatives for the PHP language, such as Zend Studio are just as good and come at a tenth of the price.
  5. PHP runs on APACHE which has a great security track record and is open source. However IIS, the platform for ASP.NET has in the past been plagued with problems and security concerns. Regardless of whether people are just attacking it because it’s Microsoft, the flaw to be exposed is still there.
    ASP.NET Strong Points:# ASP.NET has something called the Common Language Runtime(CLR), and without going into too much detail, We can use a variety of different languages to program in, and when built they will all compile to the same code at that level. This means that we can use languages such as C#, Visual Basic.NET, Java.NET and we can even get implementations in PHP. This aids transition and helps other developers already learned in the lore of a certain language quickly pick up.
  6. This isn’t necessarily a positive but as ASP.NET is a commercial framework, bigger companies have more faith and trust in the software, and quite often a great deal of support can be gained because of this.
  7. .NET is a modern framework that has been designed from scratch. Thus meaning that the architecture, design and implementation of the languages involved are up to date and using modern principles. For example, C# is a fully object oriented language and builds on all the correct rules of programming. Regardless of the fact it may indeed take longer to program this way, it is cleaner, and logically it makes more sense and in the long run leads to less mistakes due to it’s strong typing.
  8. Exception/Event Based Error handling is a definite positive for ASP.NET. With the use of try catch blocks (although expensive) allow more sophisticated error handling. Whilst error handling in PHP is possible, there is no built in standardised way to achieve this.
  9. ASP.NET allows what is known as Code Behind Sheets. This effectively separates the logic from the design and allows us to create classes for each of our pages, leading to easier maintenance and clean code. This is possible in PHP but is certainly not a built in or standard feature as such.So the main question is, which one would I pick? Really, it’s not that simple, it’s usually more a question of which one is the best for the job in hand, or even more likely the project we have to work on has already been started in one language by our employers and which we must continue in.

If it was entirely a personal opinion, I would pick the cheaper option PHP, if however there were no costs I would pick ASP.NET.As the debate between PHP and ASP.net rages on, it is important to make a frank comparison between the two languages, so that other developers who are not so strong in their opinions are not caught in the argument between the two. Here are some of the important points that distinguish the two programming languages from each other:-  (For the uninitiated, PHP stands for Hypertext Preprocessor and ASP.net stand for Active Server Pages. It helps to put things into better perspective!)

  • PHP is a relatively simpler language to use than ASP.net. Initially, PHP was written in the C programming language to replace a set of scripts in Perl. That is the reason why coding in PHP remains simple even today. Many developers find themselves to be more at ease with the user-friendly nature of PHP when it comes to coding. However, critics also count this advantage of PHP as a disadvantage. Some of them maintain that the language of PHP has not been updated much, and hence it is still quite archaic and even, somewhat cumbersome for coding. ASP.net, which is a relatively new development, has a lot of options when it comes to languages. Here, we can use languages such as C#, J#, C++ and VB.net. Hence, when it comes to sheer choice, ASP.net has better to offer. But PHP is no less, since it can do its task quite well, even with its minimum language tools.
  • PHP is has much better support for the database management system, MySQL. In fact, the very popular blogging platform, WordPress uses the formidable combination of PHP coding on MySQL for its content management system, which includes about hundreds of thousands of blog posts every single day. Another very popular and frequently updated service that uses the combination of PHP and MySQL is Wikipedia. ASP.net can also support MySQL, but PHP is unanimously hailed, by the masses and classes alike, for its great support for this database management system.
  • People who use both PHP and ASP.net also maintain their opinion that PHP is better for embedded support with another database management system, viz. SQLite. SQLite is described as a relational database management system and since it is contained in a C programming library, PHP can provide better support to it.
  • PHP has also a very good support for object oriented programming, on which whole scripting languages are being built nowadays. ASP.net also provides very capable support to OOP.
  • When it comes to support, PHP wins over ASP.net. The main reason for this is that PHP is open source. Hence, the support can come freely from all over the world. In most cases, PHP fixes are made instantly. Being open source also ensures that there are very few snags in PHP. While, ASP.net could take a while to make fixes. That is because it is owned by Microsoft, and it is the development team of Microsoft that will need to respond to the support query. That could take more time than the worldwide open source support that PHP is able to get. Most PHP supports can be instantly found online by doing a simple search on the Internet. Some of the providers of support for PHP are Zend, NuSphere and ThinkPHP.
  • PHP can use the command line to perform many everyday activities. Some of the things that the PHP command line is useful for is for manipulating across many files and for putting files into multiple directories at once. These are just some of the important features that PHP’s command line is used for.
  • PHP is an open source programming language, which means it is free for anyone to use. Programmers can develop PHP applications virtually at no cost, because PHP is free to use. ASP.net is not free too, but its extensions are available for free on Windows platforms, upwards of 98. Hence, ASP.net is available to Windows users when they buy it. That puts a bit of restriction in its use.
  • ASP.net is compiled into memory in binary code. So, when ASP.net is used for coding, it is evident that it takes much longer time to process since the codes need to be retrieved from memory. However, PHP is not compiled into memory like ASP.net is. It is interpreted at runtime. That is the reason why PHP coding leads to better speed and even efficiency. However, it must be said that both PHP and ASP.net can run at supreme speeds and efficiency when they are coded expertly.
  • Talking about hosting charges, both PHP and ASP.net are quite cheap to host. If We do a good deal of shopping online, We will also be able to find hosting for as little as $4. While there are several pricier hosting services out there, their charges are higher for both PHP and ASP.net. Hence, it can be said that both PHP and ASP.net are at par with each other on the hosting charges.
  • Since PHP is older, there are many people who claim that it is much more secure than ASP.net where coding is concerned. ASP.net is much new, and the security options may not be fully in place yet. However, many programmers will pooh-pooh at this point, because they maintain that security in coding does not depend on the language that is used, but in the way that the coding is done by the coder. Even so, there is a lot of talk on the Internet about PHP coded sites being more difficult to hack into than those done with ASP.net.

Hence, there is a lot to debate on about the worthiness of PHP over ASP.net or vice-versa. There is probably no end to it, and there never shall be. The problem mainly is that both of them are good in their own place, but people who have been staunchly using PHP for several years now – some of them for more than a decade – would certainly not like to go in for the new ASP.net. The price to be paid is quite high, i.e. learning a whole new syntax and getting used to it. That is more the reason why PHP is still so popular.

But, to ASP.net’s credit it must be said that it is much more dynamic, even if the mere use of different languages are concerned. While PHP is still stuck to its scripting language days, ASP.net has broken new grounds by entering into new languages, and even developing some of its own. However, a new shadow is looming large on these language-programming tools – the coming of the WYSIWYG editors such as Dreamweaver, which are making coding a very simple task to do for even the lay computer user.

FullText Search Solutions

Types of FullText Search Solutions

  • Special Database Features
    • MySQL Full Text Search, Sienna
    • Solutions exists for PostgreSQL, Oracle and many others
  • Home baked database based solutions
    • Using stored procedures or set of queries and keyword tables for search
  • External Full Text Search Solutions
    • Lucene, Sphinx, Mnogosearch etc.

My Thoughts on Performance

  • Lucene and Sphinx both can handle large data sizes
  • Lucene has more features, dynamic updates
  • For the lamp developer use the Zend Framework’s Lucene Search which is based on Lucene but it will not work on php 4.
  • speed of fulltext search in lucene is much faster as compared to mysql
  • lucene is much more complex to use as compared to mysql.
  • lucene does not allow us to modify a document. Modifying a document is equivalent to deleting the current document and adding the modified document to the index.
  • lucene requires an object of the index to perform the search. We will know about it when we use the api. Whenever we add a new document to the index, a new object of the index has to be created to include the new document in the index. But creation of a new object is not a major overhead. Though it does slow down the searching process to some extent.
  • MySQL FullText Search is good for Small (relatively) data sizes

MySQL FullText Search and Updates

  • Simple: In mysql, we can simply mark an index on a text/varchar column as fulltext, and our work is done. All we need to do next is to fire MATCH AGAINST queries. Adding and modification of indexes is handled by mysql internally as and when new data is added.
  • MyISAM FullText Search is based on BTREE
    • Special form of BTREE index
  • Each word is index entry
  • Updating text with 1000 words – 1000 key entries needs to be updated
    • A lot of random IO if index is not in memory
  • Index degradation by fragmentation
    • Run OPTIMIZE TABLE for best performance
  • Minimum Length: With mysql we have the minimum length of word to be indexed which is by default 4. So all words which have less than 4 characters will not be indexed. What will we do if we want to index words like “php”, “asp”, “c”? We will have to decrease the minimum length from 4 to 1. And this will increase the index size drastically and slow down all our searches as a consequence. There are no such issues in lucene.

Lucene

Lucene is a free/open source information retrieval library, originally implemented in Java by Doug Cutting. It is supported by the Apache Software Foundation and is released under the Apache Software License. Lucene has been ported to programming languages including Delphi, Perl, C#, C++, Python, Ruby and PHP.

  • Popular full text search Library written in Java
    • http://lucene.apache.org/
    • Clucene – C port exists, but is not current
    • Is not specially tailored for indexing databases
    • Some coding is needed for integration
  • Dynamic index changes possible
  • Very Advanced query language
    • Wildcard searches:
    • Search in Fields: title:”The Right Way” AND text:go
    • Proximity Searches, Fuzzy Searches etc
  • Supports attributes (indexed and non indexed)
  • Some CJK Support
  • Easily integrates with Java

Sphinx Search

  • Designed for indexing Database content
  • Focuses
    • High performance
    • Search Quality
    • Ease of use
  • Supports multi-node clustering out of box
  • Support Multiple Attributes
  • Different sort modes (relevance, data etc)
  • Supports trend queries
  • Support for snippets
  • Client available as MySQL Storage Engine plugin
  • Number of limitations
  • no partial word searches, hard to update indexes

Tbgsearch

  • Very fast for medium size data sizes
  • Only boolean searches available

MySQL’s FEDERATED storage engine

One of the most exciting features introduced in MySQL 5 is the federated engine. The ability to access data from a remote server without the constraints of replication tickles every programmer’s fancy. The Federated engine allows a DBA to create logical pointers to tables that exist on other MySQL servers and thereby link together separate data islands to form one or more logical databases. The Federated storage engine of MySQL is extremely easy to use and set up, and can quickly turn into a DBA’s best friend if they have to answer customer demands to correlate data that exists on several different physical servers.

Let’s take a quick walk :

  1. MySQL Version: We can validate that our installation has Federated by issuing a simple SHOW ENGINES command from the mysql client program. The FEDERATED storage engine is available beginning with MySQL 5.0.3. It is a storage engine that accesses data in tables of remote databases rather than in local tables.
  2. File Structure: When we create a FEDERATED table, the server creates a table format file in the database directory. The file begins with the table name and has an .frm extension. No other files are created, because the actual data is in a remote table. With the MySQL FEDERATED storage engine, there are no local data files for a table (for example, there is no .MYD file).
  3. Data in Remote Server: A Federated table acts as a pointer to an actual table object that exists on the same or another server. Once this link/pointer has been established, we can perform whatever operations we would like on the remote object (inserts, updates, deletes, reads, etc.), as long as we have been given the privileges to do so. The local server connects to a remote server, and uses the MySQL client API to read, delete, update, and insert data in the remote table.
  4. Capability: Understand that our capabilities on the remote object are restricted to the underlying engine that is serving as the source of the Federated table. For example, if we create a Federated table that is pointing to a MyISAM table on another server, we do not have transaction (commit/rollback) capability. Likewise, a Federated pointer to an Archive engine table would not allow us to update or selectively delete data as Archive tables allow reads and inserts only.
  5. Communication: The local server communicates with the remote server using MySQL client C API functions. It invokes mysql_real_query() to send the statement. To read a result set, it uses mysql_store_result() and fetches rows one at a time using mysql_fetch_row().

How to Use:

Normally, we have two mysql servers running, either both on the same host or on different hosts.

On the remote server, we have:

CREATE TABLE `city_remote` (
  `city_id` int(11) NOT NULL auto_increment,
  `name` char(35) NOT NULL default '',
  `country_code` char(3) NOT NULL default '',
  `district` char(20) NOT NULL default '',
  `population` int(11) NOT NULL default '0',
  PRIMARY KEY  (`city_id`)
) ENGINE=MyISAM;

To use that table in our local server, enter the description:

CREATE TABLE `city_local` (
  `city_id` int(11) NOT NULL auto_increment,
  `name` char(35) NOT NULL default '',
  `country_code` char(3) NOT NULL default '',
  `district` char(20) NOT NULL default '',
  `population` int(11) NOT NULL default '0',
  PRIMARY KEY  (`city_id`)
) ENGINE = FEDERATED
connection='mysql://user:pass@remote.com:3306/world/city_remote';

Here, user and pass are valid credentials to access the table city_remote in the database world on server remote.com. The structure of these tables must be exactly the same. With that done, we can query your federated table as if it were in our local server. Issue a query and get a record set.

select * from city_local where city_id = 1;

+----------+--------+----------------+----------+--------------+
| city_id  | name   | country_code   | district | population   |
+----------+--------+----------------+----------+--------------+
|  1       | Noida  | IN             | Noida    |    3000000   |
+----------+--------+----------------+----------+--------------+

There are a few limitations concerning federated engine usage, namely:

  • The remote table must exist when you create your local one.
  • DDL operations are not supported through the Federated engine (ALTER TABLE, etc.).
  • We can’t issue ALTER TABLE commands on a federated table.
  • The federated table is not aware of any structural changes that may occur in the remote one. You may get an error at runtime. The structure definitions of both the source and federated object must stay identical.
  • Transactions are not supported (should be in version 5.1).
  • Query cache support is not enabled.
  • Any DROP TABLE statement issued against a FEDERATED table drops only the local table, not the remote table.
  • FEDERATED tables do not work with the query cache.

MySQL Step-by-Step Installations

If you are on Fedora or Red Hat Box

1
$ setenforce 0 #disbles selinux temporarily

$ yum install mysql

If you have a rpm then

1
$ rpm -i <strong><strong><code>/mysqlSRC_RPM_Folder/MySQL*



You can download rpm’s from http://www.mysql.org

1
2
$ restorecon -R /var/lib/mysql/ #restore selinux labels
$ setenforce 1 #enable selinux again

Now, I successfully installed MySQL. Now I wanted to change the location of where the actual data would be stored, I tried configuring the my.cnf file and using symlinks. I found using the symlinks to be easier and more compatible.

My data directory is /home/mysql.

The following is what I did to change the data directory after using RPM to install.

1
2
3
4
5
1. stop mysql server
2. mkdir /home/mysql
3. mv /var/lib/mysql/* /home/mysql/
4. rmdir /var/lib/mysql
5. ln -s /home/mysql /var/lib/mysql

Instead of using symlinks,we can just modify the my.cnf file (/etc/my.cnf)  by including “datadir = /home/mysql”

1
2
6. chown -R mysql:mysql /home/mysql
7. start mysql server again

MySQL Performance

MySQL Performance: Replication, Partition and Memcached

3 main step to increase mysql performance:

  1. Split Read and Write
  2. Horizontally partition
  3. Implement Memchache
  4. Setup Replication
  • You can spread your reads with replication, and that helps a lot, but you can’t spread writes (they have to process on all machines) and they’ll eventually consume all your resources. You’ll find yourself adding replicated slaves at an ever-increasing rate to make up for the diminishing returns each additional slave provides.
  • The next logical step is to horizontally partition your dataset onto different master/slave clusters so you can spread your writes, and then teach your application to connect to the correct cluster depending on the data it needs.
  • With memcached you can reduce your database reads to a mere fraction, leaving the databases to mainly do infrequent writes, and end up getting much more bang for your buck, since your databases won’t be blocking themselves doing ACID bookkeeping or waiting on writing threads.

How to setup Memcached server

Few Imp Links for detailed Study: http://www.danga.com/memcached/

Installing memcached


1
2
yum install memcached
yum install php5-memcache

Configure and Setting MemCache

  • After installing these two packages next step is to configure memcached.conf file. ( /etc/memcached.conf )
  • After that edit the memecached.ini file. ( /etc/httpd/conf.d/memcache.ini )

A sample memcache.ini file


1
2
3
4
5
6
7
8
9
10
11
; uncomment the next line to enable the module
extension=memcache.so
[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0
session.save_handler = memcache
session.save_path = "tcp://192.168.1.1:11211?weight=1,tcp://192.168.1.2:11211"

Camand Line Memcache


1
2
memcached -d   ==&gt; Start memcache as a background process
memcached -vv ==&gt; Start memcached as a foreground process

Another method for checking whether memcached was enamble or not is to check the phpinfo() function

php MemChache Conf

php MemChache Conf