Home

Best JavaScript Frameworks (Libraries)

1 Comment

Best JavaScript Frameworks/Libraries:

1.) JQuery

2.) YUI

3.) Dojo

4.) ExtJS

5.) Prototype

6.) MooTools

7.) script.aculo.us

8.) AngularJS

9.) Backbone.js

10.)Ember.js

References:

http://www.w3schools.com/js/js_libraries.asp

http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks

http://readwrite.com/2014/02/06/angular-backbone-ember-best-javascript-framework-for-you

http://www.infoq.com/research/top-javascript-mvc-frameworks

http://jonathanmh.com/best-javascript-mvc-frameworks-2013-2014/

http://www.infoworld.com/d/application-development/the-10-hottest-javascript-framework-projects-228335

http://designzum.com/2014/02/19/top-best-javascript-framework-2014/

http://code.tutsplus.com/articles/20-javascript-frameworks-worth-checking-out–net-22020

How to use Couchdb NoSQL database on CodeIgniter

Leave a comment

Here I will explain how to use CouchDB NoSQL database on CodeIgniter using PHP On Couch open source library (Data Access Library to access a CouchDB server with PHP).

PHP On Couch tries to provide an easy way to work with your CouchDB documents with PHP.

Here I assume you know PHP and CodeIgniter. If don’t go through http://ellislab.com/codeigniter Its running on your system.

Here is How to use Couchdb NoSQL database on CodeIgniter?

First Download PHP On Couch from here:

https://github.com/dready92/PHP-on-Couch

Setup instructions:

https://github.com/dready92/PHP-on-Couch/tree/master/frameworks/ci

1.) copy the PHP on Couch classes

copy all from /PHP-on-Couch-master/lib/

to /CodeIgniter_2.1.4/application/libraries/

2.) copy the PHP on Couch CI classes

copy from /PHP-on-Couch-master/frameworks/ci/libraries/

to /CodeIgniter_2.1.4/application/libraries/

3.) copy the config/couchdb.php file inside the config folder of your application/libraries/

copy from /PHP-on-Couch-master/frameworks/ci/config

to /CodeIgniter_2.1.4/application/config/

4.) edit the config/couchdb.php file to set the two configuration options couch_dsn and couch_database :

$config[‘couch_dsn’] = “http://localhost:5984/“;

$config[‘couch_database’] = “my_wonderful_db”;

5.) if you want the couchdb object to be autoloaded, edit the config/autoload.php file of your CodeIgniter application and add “couchdb” to the list of libraries to autoload

$autoload[‘libraries’] = array(‘couchdb’);

6.) Thats it!

References:

https://github.com/dready92/PHP-on-Couch/blob/master/doc/couch_client-database.md

https://github.com/dready92/PHP-on-Couch/blob/master/doc/couch_client-document.md

https://github.com/dready92/PHP-on-Couch/tree/master/doc

http://wiki.apache.org/couchdb/Getting_started_with_PHP

http://en.wikipedia.org/wiki/CouchDB

http://couchdb.apache.org/

http://planet.couchdb.org/

http://guide.couchdb.org/editions/1/en/index.html

http://docs.couchdb.org/en/latest/

http://wiki.apache.org/couchdb/

How to Install XHProf function-level hierarchical profiler for PHP on CodeIgniter

Leave a comment

First what is XHProf?

From: https://github.com/facebook/xhprof
XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level call counts and inclusive and exclusive wall time, CPU time and memory usage.

From: http://pecl.php.net/package/xhprof
XHProf: A Hierarchical Profiler for PHP
XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based navigational interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level inclusive and exclusive wall times, memory usage, CPU times and number of calls for each function. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.

There are a number of ways to profile and monitor the performance of PHP code in a development environment, but once it’s been let loose on a production server its extremely difficult to know what’s going on when your app is getting accessed by your users.
In March 2009, Facebook released XHProf, a function level profiler that allows you to identify bottlenecks in your application. And it runs on a production server with little overhead.
XHProf will provide you with a hierarchical profile of the functions your application calls, allowing you to follow the chain of events that lead up to resource intensive code running. You’ll be able to see exactly how much wall time (the actual time elapsed), CPU time and memory your application uses.
This tutorial will help you get XHProf installed on your server, and integrated with your CodeIgniter application via hooks so that you can start profiling your application, in a production environment, straight away. Everything you see here was written for Ubuntu 12.04:

Installation of XHProf can be done via PECL – as per php manual, it’s very hectic get the PECL version installed on Ubuntu. For me it’s easier to install from source.

So here I will explain how to install from source. To install from source we will require “phpize” pecl extension. So first we will install phpize.

In this topic I am assuming a PHP web server running with (Apacpe and PHP).

Step 1.) How to install phpize on ubuntu?

On Debian/Ubuntu, it’s in the php5-dev package, so we will install php dev package.

$ sudo apt-get install php5-dev

It will be available here: /usr/bin/phpize instead of only phpize.

The php5-dev package contains various files absolutely essential to compiling PHP. Since it’s a shell script, you can just copy it from the package, but it won’t work without the dependencies for building a PHP extensions (like header files).

Explanation

In the C world, compiling dynamically linked libraries (DLL/SO) is done by using header files that contain the description on how the libraries are to be interacted with (function calls, structures, etc). These are used to compile an extension without the need for the PHP source code itself. In other words, you don’t need the PHP source but you actually need the header files which are contained in php5-dev.

You can check with phpize cmd

Step 2.) How to install XHProf on ubuntu

To install from source first download source from github (https://github.com/facebook/xhprof/tarball/master)

$ wget https://github.com/facebook/xhprof/tarball/master -O xhprof.tar.gz

if you get error :

–2013-10-28 18:30:29– https://github.com/facebook/xhprof/tarball/master
Resolving github.com (github.com)… 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443… connected.
ERROR: cannot verify github.com’s certificate, issued by `/C=91/ST=UP/L=Noida/O=SRI/OU=SRI/CN=SRI/emailAddress=rakesh.snr@samsung.com’:
Unable to locally verify the issuer’s authority.
To connect to github.com insecurely, use `–no-check-certificate’.

then use this

$ wget --no-check-certificate https://github.com/facebook/xhprof/tarball/master -O xhprof.tar.gz

Extract the tarball and switch into the extracted folder – this will change depending on the latest revision available from GitHub. You can directly download and extract it.

$ tar -xvf xhprof.tar.gz
$ cd facebook-xhprof-ec8b884/extension

Then install as normal.

$ phpize
$ ./configure
$ make
$ sudo make install

Now copy xhprof source to web dir (doc root folder) for viewing the logs and make dog dir inside it.

$ sudo cp -r facebook-xhprof-ec8b884/  /var/www/xhprof/
$ sudo mkdir /var/www/xhprof/log_data
$ sudo chmod -R 777 /var/www/xhprof/log_data/

Note: path of xhproff log dir must be php execute user accessible. Means it must be in /var/www/ dir or accessible to www-dada user as this www-data user execute php script and xhprof log are created by this www-data user.

Finally, we need to tell PHP to load the extension. Create a config file for it – I do this for cleanliness but you can always drop it at the end of your main php.ini.

$ sudo gedit /etc/php5/conf.d/xhprof.ini

And paste in the following:

extension=xhprof.so
xhprof.output_dir="/var/www/xhprof/log_data"

This tells XHProf to use the directory at /var/www/xhprof/log_data to save its run data.
Note: path of xhproff log dir must be php execute user accessible. Means it must be in /var/www/ dir or accessible to www-dada user as this www-data user execute php script and xhprof log are created by this www-data user.
You can check whether XHProf is installed correctly by entering php -m at the command line and checking that the module is available. Remember to restart Apache so that it gets picked up in your PHP web applications as well.

If you want to render the callgraph images you’ll also need the graphviz package. This can be obtained from apt.

$ sudo apt-get install graphviz

Now xhprof ready
With front end – http://localhost/xhprof/xhprof_html/

Home-All-1-XHProf_ Hierarchical Profiler Report - 2013-10-29_17.14.21

Step 3.) Finally how to Integration XHProf with CodeIgniter

First setup codeigniter:
Download codeigniter and extract it in home folder
http://ellislab.com/codeigniter
Copy code to web root folder to make accessible to apache with localhost

$ sudo cp -R CodeIgniter_2.1.4 /var/www/

Now open from localhost CI URL
http://localhost/CodeIgniter_2.1.4/

CodeIgniter

If this works then CI setup ready

XHProf can be used on an ad-hoc basis to evaluate small pieces of code, but it’s at its most useful when you let it profile the full page. First of all, you’ll need to move the XHProf code into your web applications root so that it has access to the appropriate classes.
This already explained in 2nd setup, but again I will explain it.

Copy xhprof source to web dir (doc root folder) for viewing the logs and make log dir inside it or inside doc root to make www-data user accessible and also set writable permission to www-data user. This has been done in 2nd step so it must not be done again.

$ sudo cp -r facebook-xhprof-ec8b884/  /var/www/xhprof/
$ sudo mkdir /var/www/xhprof/log_data
$ sudo chmod -R 777 /var/www/xhprof/log_data/

Note: path of xhproff log dir must be php execute user accessible. Means it must be in /var/www/ dir or accessible to www-dada user as this www-data user execute php script and xhprof log are created by this www-data user.

http://localhost/xhprof/xhprof_html/

CodeIgniter has an excellent mechanism for injecting custom code into the execution of a page called ‘Hooks’. This is what we’ll use to integrate XHProf with your application.
Enable hooks in your application/config/config.php file.

