Home

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 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

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.

Template Library for CodeIgniter, the PHP Framework

Leave a comment

Template has been verified to work with CodeIgniter 1.7

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities, the ability to utilize any template parser (like Smarty), and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

Template is right for you if:

  • You feel like using views can be clunky, especially when “embedding” views.
  • You don’t like calling header, footer, and other global views from every Controller method.
  • You prefer having one “master template” that can be changed for any controller in order to meet unique application design needs.
  • You don’t want to drastically alter the way you interface controllers and views.
  • You like clear, thorough documentation on par with CodeIgniter’s User Guide.

Ready to give Template a shot? Download it now and get started.

What’s New in Version 1.4.1?

Version 1.4.1 is mostly a maintenance release, fixing comment and documentation typos. In addition, the 1.4.1 download now ships with its documentation. And finally, the Template class was renamed to work more like a core library so you can extend/overload/replace it in your application libraries folder, among other things.

Download Version 1.4.1

Template’s Approach

Template works by writing to pre-defined regions of a master template. Although you will most often write to your template from a Controller, you can write content to these regions from any part of your application. Content could be a simple string of plain text, HTML, or the results from a View. Regions display by echoing variables placed throughout your master template as desired. Template also lets you use multiple template configurations, making it completely flexible to meet the needs of your application’s design.

Here’s what using template looks like:

$this->template->write('title', 'Introduction to Template');
$this->template->write_view('content', 'blog/posts', $this->blog->get_posts());
$this->template->render();
Look interesting? Head over to the Getting Started section to begin using Template in your next CodeIgniter application.

Template User Guide:

More info:

http://williamsconcepts.com/ci/codeigniter/libraries/template/index.html
http://codeigniter.com/user_guide/libraries/parser.html

Other Template Library for CodeIgniter
http://maestric.com/doc/php/codeigniter_template

MySQL Web / Desktop Management Tools

Leave a comment

1.) phpMyAdmin
phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement.
http://www.phpmyadmin.net/home_page/
2.) Adminer
Adminer (formerly phpMinAdmin) is a full-featured MySQL management tool written in PHP. Conversely to phpMyAdmin, it consist of a single file ready to deploy to the target server.
http://www.adminer.org/
3.) MySQL Workbench

MySQL Workbench is a unified visual tool for database architects, developers, and DBAs. MySQL Workbench provides data modeling, SQL development, and comprehensive administration tools for server configuration, user administration, and much more. MySQL Workbench is available on Windows, Linux and Mac OS.

http://www.mysql.com/products/workbench/

4.) HeidiSQL – a free MySQL front-end

http://www.heidisql.com/

HeidiSQL is an easy-to-use interface and a “working-horse” for web-developers using the popular MySQL-Database. It allows you to manage and browse your databases and tables from an intuitive Windows® interface.

5.) Navicat well-designed (GUI), Navicat for MySQL

Navicat for MySQL is a powerful Database administration and development tool for MySQL. It works with any MySQL Database Server from version 3.21 or above, and supports most of the latest MySQL features including Trigger, Stored Procedure, Function, Event, View, and Manage User, etc.

http://www.navicat.com/

6.) EMS SQL Manager for MySQL

EMS SQL Manager for MySQL is a high performance tool for MySQL database administration and development. It works with any MySQL versions from 3.23 to the newest one and supports all of the latest features including MySQL triggers, views, stored procedures and functions, InnoDB foreign keys, Unicode data and so on. SQL Manager for MySQL allows you to create/edit all MySQL database objects, design MySQL databases visually, run SQL scripts, import and export MySQL database data, manage MySQL users and their privileges and has many other useful features for efficient MySQL administration. SQL Manager for MySQL has a state-of-the-art graphical user interface with well-described wizard system, so clear in use that even a newbie will not be confused

http://www.sqlmanager.net/en/products/mysql/manager

7.) SIDU 3.2 DB Web GUI

http://sidu.sourceforge.net/sidu/

8.) SQLyog MySQL GUI

SQLyog MySQL GUI is the most powerful MySQL manager and admin tool, combining the features of MySQL Query Browser, Administrator, phpMyAdmin and other MySQL Front Ends and MySQL GUI tools in a single intuitive interface.

http://www.webyog.com/en/

9.) MySQL-Front

http://www.mysqlfront.de/wp/

http://www.brothersoft.com/mysql-front-80299.html

More information here:

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

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

PHP5 Charting Library Built On Google Chart API

Leave a comment

25 EXCELLENT PHP TOOLS THAT ENHANCE THE WAY YOU DEVELOP

Leave a comment

PHP has grown to become one of the most wide-spread server-side scripting language that’s used on a daily basis in a variety of ways. For the most part, almost every developer that’s introduced to this programming language uses it and becomes fond of it at some point. With the support of a very large community, this incredibly fast technology is taking over other server-side scripting languages. If you conduct a quick search on the subject you’ll find countless ready-to-use scripts and a fist-full of quality frameworks.

Here you can see we’ve complied 25 Excellent PHP Tools That Will Enhance The Way You Develop in detail. Take a look at a few of these tools, assess which ones address your needs, and take advantage of them. After all, they’re there for us to use.

Read full entry here»

http://www.reencoded.com/2010/02/06/25-excellent-php-tools-that-enhance-the-way-you-develop/

Older Entries

%d bloggers like this: