Monday, November 22, 2010

XDebug for developing, debugging and profiling PHP


XDebug is one of the essential PHP extensions for PHP developers. The name is a bit misleading, as it implies that it is just a debugging tool. This can put people off, since getting the debugger to work with your personal editor requires an understanding of networking, and can often be confusing. Even if you can't immediately get XDebug to work as a debugger, it is still valuable as a stack trace tool, or as a color coded replacement for PHP's var_dump, or as a code coverage analysis tool, and most importantly as a profiler. In this tutorial I'll attempt to cover installation, and most of XDebug's standard features.

Install XDebug

Anyone who spends any time doing PHP development soon finds that PHP is not a one size fits all world. Thanks to its efforts to be a portable and extensible platform, PHP offers developers a wide array of platforms, installation methods, and configurations. Since XDebug needs to play within the ecosystem of PHP, there are a variety of different ways you can install it including compiling it from source.

The important thing to keep in mind is that XDebug is something you want installed on your development server, not on your production server! For that reason, I'm not going to cover compiling from source. All the installation options are covered in the XDebug manual.

For most people, the easiest way to install XDebug is to use PEAR/PECL. On a unix system that involves running pecl install.

# pecl install xdebug

Upon completion, you can check that everything has installed correctly.

debian:~# pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
xdebug 2.0.5 stable

On a Debian system, the build process included adding an ini file in an include directory that php utilizes to configure its modules, and I did not need to make further adjustments -- just restarted apache. On a 64bit Centos 5.5 install, the php.ini needed to be manually updated. In order to find the location of the xdebug.so, you can run pecl list-files.

[root@localhost ~]# pecl list-files xdebug
Installed Files For xdebug
==========================
Type Install Path
doc /usr/share/pear/doc/xdebug/contrib/tracefile-analyser.php
doc /usr/share/pear/doc/xdebug/contrib/xt.vim
doc /usr/share/pear/doc/xdebug/Changelog
doc /usr/share/pear/doc/xdebug/CREDITS
doc /usr/share/pear/doc/xdebug/LICENSE
doc /usr/share/pear/doc/xdebug/NEWS
doc /usr/share/pear/doc/xdebug/README
src /usr/lib64/php/modules/xdebug.so

When you run the pecl install you'll see an erroneous message indicating that you should add an extension=xdebug.so to your php.ini. IGNORE THIS!!!
You actually need to load XDebug using either:

; Enable xdebug
zend_extension="/usr/lib64/php/modules/xdebug.so"

--or if you're setup with the threaded environment that has enabled "thread safety" then:

; Enable xdebug
zend_extension_ts="/usr/lib64/php/modules/xdebug.so"

The cleanest way to set this up under Centos is to create a file in the /etc/php.d directory named xdebug.ini. You can also just manually add the lines above to your php.ini file. The comment "; Enable xdebug" isn't necesssary but it's helpful for documentation purposes to have it, so why not?
If you've followed these instructions and you still don't see xdebug in your phpinfo() page, make sure you have permanently disabled selinux, as it can interfere with the ability for php to load the XDebug module.

Once you've installed XDebug, an XDebug section will be visible in the phpinfo() page, along with a list of default settings.

var_dump()


One of the first things that XDebug will do by default is replace php's var_dump() with a nicer version that is also configurable in a variety of ways.
In this example, I've inserted:

var_dump($mainframe); die();

--into the index.php file for the CMS joomla. The $mainframe object is the main application/controller object for Joomla, so inspecting it might be useful for understanding more about how Joomla works. Without XDebug, this is what the output looks like:

object(JSite)#2 (7) { ["_clientId"]=> int(0) ["_messageQueue"]=> array(0) { } ["_name"]=> string(4) "site" ["scope"]=> NULL ["_errors"]=> array(0) { } ["requestTime"]=> string(16) "2010-10-09 23:56" ["setTemplate"]=> string(13) "rhuk_milkyway" }


With it turned on we get this:
xdebug_vardump

XDebug adds nesting, color coding and scope identification to the output.
Consider a more complicated object:
xdebug_novardump2
Trying to make sense out of all this jumbled output isn't easy. With XDebug you can see the forest through the trees.

xdebug_vardump2

Stack Trace dump


A stack dump is what PHP spits out when you have a runtime error in your script. During development you want to have display_errors turned on, so you can easily see these when they occur. Vanilla PHP might show you something like:

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (tutorials)' in /var/sites/flingbits.com/library/Zend/Controller/Dispatcher/Standard.php:248 Stack trace: #0 /var/sites/flingbits.com/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/sites/flingbits.com/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /var/sites/flingbits.com/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /var/sites/flingbits.com/public/index.php(10): Zend_Application->run() #4 {main} thrown in /var/sites/flingbits.com/library/Zend/Controller/Dispatcher/Standard.php on line 248

With XDebug, your Stack dump looks like this:
xdebug_stack1
The XDebug version is not only a lot easier to read, but it also adds profiling and memory usage information to the trace. However, there are a number of additional options you can turn on to make this even more useful.

xdebug.collect_params

This setting will provide you a variable level of information about parameters being passed. Setting this to "4" gives you the maximum amount of parameter information available.

xdebug.collect_params=4


xdebug.show_local_vars=1

This is a kitchen sink setting that will dump out every variable in the local scope. In a smaller application or when confronted with a particularly confusing problem, this might be useful, but in most cases where you have a script of any sophistication, it simply produces too much output.

Dumping superglobals

You can add some or all of the various superglobals to your stack trace, by setting the xdebug.dump.SUPERGLOBALNAME=*.
For example:

xdebug.dump.SESSION=*
xdebug.dump.COOKIE=*
xdebug.dump.GET=*
xdebug.dump.POST=*
xdebug.dump.FILES=*
xdebug.dump.REQUEST=*
xdebug.dump.ENV=*
xdebug.dump.SERVER=*

Most of the time, you will probably want to limit the output to a handful of commonly useful variables, so instead of setting the variable to the wildcard '*', you can instead pass a list of the specific variables you are interested in.
For example:

xdebug.dump.SERVER=SCRIPT_FILENAME,REQUEST_METHOD,QUERY_STRING,HTTP_COOKIE,REMOTE_ADDR


Profiling


The XDebug profiler outputs "cachegrind compatible files" that can be analyzed with a variety of tools, depending on your platform. If you're developing on a linux workstation use kcachegrind, or on windows wincachegrind.

The best way to enable profiling is to set XDebug so that you can pass a parameter to the script via a GET, POST or COOKIE that will enable it. There's also a setting that defines the name of the cachegrind file(s) generated. I recommend these settings, and by default your files will be deposited in the /tmp directory of the server.

;profiling
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_name=cachegrind.out.%s.%t

Now you can selectively trigger profiling by passing a GET param in the URL:

http://www.gizlocal.com/?XDEBUG_PROFILE

Once the script has run, you should find the profile output file in your temp directory. The file will be namedcachegrind.out.{path_and_filename}.{timestamp}

Using these settings will allow you to generate multiple profilings for the same script, as well as allowing you to easily identify the script that actually generated the profiling data.


debian:/tmp# ls -lath | grep cachegrind*

... 4.5M 2010-11-16 13:04 cachegrind.out._var_sites_flingbits.com_public_index_php.1289941492


Once you have a profiling data file, you will need to load it into an analysis tool. There are analysis tools available for most common operating systems, although the features of the various tools differs. For an Xwindows Linux workstation, KCachegrind provides the timing and call data as well as graphical visualizations like the "Call Graph" screen. WinCacheGrind is a native windows application which doesn't provide graphs, but does show the calls and timings, and allows you to sort the profile data in a variety of ways. Here's a screenshot showing the functions which take the most time.

xdebug_profile

Regardless of the tool, your primary goal is to determine which blocks of code are taking the most time. The analysis tool will show you how many times each function was called, along with aggregate and average execution times. Often you will have functions or methods that call other functions. The local time is totalled seperately from the cumulative time so you can determine where the majority of the time is being spent.

Debugging


Getting the XDebug remote debugger to work with your favorite IDE will probably require looking up configuration instructions for your IDE. These settings are typical, and reflect the process of setting things up to work with Eclipse PDT.
Remember that whenever you make changes to any of these serverside settings, in the php.ini or an included .ini, you must restart Apache!

The first thing you need to do is configure XDebug on your server to turn on remote debugging support. While a number of these settings are also the default it doesn't hurt to include them, in case you need to make tweaks.

;Debugger
xdebug.remote_enable=1
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.idekey=ECLIPSE_DBGP
xdebug.remote_handler=dbgp
xdebug.remote_host=10.1.0.2

Reviewing these settings:
-- you need to enable the debugger using xdebug.remote_enable=1.
-- The xdebug.remote_port is the port the debugger will use to connect back to your IDE once the debugging session is started. It defaults to port 9000.
-- xdebug.idekey needs to be set to whatever your IDE will use to instantiate the session. This gets passed as a url parameter by the eclipse debugger as ?XDEBUG_SESSION_START=. For Eclipse with PDT, the session id will be ECLIPSE_DBGP. For other IDE's or editors that support XDebug this could very well be something different. Ultimately it is an identification mechanism, which simply has to be agreed upon for the editor to connect to XDebug. When everything is setup correctly, you can expect to see something like this in the browser URL when your eclipse debug sessions starts.

http://www.gizlocal.com/?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=12900687508406


-- xdebug.remote_handler specifies the debug protocol, which in this case should be dbgp.
-- Last but not least, the xdebug.remote_host needs to be an IP address for your workstation that can be reached by the server. If for example, your workstation is behind a NAT firewall, you'd have to setup a port forward rule for your workstation that forwards port 9000 traffic back to your workstation. If you're using a WAMP or virtual server environment using VMware or Sun Virtualbox, then chances are this is going to be an internal IP address like the one I included in my example. I highly recommend using a virtual server for your development environment.
If you're not sure how to do this, I have a detailed 2 part article on setting up your own virtual Centos Lamp server running inside Sun Virtualbox on a PC running Windows here.


Configuring Eclipse PDT for XDebug


There are many things that can go wrong with the debugging configuration. Keep in mind that Eclipse PDT's debugger is generic and setup to support different debuggers. This section is not meant to be exhaustive, but should give you an idea of how to get started.
When the debug session starts and your workstation browser is opened, you should see a valid URL (see above) and the page should be blank. If the full page is displayed this is a good indication that you need to check your settings, and that Eclipse didn't connect to XDebug!

When configuration is complete you will open the PHP Debug perspective, and choose a debug configuration. For any specific script you want to debug, you'll need to create a Debug configuration for it. In other words, if you reach a script via a particular URL, you'll need a debug configuration unless it can be reached via another script that you have already setup. For a framework style application, you can set skip to the points you're interested in via breakpoints, but you'll need to have the files you want to set breakpoints in, open in the IDE, and then once you start the debugger, you switch to the file you want to set the breakpoint in, and choose "Run to line". It's not pretty but it works.

From the Menu choose the Run | Debug Configurations panel.

xdebug_eclipse_config1

-- When you get into this panel, give the Debug configuration a name representing the script. This will make it easy for you to choose the right config to debug. In this example, I called it "Index" because I'm debugging the index.php of this framework application.
-- Set the server debugger to XDebug.
-- Browse your project and find the script you want to debug. The script has to actually be executable.
-- Uncheck URL - Auto Generate. This is bugged in my version of Eclipse PDT, and it also seems to add slashes in the neighboring path box that you want to clear out whenever you see them.
-- Save
-- Reopen your freshly created debug configuration, and now "Add" a new PHP Server.

xdebug_eclipse_config2

-- Give this a name representing your development server that is running XDebug.
-- Enter the domain name, and provide a path if you've got an application running in a subdirectory off the site root. Leave off the closing '/'!
-- The configuration wizard will take you to the next step, which is adding at least one "Path Mapping".

xdebug_eclipse_config3

-- This maps the base location for your workspace files to the path on the server.

Ready to debug?

If everything has gone as planned you should now have a working configuration. Change to the "PHP Debug" perspective. Click on the Debug button, and choose your Debug configuration based on the name you gave it when you set the configuration up in eclipse. You can switch to the browser and should see it loaded with the proper url and the added XDebug parameters discussed previously. The screen should be blank and Eclipse should load up the debugged file into the editor, fill the variable window and set things so that you can step through the code using the "step into", "step over", and "step and return" buttons on the debug button bar.

xdebug_eclipse

Summary


XDebug is more than a debugger, even though for PHP it can be used as one. It's an invaluable development tool that will help you during the development process. Hopefully you learned more about how to set it up and start to make use of it. If you have questions or comments, reply here or make a thread in the forum.

Original Article Source:
http://www.flingbits.com/tutorial/view/xdebug-for-developing-debugging-and-profiling-php

Wednesday, July 21, 2010

Making SEO Friendly Websites

Website designing does not only involve giving it an attractive and professional look. It must bring in more business output. For this the website has to have a good page rank with all search engines.

The basic idea of creating a successful website is to make it SEO friendly. This means to say that before building a website you must conduct an extensive and in depth research about the keywords for the content and name of the website, the competition it faces from the other websites that provides same service and information.

But this doesn’t mean that creating a SEO friendly site is hard. All you need is a proper conception and in-depth knowledge about search engine optimization and how to plan your strategies to give the website a healthy page rank on the search engine results.

Here are a few tips for making a SEO friendly site:
Make sure that the website doesn’t take much time to load as this would make the visitors to drift away to other websites and you shall be losing customers and hence revenue.

The HTML codes must not have error. This shall show broken and ineligible elements in the website and thus greater chances of miscommunication and you shall loose repeat visitors to your website.

The keywords that are to be used must be well researched and placed with proper density that can bring about proper page rank in search engine listing.

Do not use too much designer font style that would make the content ineligible. The main purpose is to communicate with the visitor and achieve the goal. Miscommunication would destruct the whole purpose.

Give emphasis on pictures. As the saying goes a picture says thousand words. Not only would it make the website attractive, at the same time it would help to communicate with the visitor with much less chances of miscommunication.

The sole purpose of search engine optimization is to achieve a good page rank in the search engine results and bring in more visitors. Whatever you do make sure that the website is user friendly and that it attracts more and more visitors and helps in enhancing business output.

Monday, March 22, 2010

Image Selection solutions for a Web Design Company

A web page is constructed for attracting a viewer and the more a viewer stays in a particular page, the more profitable a website becomes, particularly for the business websites.

Visitor retention is the ultimate objective of website design. A number of methods are being employed for enhancing the overall look and feel of a website and among them image insertion plays a pivotal role. Graphical elements, like images and animations play a vital role in making a web page attractive and alluring. Therefore, the web design company that includes elegant and useful images to convey vital messages for the website is considered to be a good website design company. Also, images should not be more that 2-3 for a particular page. There are certain aspects that are to be followed before inserting an image while doing a website design.

A website design company should look after certain things before choosing images for a particular website. It is totally depending on the requirement of the client that an image is chosen. Also, the image is chosen as per the budget that is allotted for a web page. Sometimes clients themselves provide images that are mandatory to be used in a particular page. In other cases, website design company chooses images for their own client. This is done as per the money estimate that is provided by the client.

Some of the things that a website design company should remember while making use of images:

• Image resolution and size: Depending on the budget estimate and also the size of the web page, a particular image is selected. This image is to be placed in such a way to fit in the page properly and in a place that never blocks or disturbs any other part of the page. A good website design company always chooses an image that has the same of nearly the same dimension of the image placeholder.

• Meaningful Images: The images that convey the ideas of the web page are to be selected. Also, minimal number of images is to be placed in a page that matches with the content of the page.

• Images in header: Header images are to be chosen in a particular way to focus the purpose and objective of the site.

• Use of genuine images: The images that are to be placed in a web page should be cleared from any type of copyright problems.

Web Design and the Use of SEO

For a successful web design it is essential to build a web page that is very much visible over the net. For that it is necessary to optimize the page in a way to get it easily through search engine tools. Web development is not at all simple and it requires a lot of technical planning before a web page is built. The first and foremost thing that a web development company should take care of is the search engine optimality issue and accordingly the site should be built. The basic purpose of web design is to build an effective web site that can be easily obtained through any of the standard search engine.

The basic thing that should be taken care while building a particular web page is that the requisite keywords are chosen properly and in accordance to the utility of the site. The content should be written in a way to make use of as much keywords as possible so that the search engine crawlers can hunt it easily. A web page is consisted of several other components. These can be images, down-loadable links, video files, music files or some other external links. For any types of media files a particular ID is allotted so that it can be found easily when given a search.

The purpose of SEO is to make the entire component of a web page visible and search-able with a standard search engine. The Content should be the prime focus for any of the web site and web content writing involves maximized use of the relevant keywords. The keywords are to be chosen keeping in mind the simplicity of the phrases. Mostly commonly used phrases are allotted as keywords and these are included in the content to make a meaningful content.

Also, a website design company plans to keep the layout simple and easy for the search engine crawlers to retrieve the required keywords. In all, the effectiveness of a good web design fully depends on the strong SEO planning and development.

Monday, February 8, 2010

Microsoft Q&A: Microsoft and Open Source

by Tomas Gonsorcik on Feb 8, 2010 5:59:06 PM - 90 views

Microsoft has continued to engage with the open source community over the last year. Following up on the Q&A from last May, they would like to share their progress as well as hear your thoughts on how you see PHP working on Windows Server and Microsoft stack in general.

The improvements include:

  • SQL Server driver for PHP
  • Windows Cache Extension 1.0 for PHP
  • Integration into open source Content Management System (CMS) with platforms such as Wordpress and Drupal

There is a good deal of work being done on making PHP run on Azure as well.

Now they would like to hear about the impact of these improvements on your work and what could be done in future to help your apps interoperate with Microsoft stack better.

We decided to restart a dedicated board for the Microsoft Q&A to run a Q&A session with Tom Hanrahan, Director of Microsoft’s Open Source Technology Center, where we ask you to post questions and comments for Tom.

On February 22 at 4.30 GMT, Tom will join the forum and answer all your questions. He will also stay on the forum for the day with his technical team to answer that arise during the live session.

We invite you post your questions freely and with intention to improve your experience with PHP interop. This is an exclusive opportunity to shape the future release of PHP for Windows Server as well as exciting new technologies like PHP on Azure.

We look forward to hearing from you. Ask your questions in the forum now.

Source: http://www.phpfreaks.com/blog/microsoft-qa-microsoft-and-open-source


Media Buying - Media buying & planning, including digital from Space & Time Media


Creativity in Education - Creativity is not unique to the arts. Creativity in education is equally important in mathematics, science, technology, in business - indeed in all areas of life. Neither is creativity simply about letting go, after all creative achievement relies on knowledge, control of materials and command of ideas.



no exam life insurance

Thursday, December 3, 2009

50 Extremely Useful PHP Tools

By Jacob Gube

PHP is one of the most widely used open-source server-side scripting languages that exist today. With over 20 million indexed domains using PHP, including major websites like Facebook, Digg and WordPress, there are good reasons why many Web developers prefer it to other server-side scripting languages, such as Python and Ruby.

PHP is faster (updated), and it is the most used scripting language in practice; it has detailed documentation, a huge community, numerous ready-to-use scripts and well-supported frameworks; and most importantly, it’s much easier to get started with PHP than with other scripting languages (Python, for example). That’s why it makes perfect sense to provide the huge community of PHP developers with an overview of useful tools and resources that can make their development process easier and more effective.

This post presents 50 useful PHP tools that can significantly improve your programming workflow. Among other things, you’ll find a plethora of libraries and classes that aid in debugging, testing, profiling and code-authoring in PHP.

Debugging Tools

  • Webgrind
    Webgrind is an Xdebug profiling Web front end in PHP 5. It implements a subset of the features of kcachegrind, installs in seconds and works on all platforms. For quick ‘n’ dirty optimizations, it does the job.

    Webgrind in 50 Extremely Useful PHP Tools

  • Xdebug
    Xdebug is one of the most popular debugging PHP extensions. It provides a ton of useful data to help you quickly find bugs in your source code. Xdebug plugs right into many of the most popular PHP applications, such as PHPEclipse and phpDesigner.
  • Gubed PHP Debugger
    As the name implies, Gubed PHP Debugger is a PHP debugging tool for hunting down logic errors.
  • DBG
    DBG is a robust and popular PHP debugger for use in local and remote PHP debugging. It plugs into numerous PHP IDE’s and can easily be used with the command line.
  • PHP_Debug
    PHP_Debug is an open-source project that gives you useful information about your PHP code that can be used for debugging. It can output processing times of your PHP and SQL, check the performance of particular code blocks and get variable dumps in graphical form, which is great if you need a more visual output than the one given to you by print_r() or var_dump().
  • PHP_Dyn
    PHP_Dyn is another excellent PHP debugging tool that’s open-source. You can trace execution and get an output of the argument and return values of your functions.
  • MacGDBp
    MacGDBp is a live PHP debugger application for the Mac OS. It has all the features you’d expect from a fully featured debugger, such as the ability to step through your code and set breakpoints.

Testing and Optimization Tools

  • PHPUnit
    PHPUnit is a complete port of the popular JUnit unit testing suite to PHP 5. It’s a tool that helps you test your Web application’s stability and scalability. Writing test cases within the PHPUnit framework is easy; here’s how to do it.
  • SimpleTest
    SimpleTest is a straightforward unit-testing platform for PHP applications. To get up and running with SimpleTest quickly, read through this pragmatictutorial that shows you how to create a new test case.

    Simpletest in 50 Extremely Useful PHP Tools

  • Selenium
    Selenium Remote Control (RC) is a test tool that allows you to write automated Web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser. It can be used in conjunction with PHPUnit to create and run automated tests within a Web browser.
  • PHP_CodeSniffer
    PHP_CodeSniffer is a PHP 5 script for detecting conformance to a predefined PHP coding standard. It’s a helpful tool for maintaining uniform coding styles for large projects and teams.
  • dBug
    dBug is ColdFusion’s cfDump for PHP. It’s a simple tool for outputting data tables that contain information about arrays, classes and objects, database resources and XML resources, making it very useful for debugging purposes.

    11 Dbug in 50 Extremely Useful PHP Tools

  • PHP Profile Class
    PHP Profile Class is an excellent PHP profiling tool for your Web applications. Using this class will help you quickly and easily gain insight into which parts of your app could use some refactoring and optimization.

Documentation Tools

  • phpDocumentor
    phpDocumentor (also known as phpdoc and phpdocu) is a documentation tool for your PHP source code. It has an innumerable amount of features, including the ability to output in HTML, PDF, CHM and XML DocBook formats, and has both a Web-based and command-line interface as well as source-code highlighting. To learn more about phpDocumentor, check out the online manual.
  • PHP DOX
    An AJAX-powered PHP documentation search engine that enables you to search titles from all PHP documentation pages.

Security Tools

  • Securimage
    Securimage is a free, open-source PHP CAPTCHA script for generating complex images and CAPTCHA codes to protect forms from spam and abuse.
  • Scavenger
    Scavenger is an open-source, real-time vulnerability management tool. It helps system administrators respond to vulnerability findings, track vulnerability findings and review accepted and false-positive answered vulnerabilities, without “nagging” them with old vulnerabilities.
  • PHP-IDS
    PHP-IDS (PHP-Intrusion Detection System) is a simple-to-use, well-structured, fast and state-of-the-art security layer for your PHP-based Web application.
  • Pixy: PHP Security Scanner
    Pixy is a Java program that performs automatic scans of PHP 4 source code, aimed to detect XSS and SQL injection vulnerabilities. Pixy takes a PHP program as input and creates a report that lists possible vulnerable points in the program, along with additional information for understanding the vulnerability.

Image Manipulation and Graphs

  • PHP/SWF Charts
    PHP/SWF Charts is a powerful PHP tool that enables you to create attractive Web charts and graphs from dynamic data. You can use PHP scripts to generate and gather data from databases, then pass it to this tool to generate Flash (SWF) charts and graphs.
  • pChart – a chart-drawing PHP library
    pChart is a PHP class-oriented framework designed to create aliased charts. Most of today’s chart libraries have a cost; this one is free. Data can be retrieved from SQL queries or CSV files or can be manually provided.

    Chart in 50 Extremely Useful PHP Tools

  • WideImage
    WideImage is a PHP library for dynamic image manipulation and processing for PHP 5. To be able to use the library, you should have the GD PHP extensioninstalled on your Web server.
  • MagickWand For PHP
    MagickWand For PHP is a PHP module suite for working with the ImageMagickAPI, which lets you create, compose and edit bitmap images. It’s a useful tool for quickly incorporating image-editing features in your PHP applications.

PHP Code Beautifier

  • PHP_Beautifier
    PHP Beautifier is a PEAR package for automatically formatting and “beautifying” PHP 4 and PHP 5 source code.
  • PHPCodeBeautifier
    PHPCodeBeautifier is a tool that saves you from hours of reformatting code to suit your own way of presenting it. A GUI version allows you to process files visually; a command-line version can be batched or integrated with other tools (like CVS, SubVersion, IDE, etc.); and there is also an integrated tool of PHPEdit.
  • GeSHi – Generic Syntax Highlighter
    GeSHi is designed to be a simple but powerful highlighting class, with the goal of supporting a wide range of popular languages. Developers can easily add new languages for highlighting and define easily customizable output formats.

Version-Control Systems

  • Phing
    Phing is a popular project version-control system for PHP. It is a useful tool for organizing and maintaining different builds of your project.
  • xinc
    xinc is a continuous integration server version-control system written in PHP 5 (i.e. continuous builds instead of nightly builds). It works great with other systems such as Subversion and Phing.

Useful Extensions, Utilities and Classes

  • SimplePie
    SimplePie is a PHP class that helps you work with RSS feeds. Check out the online RSS and Atom feed reader, which demonstrates a simple Web application that uses SimplePie.

    Spie in 50 Extremely Useful PHP Tools

  • HTML Purifier
    HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier not only removes all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive white list, it also makes sure your documents are standards-compliant. Open source and highly customizable.
  • TCPDF
    TCPDF is an open-source PHP class for generating PDF documents.
  • htmlSQL
    htmlSQL is a unique tool. It is a PHP class for querying HTML values in an SQL-like syntax. Check out the live demonstration of how htmlSQL works.
  • The Greatest PHP Snippet File Ever (Using Quicktext for Notepad++)
    “A little something for all coders: a snippets file that I use for PHP coding. This is designed to be used with Quicktext for Notepad++, but feel free to adapt it to whatever text editor you prefer.”
  • Creole
    Creole is a database abstraction layer for PHP5. It abstracts PHP’s native database-specific API to create more portable code while also providing developers with a clean, fully object-oriented interface based loosely on the API for Java’s JDBC.
  • PHPLinq
    LINQ is a component that adds native data querying capabilities to PHP using a syntax reminiscent of SQL. It defines a set of query operators that can be used to query, project and filter data in arrays, enumerable classes, XML, relational databases and third-party data sources. [via]
  • PHPMathPublisher
    With PhpMathPublisher, you can publish mathematical documents on the Web using only a PHP script (no LaTeX programs on the server and no MathML).

    Math in 50 Extremely Useful PHP Tools

  • phpMyAdmin
    If you’re working with PHP, there’s a big chance you’re set up in a LAMP configuration. phpMyAdmin is Web-based tool for managing, building, importing, exporting and exploring MySQL databases.
  • PHPExcel
    PHPExcel is a set of useful PHP classes for working with Microsoft Excel files. PHPExcel allows you to read Excel files and write to them. This is useful for dynamically generating Excel spreadsheets for downloading.
  • Phormer
    Phormer is a PHP-based photo gallery management application that helps you to store, categorize and trim your photos online.
  • xajax PHP Class Library
    xajax is a PHP class for easily working with PHP AJAX applications. It gives you an easy-to-use API for quickly managing AJAX-related tasks. Check out thexajax Multiplier demo and the Graffiti Wall demo to see the xajax PHP class in action.
  • PHP User Class
    PHP User Class is an excellent script that helps you create a system for user authentication (i.e. registration, log in, account profile, etc.). It’s a useful utility to have around if you require user registration for your Web applications.
  • PHP-GTK
    PHP-GTK is a PHP extension for the GTK+ toolkit (a robust toolkit for developing GUIs). It is a suite of useful OOP functions and classes to help you rapidly build cross-platform, client-side GUI’s for your application.

PHP Online Tools and Resources

  • Minify!
    Minify is a PHP 5 app that can combine multiple CSS or JavaScript files, compress their content (i.e. remove unnecessary white space and comments) and serve the results with HTTP encoding (via Gzip/deflate) and headers that allow optimal client-side caching. This will help you follow several of Yahoo!’sRules for High Performance Websites.

    Minify in 50 Extremely Useful PHP Tools

  • HTTP_StaticMerger: Automatic “merging” of CSS and JavaScript files
    This library automatically merges sets of static files (CSS or JavaScript) and speeds up page loading (by lowering the number of HTTP queries). It is recommended to use this together with caching reverse-proxy to minimize the response time.
  • PHP Object Generator
    PHP Object Generator is an open-source Web-based tool that helps you quickly construct PHP objects and leverage object-oriented programming (OOP) principles in your code.

    03 Object Generator in 50 Extremely Useful PHP Tools

  • gotAPI/PHP
    gotAPI is a useful online tool for quickly looking up PHP functions and classes. Also check out the Quick PHP look-up widget example in case you’d like to include this awesome look-up feature on your website.

    04 Gotapi in 50 Extremely Useful PHP Tools

  • koders
    koders is a search engine for open-source and downloadable code. It currently has over a billion lines of code indexed and isn’t limited to just PHP.
  • PECL
    PECL is a directory of all known PHP extensions and a hosting facility for downloading and developing PHP extensions.

In-Browser Tools (Firefox Add-Ons)

  • FirePHP
    FirePHP is a Firefox extension that allows you to log data in Firebug. It has a variety of useful logging features, such as the ability to change your error and exception handling on the fly and to log errors directly to the Firebug console. To learn more about what FirePHP can do, check out the FirePHP guide onhow to use FirePHP. For developers using the Zend PHP framework, you might find this guide on using FirePHP with Zend useful.

    01 Firephp in 50 Extremely Useful PHP Tools

  • phpLangEditor
    phpLangEditor is a very handy Firefox add-on for translating language files and variables in your script.

    02 Phplangeditor in 50 Extremely Useful PHP Tools

  • PHP Lookup
    PHP Lookup is a built-in search bar to help you quickly look up references to PHP syntax.
  • PHP Manual Search
    PHP Manual Search is a handy search bar that searches official PHP documentation from within your Web browser.

Frameworks for PHP

  • Dwoo
    Dwoo is a PHP 5 template engine positioned as an alternative to Smarty. It is (nearly) fully compatible with its templates and plug-ins, but it is being written from scratch and is aimed to go one step further with a cleaner code base.
  • CodeIgniter
    CodeIgniter is a powerful, high-performance, open-source PHP framework that helps you author PHP applications rapidly. CodeIgniter is known for having a light footprint, thereby reducing your server’s work. You can get up and running with CodeIgniter in a jiffy: it has an awesome online manual, a couple of helpful video tutorials and an active user forum.

    Codeigniter in 50 Extremely Useful PHP Tools

  • YII Framework
    Here is a high-performance component-based PHP framework that is supposed to be more efficient than CodeIgniter, CakePHP, ZF and Symfony. An optimal solution for developing large-scale Web applications. Yii supports MVC, DAO/ActiveRecord, I18N/L10N, caching, jQuery-based AJAX support, authentication and role-based access control, scaffolding, input validation, widgets, events, theming and Web services.
  • NetBeans
    A dedicated PHP coding environment and complete integration with web standards. The NetBeans PHP editor is dynamically integrated with NetBeans HTML, JavaScript and CSS editing features such as syntax highlighting and the JavaScript debugger. NetBeans IDE 6.5 fully supports iterative development, so testing PHP projects follows the classic patterns familiar to web developers.
  • Solar
    Solar is a PHP 5 development framework for Web applications derived from the Savant templating engine. Solar uses the MVC architectural pattern and has a host of classes and functions for securing your Web app against SQL injection, cross-website scripting (XSS) and other common exploits.

    Solar in 50 Extremely Useful PHP Tools

  • symfony
    symfony is an open-source PHP 5 Web application framework that is well known for its modularity and useful library of classes. To get up and running as fast as possible, you should check out the pragmatic symfony online tutorial called “The symfony 1.2 advent calendar tutorial,” which takes you through a step-by-step example of building your own symfony-based Web application.
  • PEAR – PHP Extension and Application Repository
    PEAR is a popular framework and distribution system for reusable PHP components. The purpose of the framework is to provide a structured library of open-source code for PHP users, a system for code distribution and package maintenance and a standard style for PHP code.
  • Propel
    Propel is an Object-Relational Mapping (ORM) framework for PHP 5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.
  • {{macro}} template engine
    {{macro}} compiles initial templates into executable PHP scripts with very clean syntax (much cleaner than WACT and Smarty) and executes them very fast. The engine doesn’t use an XML-like syntax; there are only two data scopes, global and local, and no more data sources (all data is displayed with regular PHP variables); and the system supports all WACT features such as templates wrapping and including.Macro in 50 Extremely Useful PHP Tools
  • Zend Framework
    The Zend Framework by Zend Technologies (the creators of PHP’s scripting engine) is a popular PHP Web application framework that embraces the principles of PHP OOP; it’s very extensible and has built-in utilities for working with free Web service APIs, such as those of Google, Flickr and Amazon.
  • Qcodo
    Qcodo is an excellent open-source PHP Web application framework. It’s subdivided into two parts: (1) Code Generator, and (2) Qforms. Code Generator handles the creation of object code and PHP and HTML front-end code from your data model. Qforms is an intuitive system for handling and creating complex PHP-driven HTML Web forms. Check out demos of applications that use Qcodo and presentational material that covers Qcodo.

    Qc in 50 Extremely Useful PHP Tools

  • SAJAX
    SAJAX is a JavaScript and AJAX application framework that works well with PHP (as well as several other server-side scripting languages). See SAJAX at work by going to Wall live demonstration.
  • Smarty
    Smarty is a popular PHP templating system to help you separate PHP logic and front-end code (HTML, CSS, JavaScript). It will keep your projects modular and easier to maintain.
  • CakePHP
    CakePHP is one of the leading PHP frameworks for creating robust, fully-featured Web applications. CakePHP has an extensive and well-organizedonline manual. If you want to learn via video tutorials, check out the CakePHP screencasts.

    Cake in 50 Extremely Useful PHP Tools

  • Savant2
    Savant2 is another popular object-oriented PHP templating system. Instead of a special syntax unique to Savant2, you use PHP syntax to develop your project’s template.
  • PHPSpec
    PHPSpec is a simple and intuitive PHP framework. It follows the Behavior-Driven Development principle and therefore allows you to write behavior-oriented code, oftentimes in plain English.

PHP IDEs and Editors

  • PHPEclipse
    PHPEclipse is a popular PHP source-code editor that is open source and runs on all the major operating systems, such as Windows, Linux and Mac OS. It has all the features you’d expect from a PHP source-code editor, such as code-folding, syntax highlighting, hover-over tool tips and support for XDebug and DBG.

    07 Php Eclipse in 50 Extremely Useful PHP Tools

  • PhpED
    PhpED is an excellent IDE for Windows users. It is one of the most robust and feature-packed IDEs currently out on the market and has useful features such as a built-in source-code profiler to find bottlenecks in your PHP source code and excellent integration with third-party apps and services just as front-end code validation.

    08 Phped in 50 Extremely Useful PHP Tools

  • phpDesigner
    phpDesigner is a lightweight PHP editor/IDE that also handles front-end code and markup remarkably well. Check out the phpDesigner online tutorials, as well as screencasts on phpDesigner to help you learn more about the IDE.

    09 Phpdesigner in 50 Extremely Useful PHP Tools

  • Zend Studio
    Zend Studio is an excellent PHP IDE for Eclipse. It’ll help you develop, deploy and manage Rich Internet Applications (RIAs) in an intuitive interface.

    10 Zend Studio in 50 Extremely Useful PHP Tools

  • Aptana PHP
    Aptana PHP is an open-source IDE extension/plug-in to be used in conjunction with Aptana Studio. To learn more, be sure to check out the online documentation about Aptana PHP.
  • PDT
    PDT is a PHP Development Tools framework that’s part of the Eclipse project. PDT includes all the necessary tools for you to create PHP-based Web applications.
  • VS.Php
    VS.Php is a PHP IDE for MS Visual Studio, making it a great IDE for recently converted ASP developers who have used MS VS to develop Web applications. To get you up and running ASAP with VS.Php, check out Jcx.Software’s online tutorials as well as its online documentation.
  • PHPEdit
    PHPEdit is an excellent PHP editor/IDE with a ton of useful features and a very intuitive user interface. To learn more about why PHPEdit is a good IDE, read the 10 reasons to use PHPEdit and view the introductory screencast about PHPEdit.

Source: http://www.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/

Software Testing Services

Thursday, November 19, 2009

NoSQL Ecosystem

I found a very interesting article entitled "NoSQL Ecosystem" from The Rackspace Could. It dove into the fact that we need an alternative for relational databases to handle the high volume of data these days. Some examples the article gave:

The fundamental problem is that relational databases cannot handle many modern workloads. There are three specific problem areas: scaling out to data sets like Digg’s (3 TB for green badges) or Facebook’s (50 TB for inbox search) or eBay’s (2 PB overall), per-server performance, and rigid schema design.

It's a good read, I would like to hear your thoughts around this NoSQL Movement idea.

By Jonathan Ellis, Systems Architect

Unprecedented data volumes are driving businesses to look at alternatives to the traditional relational database technology that has served us well for over thirty years. Collectively, these alternatives have become known as “NoSQL databases.”

The fundamental problem is that relational databases cannot handle many modern workloads. There are three specific problem areas: scaling out to data sets like Digg’s (3 TB for green badges) or Facebook’s (50 TB for inbox search) or eBay’s (2 PB overall),per-server performance, and rigid schema design.

Businesses, including The Rackspace Cloud, need to find new ways to store and scale large amounts of data. I recently wrote a post on Cassandra, a non-relational database we have committed resources to. There are other non-relational databases being worked on and collectively, we call this the “NoSQL movement.”

The “NoSQL” term was actually coined by a fellow Racker, Eric Evans when Johan Oskarsson of Last.fm wanted to organize an event to discuss open source distributed databases. The name and concept both caught on.

Some people object to the NoSQL term because it sounds like we’re defining ourselves based on what we aren’t doing rather than what we are. That’s true, to a degree, but the term is still valuable because when a relational database is the only tool you know, every problem looks like a thumb. NoSQL is making people aware that there are other options out there. But we’re not anti-relational-database for when that really is the best tool for the job; it’s “Not Only SQL,” rather than “No SQL at all.”

One real concern with the NoSQL name is that it’s such a big tent that there is room for very different designs. If this is not made clear when discussing the various products, it results in confusion. So I’d like to suggest three axes along which to think about the many database options: scalability, data and query model, and persistence design.

I have chosen 10 NoSQL databases as examples. This is not an exhaustive list, but the concepts discussed are crucial for evaluating others as well.

Scalability

Scaling reads is easy with replication, so when we’re talking about scaling in this context, we mean scaling writes by automatically partitioning data across multiple machines. We call systems that do this “distributed databases.” These include Cassandra, HBase, Riak,Scalaris, Voldemort, and more. If your write volume or data size is more than one machine can handle then these are your only options if you don’t want to manage partitioning manually. (You don’t.)

There are two things to look for in a distributed database: 1) support for multiple datacenters and 2) the ability to add new machines to a live cluster transparently to your applications.

Non-distributed NoSQL databases include CouchDB, MongoDB, Neo4j, Redis, and Tokyo Cabinet. These can serve as persistence layers for distributed systems; MongoDB provides limited support for sharding, as does a separate Lounge project for CouchDB, and Tokyo Cabinet can be used as a Voldemort storage engine.

Data and Query Model

There is a lot of variety in the data models and query APIs in NoSQL databases.

(Respective Links: Thrift, map/reduce views, Thrift, Cursor, Graph, Collection, Nested hashes, get/put, get/put, get/put)

Some highlights:

The columnfamily model shared by Cassandra and HBase is inspired by the one described by Google’s Bigtable paper, section 2. (Cassandra drops historical versions, and addssupercolumns.) In both systems, you have rows and columns like you are used to seeing, but the rows are sparse: each row can have as many or as few columns as desired, and columns do not need to be defined ahead of time.

The Key/value model is the simplest and easiest to implement but inefficient when you are only interested in querying or updating part of a value. It’s also difficult to implement more sophisticated structures on top of distributed key/value.

Document databases are essentially the next level of Key/value, allowing nested values associated with each key. Document databases support querying those more efficiently than simply returning the entire blob each time.

Neo4J has a really unique data model, storing objects and relationships as nodes and edges in a graph. For queries that fit this model (e.g., hierarchical data) they can be1000s of times faster than alternatives.

Scalaris is unique in offering distributed transactions across multiple keys. (Discussing the trade-offs between consistency and availability is beyond the scope of this post, but that is another aspect to keep in mind when evaluating distributed systems.)

Persistence Design

By persistence design I mean, “how is data stored internally?”

The persistence model tells us a lot about what kind of workloads these databases will be good at.

In-memory databases are very, very fast (Redis achieves over 100,000 operations per second on a single machine), but cannot work with data sets that exceed available RAM. Durability (retaining data even if a server crashes or loses power) can also be a problem; the amount of data you can expect to lose between flushes (copying the data to disk) is potentially large. Scalaris, the other in-memory database on our list, tackles the durability problem with replication, but since it does not support multiple data centers your data will be still be vulnerable to things like power failures.

Memtables and SSTables buffer writes in memory (a “memtable”) after writing to an append-only commit log for durability. When enough writes have been accepted, the memtable is sorted and written to disk all at once as a “sstable.” This provides close to in-memory performance since no seeks are involved, while avoiding the durability problems of purely in-memory approaches. (This is described in more detail in sections 5.3 and 5.4 of the previously-referenced Bigtable paper, as well as in The log-structured merge-tree.)

B-Trees have been used in databases since practically the beginning of time. They provide robust indexing support, but performance is poor on rotational disks (which are still by far the most cost-effective) because of the multiple seeks involved in reading or writing anything.

An interesting variant is CouchDB’s append-only B-Trees, which avoids the overhead of seeks at the cost of limiting CouchDB to one write at a time.

Conclusion

The NoSQL movement has exploded in 2009 as an increasing number of businesses wrestle with large data volumes. The Rackspace Cloud is pleased to have played an early role in the NoSQL movement, and continues to commit resources to Cassandra and support events like NoSQL East.

NoSQL conference announcements and related discussion can be found on the Google discussion group.

Source: http://www.rackspacecloud.com/blog/2009/11/09/nosql-ecosystem/