$ sudo gedit /var/www/CodeIgniter_2.1.4/application/config/config.php

application/config/config.php file :
//set enable_hooks to true

$config['enable_hooks'] = true;

// and

/*
 XhProf config
*/
$config['xhprof_lib_dir'] = '/var/www/xhprof/log_data/';
$config['xhprof_ui_url'] = 'http://localhost/xhprof/xhprof_html/index.php';
$config['xhprof_flag'] = TRUE; // TRUE / FALSE to enable and disable

Then specify your hooks in application/config/hooks.php

$ sudo gedit /var/www/CodeIgniter_2.1.4/application/config/hooks.php

application/config/hooks.php file:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/

$hook['pre_controller'] = array(
 'class' => 'XHProf',
 'function' => 'XHProf_Start',
 'filename' => 'xhprof.php',
 'filepath' => 'hooks',
 'params' => array()
);

$hook['post_controller'] = array(
 'class' => 'XHProf',
 'function' => 'XHProf_End',
 'filename' => 'xhprof.php',
 'filepath' => 'hooks',
 'params' => array()
);

$hook['post_system'] = array(
 'class' => 'XHProf',
 'function' => 'XHProf_list_runs',
 'filename' => 'xhprof.php',
 'filepath' => 'hooks',
 'params' => array()
);

/* End of file hooks.php */
/* Location: ./application/config/hooks.php */

Then create the hook that will load XHProf into your application at application/hooks/xhprof.php. This class will provide the necessary minimum to get XHProf collecting data from your application.

$ sudo gedit /var/www/CodeIgniter_2.1.4/application/hooks/xhprof.php

application/hooks/xhprof.php file:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class XHProf {

 private $XHProfPath = '/var/www/xhprof/';
 private $applicationName = 'my_xhprof_CI';
 private $sampleSize = 1;
 private static $enabled = false;
 private $suffix = 'xhprof';
 private static $xhprof_flag = false;

var $CI;

 public function XHProf_Start() {
 self::$xhprof_flag = config_item('xhprof_flag');
 if (self::$xhprof_flag && mt_rand(1, $this->sampleSize) == 1) {
 include_once $this->XHProfPath . 'xhprof_lib/utils/xhprof_lib.php';
 include_once $this->XHProfPath . 'xhprof_lib/utils/xhprof_runs.php';
 xhprof_enable(XHPROF_FLAGS_NO_BUILTINS);
 self::$enabled = true;
 }
 }

 public function XHProf_End() {
 if (self::$xhprof_flag && self::$enabled) {
 $XHProfData = xhprof_disable();

$XHProfRuns = new XHProfRuns_Default();
 $this->CI =& get_instance();

$name = $this->applicationName;
 $className = $this->CI->router->class;
 if(!empty($className))
 $name .= '_' . $className;
 $methodName = $this->CI->router->method;
 if(!empty($methodName))
 $name .= '_' . $methodName;

$XHProfRuns->save_run($XHProfData, $name);
 }
 }

function XHProf_list_runs() {
 if (self::$xhprof_flag && self::$enabled) {

$this->CI =& get_instance();

$name = $this->applicationName;
 $className = $this->CI->router->class;
 if(!empty($className))
 $name .= '_' . $className;
 $methodName = $this->CI->router->method;
 if(!empty($methodName))
 $name .= '_' . $methodName;

 $xhprof_lib_dir = config_item('xhprof_lib_dir');
 $xhprof_ui_url = $this->CI->config->item('xhprof_ui_url');

if (is_dir($xhprof_lib_dir)) {

 echo "<hr/>Current runs:\n<ul>\n";
 $files = glob("{$xhprof_lib_dir}/*.$name.{$this->suffix}");
 usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
 $f = true;
 foreach ($files as $file) {

 list($run,$source) = explode('.', basename($file));
 echo '<li><a href="' . htmlentities($xhprof_ui_url)
 . '?run=' . htmlentities($run) . '&source='
 . htmlentities($source) . '" target="_blank">'
 . htmlentities(basename($file)) . "</a><small> "
 . date("Y-m-d H:i:s", filemtime($file)) . "</small></li>\n";
 if($f)
 {
 $f = false;
 echo "</ul>\n<hr/>Older runs:\n<ul>\n";
 }
 }
 echo "</ul>\n";
 }
 }

 }

}

?>

Now open from localhost CI URL
http://localhost/CodeIgniter_2.1.4/

Welcome to CodeIgniter - 2013-10-29_17.16.59

If you see this then it works

There’s a few thing to point out in this code sample.

• The $XHProfPath variable should point to the directory you installed XHProf in as explained in step 2 and also above in this step. In our example, we put it in the root of the web application, but you might be storing it somewhere central and symlinking it to multiple applications.
• The $applicationName variable lets you specify the name of the application using XHProf. This could be especially important in an environment where you’re running multiple applications on the same server.
• The $sampleSize variable lets you specify a factor for how often XHProf profiles a run. In a production environment where you’re receiving thousands of hits, it’s probably not worth storing every single run. You can increase this variable to get a random sample of runs. Changing it to 10, for example, will give you a report from one in every 10 visits to your application.

The xhprof_enable() function can accept any combination of 3 constants.

• XHPROF_FLAGS_NO_BUILTINS – skip all internal php functions. Adding this means you’ll only see time spent in functions that you have written (or are part of CodeIgniter)
• XHPROF_FLAGS_CPU – add additional CPU profiling information
• XHPROF_FLAGS_MEMORY – add additional memory profiling information
• Combine them using +. eg. xhprof_enable(XHPROF_FLAGS_NO_BUILTINS + XHPROF_FLAGS_MEMORY);
After running through your application a couple of times, point your browser at the XHProf application directory http://localhost/xhprof/xhprof_html/index.php – adjusting for the address of your development server – and you’ll see a list of your last application runs with the newest at the top. Select one of the runs to see its profiling information.

Home-All-XHProf_ Hierarchical Profiler Report - 2013-10-29_17.14.21

Evaluating the Results
Storing all this profiling information is all very well and good but knowing how to evaluate it is the key to optimizing your application.
The ‘Overall Summary’ is a good place to start – it’ll show you:
• Total inclusive wall time – how long (in microseconds) it took for you page to be generated
• Total memory use – the total memory used by this run of your application
• Total peak memory use – the maximum amount of memory that was used by your application
• Number of function calls – the number of functions that were called by your application

XHProf_ Hierarchical Profiler Report - 2013-10-29_17.17.24

These numbers should give you an overall base to start from and provide headline numbers to compare against when you start optimization.
Below the summary is the detailed run report the bottlenecks in your application should be fairly obvious – they’re the function calls at the top of the report.

The most resource intensive things you’re likely to come across will be those that make calls to external services or your database. By default, the results are sorted by ‘inclusive wall time’. This shows the functions that took the longest to run by the cumulative total of them and the functions they call. Ordering by ‘exclusive wall time’ allows you to see the specific functions that are using the most amount of resource.
Clicking a function allows you to drill down into more detail about that function and the functions it called. From there, it’ll be easier to see exactly what your long running function was doing and spot any issues.
When debugging your CodeIgniter application, one of the best places to start is the controller being called for your page – Welcome::index in the example. From there you can easily see the breakdown of where the controller spent most of its time.

Welcome-Index-XHProf_ Hierarchical Profiler Report - 2013-10-29_17.19.29

Callgraph
XHProf can generate a call graph view that provides a visual clue to the main path of your application. The main bottlenecks are highlighted in red to show where most your resources are being spent.

callgraph.php (PNG Image, 2945 × 1779 pixels) - 2013-10-29_17.18.51

Comparing Runs
XHProf provides a mechanism for comparing multiple runs – this will allow you to make a number of optimizations and then see how they’ve affected your application.
http://localhost/xhprof/xhprof_html/index.php?run1=run_id_1>&run2=run_id_2&source=applicationName
Note: run_id_1 and run_id_2 should be the ids from some of your previous runs and applicationName should be the name you specified when setting up the hook earlier.
This will provide the same information you see in a regular report but provide percentage statistics on any changes since the first run, allowing you to easily see if your optimizations are moving your performance in the right direction.

http://localhost/xhprof/xhprof_html/index.php?run1=526fa02b94f31&run2=526fa0255926b&source=my_xhprof_CI_welcome_index

XHProf_ Hierarchical Profiler Report - 2013-10-29_17.30.43

Aggregating Runs
Sometimes a single run might not be enough to evaluate exactly what’s going on. Pages my work slightly differently depending on the query string or user input or there might be differences in caching mechanisms.
Aggregating a number of runs allows you to combine a number of runs and receive an average of the resources consumed.
http://localhost/xhprof/xhprof_html/index.php?run=run_id,run_id,run_id&source=applicationName
Note: run_id should be the ids from some of your previous runs and applicationName should be the name you specified when setting up the hook earlier.

http://localhost/xhprof/xhprof_html/index.php?run=526fa02b94f31,526fa0255926b&source=my_xhprof_CI_welcome_index

XHProf_ Hierarchical Profiler Report - 2013-10-29_17.41.01

Summary
You should now have XHProf up and running in your CodeIgniter application and be able to see exactly where your code is spending most of it’s time. Optimisation can be a difficult task. Sometimes it’s not as simple as reimplementing a function, or adding a layer of caching. Thinking about why you’re doing something and what the exact effect that is having on your application is just as important.
So let me know if you have any questions in the comments below. Thank you so much for reading!

References:

http://net.tutsplus.com/tutorials/php/advanced-codeigniter-profiling-with-xhprof/
https://github.com/facebook/xhprof
http://www.catswhocode.com/blog/how-to-create-a-simple-and-efficient-php-cache
http://css-tricks.com/snippets/php/intelligent-php-cache-control/
http://www.phptoys.com/tutorial/speed-up-with-caching.html
http://www.addedbytes.com/articles/for-beginners/output-caching-for-beginners/
Xcache: http://xcache.lighttpd.net/
APC: http://php.net/manual/en/book.apc.php
Varnish: https://www.varnish-cache.org/
http://www.sitepoint.com/getting-started-with-varnish/
Even More: http://en.wikipedia.org/wiki/List_of_PHP_accelerators

How to Enable Site-Wide Profiling in CodeIgniter

Leave a comment

To measure the performance of a web site we need to get loading time of all classes and number of queries and execution time of each query etc.
In CodeIgniter it can be done very easy way. A very good part of CodeIgniter is its ability to give you the ‘profiling’ information for page loads. That is, if you add:

$this->output->enable_profiler(true);

In your controller before you load a view, CodeIgniter will give you information regarding how fast the page loaded, how many SQL queries executed, the content of each query, and the running time of each query. This is incredibly useful when you are trying to debug your application, or simply see how quickly things are loading.

There’s only one problem: To enable profiling, that line of code above must be present. What if you want to profile several pages, or even your whole web application? In that case, you have to start thinking:

I could put that line in the constructor of my controller, and then of of that controller’s methods will be profiled.
I could put that line in each method I want to profile.

These methods start to get ugly. And of course, you don’t want to comment out each profiling line when you don’t need them.

I will suggest to tackle this problem using CodeIgniter’s Hooks feature to enable or disable profiling for the entire web applications based on a value in the configuration file. In the end, I can turn on profiling for my entire website via a config value by setting it to true or false.

Here is the steps:

1. Create a folder in your application directory named hooks (If it does not already exist). Inside it, create a file named hooks.classes.php. Inside it, put this:

class ProfilerHandler
{
	function EnableProfiler()
	{
		$CI = &get_instance();
		$CI->output->enable_profiler( config_item('enable_hooks') );
	}
}

2. Create a file in the config directory named hooks.php if it does not already exist. Inside it, place:


$hook['post_controller_constructor'][] = array(
                                'class'    => 'ProfilerHandler',
                                'function' => 'EnableProfiler',
                                'filename' => 'hooks.classes.php',
                                'filepath' => 'hooks',
                                'params'   => array()
                                );

3. Finally, enable hooks in your CodeIgniter Application by going to config/config.php end setting the flag to true:


$config['enable_hooks'] = TRUE;	// TRUE or FALSE depending upon your choice, what you want enable/disable profiling

Setting this value to true will enable profiling across your entire website.

That All.

References:
http://ellislab.com/codeigniter/user-guide/general/profiling.html
http://ellislab.com/codeigniter/user-guide/general/hooks.html
http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-profiling-benchmarking-hooks/
https://github.com/EllisLab/CodeIgniter/wiki/Customizing-the-Profiler

How to use zendtool in Zend Framework 2

Leave a comment

Here is step by step guide to create a module in a zend framework 2 application using zendtool.

Step A. First Install zendtool

Step 1: First Download the Zend Tool from here. Secondly, extract the files into your root (www) localhost folder and rename the folder to anything you want. I will call it “zftool. So zendtool path look like this – C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zftool

This file provides you with all the necessary files to create your basic folder structure.

Step 2: Download the zftool.phar from packages.zendframework.com

And copy it to zendtool folder.

Step 3: Open your Terminal. (In Windows 7, click Start and in the search box type “cmd” (no quotes), and click cmd.exe.

Step 4: Once opened, use the “cd” command to navigate to the folder where you created your project in your root (www) localhost folder. My command looks like this “cd C:\Program Files\php_5_4_15_Win32_VC9_x86\www″. You should be inside the root folder now and your line in Terminal should resemble this “C:\Program Files\php_5_4_15_Win32_VC9_x86\www>″.

Step 5: Now type this command, “php zftool/zftool.phar version” and press Enter, To check zendtool. For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www>php zftool/zftool.phar version

Output look like bellow:

ZFTool – Zend Framework 2 command line Tool

The ZFTool is using Zend Framework 2.2.0

This means zendtool install and working fine.

Step B. use zendtool

Step 1. Assumtions

Zendframework 2 project created with zf2 installed.

Path like this

http docs root path:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www

zf2 project / application path:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\ZendSkeletonApplication6ACLNAV

Step 2. Use zendtool to create module in zf2 application

Here is how you can user zendtool on zf2 application for creating a module

Step a: Open your Terminal. (In Windows 7, click Start and in the search box type “cmd” (no quotes), and click cmd.exe.

Step b: Once opened, use the “cd” command to navigate to the folder where you created your project in your root (www) localhost folder. My command looks like this “cd C:\Program Files\php_5_4_15_Win32_VC9_x86\www″. You should be inside the root folder now and your line in Terminal should resemble this “C:\Program Files\php_5_4_15_Win32_VC9_x86\www>″.

Step c: Now type this command, “php zftool/zftool.phar create module user ZendSkeletonApplication6ACLNAV” and press Enter, To use zendtool. For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www> php zftool/zftool.phar create module user ZendSkeletonApplication6ACLNAV

Output look like bellow:

The module User has been created in ZendSkeletonApplication6ACLNAV

 

This means zendtool install and working fine.

 

Similarly other commands of zendtool can be used in zf2 application.

References:

1.)    https://maheshvnit.wordpress.com/2013/06/10/zend-framework-2-how-to-create-a-new-project-how-to-install-skeleton-application/

2.)    http://framework.zend.com/manual/2.2/en/modules/zendtool.introduction.html

2.)    https://github.com/zendframework/ZFTool

Pure CSS and DIV based Contact Us form design

2 Comments

Pure CSS and DIV based Contact Us form design

Here is how you can design Pure CSS and DIV based Contact Us form design.

I have used simple design, it is not much complited to understand.

Here is how it look like:
1.)FF

FF - Pure CSS and DIV based Contact Us form design

FF – Pure CSS and DIV based Contact Us form design

2.)Chrome

Chrome - Pure CSS and DIV based Contact Us form design

Chrome – Pure CSS and DIV based Contact Us form design

3.) IE

IE - Pure CSS and DIV based Contact Us form design

IE – Pure CSS and DIV based Contact Us form design

Full HTML with CSS source code:
Modify border and colors as you like.


<!DOCTYPE html>
<html>
    <head>
        <title>Contact Us</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style>
			body{
				font-family:Verdana, Arial, Helvetica, sans-serif;
				font-size:14px;
			}
			p, h1, form, button{border:0; margin:0; padding:0;}
			.spacer{clear:both; height:1px;}

			/* ----------- My Form ----------- */
			.myform{
				margin:0 auto;
				width:509px;
				padding:14px;
			}

			/* ----------- form-wrapper ----------- */
			#form-wrapper{
				background: none repeat scroll 0 0 #C6C6C6;
				border: 2px solid #8B8B8B;
				border-radius: 10px;
				-moz-border-radius: 10px;
				-op-border-radius: 10px;
				-webkit-border-radius: 10px;
			}
			#form-wrapper h1 {
				font-weight:bold;
				margin-bottom:8px;
			}
			#form-wrapper p{
				font-size:11px;
				color:#666666;
				margin-bottom:20px;
				border-bottom:solid 1px #7E7E7E;
				padding-bottom:10px;
			}
			#form-wrapper label{
				display:block;
				font-weight:bold;
				text-align:right;
				width:193px;
				float:left;
			}
			#form-wrapper .small{
				color:#666666;
				display:block;
				font-size:11px;
				font-weight:normal;
				text-align:right;
				width:193px;
			}
			#form-wrapper input,#form-wrapper textarea{
				float:left;
				border:solid 1px #aacfe4;
				width:284px;
				margin:2px 0 20px 10px;
				border-radius: 15px;
				-moz-border-radius: 15px;
				-op-border-radius: 15px;
				-webkit-border-radius: 15px;
				font-size: 14px;
			}

			#form-wrapper input{
				height: 25px;
				padding: 4px 10px;
			}
			#form-wrapper textarea{
				padding: 10px 10px;
				overflow: auto;
			}
			/* ----------- Form Button ----------- */
			#form-wrapper button {
			   background: #2c3e4a;
			   background: -webkit-gradient(linear, left top, left bottom, from(#919496), to(#2c3e4a));
			   background: -webkit-linear-gradient(top, #919496, #2c3e4a);
			   background: -moz-linear-gradient(top, #919496, #2c3e4a);
			   background: -ms-linear-gradient(top, #919496, #2c3e4a);
			   background: -o-linear-gradient(top, #919496, #2c3e4a);
			   padding: 5px 10px;
			   -webkit-border-radius: 15px;
			   -moz-border-radius: 15px;
			   border-radius: 15px;
			   margin-left: 315px;
			   color: white;
			   font-size: 20px;
			   text-decoration: none;
			   vertical-align: middle;
			}
			#form-wrapper button:hover {
			   background: #3d4b54;
			   color: #ccc;
			}
        </style>
    </head>
    <body>
        <div id="form-wrapper" class="myform">
            <form id="form" name="form" method="post" action="index.html">

                <h1>Contact Us</h1>
                <p>Please complete the form bellow.</p>

                <label for="name">Name
                    <span class="small">Add your name</span>
                </label>
                <input type="text" name="name" placeholder="Mahesh Prasad" id="name" />

                <label for="email">Email
                    <span class="small">Add a valid address</span>
                </label>
                <input type="text" name="email" placeholder="mail@example.com" id="email" />

                <label for="phone">Phone
                    <span class="small">Add valid 10 digit your mobile no.</span>
                </label>
                <input type="text" name="phone" placeholder="8888888888" id="phone" />

                <label for="web">Web-site
                    <span class="small">Add your web-site url</span>
                </label>
                <input id="web" type="text" placeholder="http://www.example.com" name="web" id="web">

                <label for="message">Message
                    <span class="small">Write something to us</span>
                </label>
                <textarea placeholder="Write something to us" name="message" id="message"  rows="5"></textarea>

                <button type="submit">Send</button>
                <div class="spacer"></div>

            </form>
        </div>
    </body>
</html>

Zend Framework 2 – How to Create A New Project / How to install Skeleton Application

12 Comments

ZF2 There has been lots of confusion with new Zend Framework 2 lately. The manual on Zend Framework‘s website is horrible (in terms of beginner manual and documentation) and is designed for advanced user’s with Zend Framework 1 extensive experience.

Many users are still unable to create a first basic folder structure to begin using Zend Framework 2 library. The initial example is provided here. I’m going to break it down for you guys.

(Note: This instruction guide assumes you have successfully installed Apache web server and PHP 5.3 or above)

Method 1: by downloading skeleton application

Step 1: First Download the Zend Framework Skeleton Application from here. Secondly, extract the files into your root (www) localhost folder and rename the folder to anything you want. I will call it “zf_project1”.path look like this – C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1
This file provides you with all the necessary files to create your basic folder structure.

Step 2: Open your Terminal. (In Windows 7, click Start and in the search box type “cmd” (no quotes), and click cmd.exe.

Step 3: Once opened, use the “cd” command to navigate to the folder where you extracted your zip file you downloaded in step 1 (“zf_project1”). My command looks like this “cd C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1″. You should be inside the folder now and your line in Terminal should resemble this “C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>

Step 4: Now type this command, “php composer.phar self-update” and press Enter.

For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>php composer.phar self-update

Output look like bellow:

Updating to version f56b985884b1631dbcbc675434ead96168462824.

Downloading: 100%

Step 5: Type another command, “php composer.phar install”. This will create your directories for basic skeleton application.

For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>php composer.phar install

Output look like bellow:

Loading composer repositories with package information

Installing dependencies (including require-dev)

– Installing zendframework/zendframework (2.2.0)

Loading from cache

zendframework/zendframework suggests installing ext-intl (ext/intl for i18n features (included in default builds of PHP))

zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)

zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)

zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager to handle lazy initialization of services)

zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)

zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)

Writing lock file

Generating autoload files

That’s all. Now, open your browser and navigate to your localhost and zf_project1/public folder (mine looks like this: http://localhost/zf_project1/public/). You should see this website. If you do, then every step has been successfully completed.

Method 2: by using zendtool

Step 1: First Download the Zend Tool from here. Secondly, extract the files into your root (www) localhost folder and rename the folder to anything you want. I will call it “zendtool. So zendtool path look like this – C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zendtool

This file provides you with all the necessary files to create your basic folder structure.

Step 2: Download the zftool.phar from packages.zendframework.com

And copy it to zendtool folder.

Step 3: Open your Terminal. (In Windows 7, click Start and in the search box type “cmd” (no quotes), and click cmd.exe.

Step 4: Once opened, use the “cd” command to navigate to the folder where you created your project in your root (www) localhost folder. My command looks like this “cd C:\Program Files\php_5_4_15_Win32_VC9_x86\www″. You should be inside the root folder now and your line in Terminal should resemble this “C:\Program Files\php_5_4_15_Win32_VC9_x86\www>″.

Step 5: Now type this command, “php zendtool/zftool.phar version” and press Enter, To check zendtool. For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www>php zendtool/zftool.phar version

Output look like bellow:

ZFTool – Zend Framework 2 command line Tool

The ZFTool is using Zend Framework 2.2.0

This means zendtool install and working fine.

Step 6: Now type this command,”php zendtool/zftool.phar create project zf_project1” and press enter, to create project “zf_project1”. For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www>php zendtool/zftool.phar create project zf_project1

Output look like bellow:

ZF2 skeleton application installed in zf_project1.

In order to execute the skeleton application you need to install the ZF2 library.

Execute: “composer.phar install” in zftest

For more info in zftest/README.md

 

Step 7: Now use the “cd” command to navigate to the project. My command looks like this “cd zf_project1

C:\Program Files\php_5_4_15_Win32_VC9_x86\www>cd zf_project1

Now you should be inside the project folder and your line in Terminal should resemble this “C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>″.

Step 8: Now type this command, “php composer.phar self-update” and press Enter.

For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\ zf_project1>php composer.phar self-update

Output look like bellow:

Updating to version 1a7f734bc78df99553a742dfac6651a4863c00c6.

Downloading: 100%

Step 9: Now type this command, “php composer.phar install” and press Enter.

For me look like this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\ zf_project1>php composer.phar install

Output look like bellow:

Loading composer repositories with package information

Installing dependencies (including require-dev)

– Installing zendframework/zendframework (2.2.0)

Loading from cache

zendframework/zendframework suggests installing ext-intl (ext/intl for i18n features (included in default builds of PHP))

zendframework/zendframework suggests installing doctrine/annotations (Doctrine Annotations >=1.0 for annotation features)

zendframework/zendframework suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if OpenSSL/Mcrypt extensions are unavailable)

zendframework/zendframework suggests installing ocramius/proxy-manager (ProxyManager to handle lazy initialization of services)

zendframework/zendframework suggests installing zendframework/zendpdf (ZendPdf for creating PDF representations of barcodes)

zendframework/zendframework suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha for rendering ReCaptchas in Zend\Captcha and/or Zend\Form)

Writing lock file

Generating autoload files

That’s all. Now, open your browser and navigate to your localhost and zf_project1/public folder (mine looks like this: http://localhost/zf_project1/public/). You should see this website. If you do, then every step has been successfully completed.

References:

1.)    http://framework.zend.com/manual/2.2/en/user-guide/overview.html

2.)    http://framework.zend.com/manual/2.2/en/user-guide/skeleton-application.html

3.)    https://github.com/zendframework/ZFTool/

4.)    http://framework.zend.com/manual/2.2/en/modules/zendtool.introduction.html

Update 1 – 12-06-3013

if you see this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>php composer.phar install
Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP 5.3.1, upgrading is strongly
recommended.
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– The requested package php >=5.3.3 could not be found.
Problem 2
– zendframework/zendframework 2.2.0rc3 requires php >=5.3.3 -> no matching package found.
– zendframework/zendframework 2.2.0rc2 requires php >=5.3.3 -> no matching package found.
– zendframework/zendframework 2.2.0 requires php >=5.3.3 -> no matching package found.
– Installation request for zendframework/zendframework >2.2.0rc1 -> satisfiable by zendframework/zendframework[2.2.0, 2.2.0rc2, 2.2.0r
c3].

Potential causes:
– A typo in the package name
– The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion&gt; for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md&gt; for further common problems.

This means PHP version not appropriate, you must have 5.3.3 or above.

So now first upgrade php:

download your desired version of php binary from http://windows.php.net/download/ website. download Thread Safe binary zip version. Unzip the downloaded version of the PHP in a separate folder. Please make sure that your new php folder name is not “PHP”. May be you can use filder name as the version name. For example for php 5.4 you can use php54.

Copy the new php folder into your xampp folder. Now go to yourxampp/apache/conf/extra folder. Open file httpd-xampp.conf from the folder extra. Change the following variables:

variable LoadFile and PHPINIDir

Variable PHPINIDir to be / Varaible LoadModule to be //php5apache2_2.dl

Save the file httpd-xampp.conf. Restart your XAMPP apache server. If your server get restarted successfully then your server php version is upgraded.

References:

http://hype-free.blogspot.in/2007/07/updating-php-in-xampp-for-windows.html

http://stackoverflow.com/questions/2154762/upgrading-php-in-xampp-for-windows

Update 2- 13-06-3013

if you see this:

C:\Program Files\php_5_4_15_Win32_VC9_x86\www\zf_project1>php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
– Installing zendframework/zendframework (2.2.0)
Downloading: 100%
Downloading: 100%
Downloading: 100%

 

[Composer\Downloader\TransportException]
The “http://nodeload.github.com/zendframework/zf2/zip/release-2.2.0&#8221; file could not be downloaded: failed to open stream: Unable to f
ind the socket transport “ssl” – did you forget to enable it when you configured PHP?

 

install [–prefer-source] [–prefer-dist] [–dry-run] [–dev] [–no-dev] [–no-custom-installers] [–no-scripts] [–no-progress] [-v|vv|vv
v|–verbose] [-o|–optimize-autoloader]

This means openssl not enabled in php, you must enable it.

So now first enable openssl php:

  1. Rename php.ini-production to php.ini (in C:\xampp\php\ folder)
  2. Edit php.ini and uncomment extension_dir=ext.
  3. Also uncomment extension=php_openssl.dll.

References:

http://stackoverflow.com/questions/1705856/socket-transport-ssl-in-php-not-enabled

http://stackoverflow.com/questions/2154762/upgrading-php-in-xampp-for-windows

Now you will be able to install ZF2.

Older Entries

%d bloggers like this: