In: Ruby|Ruby on Rails
8 Aug 2012Here is a beautiful tool for installing Mac System. It’s just a one click installer which guide you step by step to
from Engine Yard on Vimeo.
Reference: http://railsinstaller.org/#osx
Many of us use Zend Framework for their local development in windows machine. Very few of us use Mac OS or Linux. There are lots of installation process available in Web but, very few of us get the proper way to install and configure zend Framework in their windows machine.
Therefore i am writing this post with some simple and easy steps. So lets start.
Requirements before Installation:
Step 01:
Create a virtual host inside our apache virtual host configuration file called httpd-vhosts.conf. You will find the file at: F:\xampp\apache\conf\extra\httpd-vhosts.conf. i have created my own virtual in the following fashion:
<VirtualHost *:80>
ServerAdmin masudiiuc@gmail.com
DocumentRoot "F:/xampp/htdocs/zf/"
ServerName zf.masudiiuc.com
##ServerAlias www.dummy-host.localhost
##ErrorLog "logs/dummy-host.localhost-error.log"
##CustomLog "logs/dummy-host.localhost-access.log" combined
</VirtualHost>
We are going to put our application folder inside the XAMPP root folder htdocs. We will name our project “zf”, therefore we will create a folder “zf” inside the root directory. therefore we placed the DocumentRoot settings to “F:/xampp/htdocs/zf/”.
Step: 02:
The very next thing we have to do is list the host name in windows host folder. Our host file is available at “c:\Windows\System32\drivers\etc\hosts“. At the very bottom of the page add a new line with our host information exactly same as the below line:
127.0.0.1 zf.masudiiuc.com
Step: 03
Now create a folder called “zf” inside the root folder of XAMPP. Now restarts the XAMPP apache service and browse the http://zf.masudiiuc.com. You will see a blank page with web index listing.
Step: 04
Now we have to configure zend Framework. We know Zend library is a Huge library and we will have to use the library for all application. So its better to place the librarl in such location from where all our apps can share the library rather than using individual Library folder. So we are going to add the library in a common windows PATH and also going to add that in php “include_path” by editing the php.ini file inside F:\xampp\php\php.ini. So lets do it…
;C:\Program Files\bin;F:\xampp\php
include_path = ".;F:\xampp\php\PEAR;C:\library"
After Restarting windows, open your command line. goto the root directory of XAMPP at: F:\xampp\htdocs\. Now type the following Command
zf show version
This will show the Current Zend Framework version. which also let you know that your current configuration is done successfully.
Now we are going to create our project structure using Zend framework command line tool. Here is the command:
zf create project zf
This will create a project structure inside the zf folder. If you browse the http://zf.masudiiuc.com you will see the project folder. To see the default view of the framework you to modify the virtual host document root a bit more: just change the following line
DocumentRoot "F:\xampp\htdocs\zf\" to DocumentRoot "F:\xampp\htdocs\zf\public\"
This is because zend Executes all controller by going through public/index.php file. this is due to security reason of the application.
So this is simple to configure your zend framework inside your windows folder. So enjoy and put comments.
I have working with codeigniter for last 3/4 years. i have the opportunity to developed some application using codeigniter. I found some feature common almost in all application. Some parts of the development needs extensive care such as handling the Models. It is very difficult to develop new tool thinking about deadline of project. So its better if we use some community libraries and contribute on those things. it will take less time and increase the productivity as well.
Today i am going to focus on some libraries which i personally use and get much benefits from those things. Here are those libraries:
Authentication Library: DX Auth
Authentication is a basic and most common part of every web applications. Login, Logout, Registration, change password, forgot password etc. We can create such libraries but sometime its so boring to recreate them as i fill sometime. Therefore in the codeigniter forum, there are lots of authentication libraries available. But i personally found Dx_auth very useful. Because this libraries has maximum number of features with a well documentation. Here is some of the core features:
Documentation Link: http://dexcell.shinsengumiteam.com/dx_auth/
Codeigniter ORM Library: Datamapper ORM
Deal with model is very important in every application. ORM is one of the core features for Data Mapping. Some time we create this mapper by ourself. but as there is a build in Library specially for Codeigniter, why we should build another one. DataMapper ORM is such one which saves lots of our time and give us a clear view of managing models.
Here is some core features of the Library:
Documentation link: http://datamapper.wanwizard.eu
CodeIgniter and Doctrine
This is another way to mapping database. You will have a complete guideline from the following link:
Documentation Link: http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup
Here is the list of articles. Please have a look on this as well.
Hope that, this links will work for you and i will come with more updates on such things.
Please have a look on part one if don’t read the previous one:
Google Contact’s API with Codeigniter Framework [part-01]
In the previous post we are missing a function called “processFeedResult($feed)” at 36. Here is the details:
<pre>/**
* Parse Feed Result
*
* @access private
* @param Zend Gdata Object $feed
* @return object $results
*/
private function _processFeedResult( $feed ){
if( $feed ){
$results = array();
foreach( $feed as $key => $entry ){
$xml = simplexml_load_string( $entry->getXML() );
//create a new Object
$obj = new stdClass;
//set value to the object
$obj->name = (string) $entry->title;
$obj->orgName = (string) $xml->organization->orgName;
$obj->orgTitle = (string) $xml->organization->orgTitle;
$obj->edit = (string) $entry->getEditLink()->href; // require for edit/delete
foreach( $xml->email as $email ){
$obj->emailAddress[] = (string) $email['address'];
}
foreach ($xml->phoneNumber as $p) {
$obj->phoneNumber[] = (string) $p;
}
foreach ($xml->website as $w) {
$obj->website[] = (string) $w['href'];
}
$results[] = $obj;
}
return $results;
}
return false;
}
Now are simplifying the process by creating two functions. One will create the connection with a API call and returns the Object. Then we will create another function for adding new contacts to that account.
Step:01
Creating common connection with Google Account
/**
* Create connection to google Account
*
* @access private
* @param none
* @return object $gData
*/
private function _connectToAgentE3GoogleAccount( $update=false ){
$this->load->library('zend');
$this->zend->load('Zend/Loader');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');
try{
//perform account login and set protocol version
$client = Zend_Gdata_ClientLogin::getHttpClient('TEST_EMAIL_ACCOUNT', 'PASSWORD', 'cp');
if( $update ){
$client->setHeaders('If-Match: *');
}
$gData = new Zend_Gdata( $client );
$gData->setMajorProtocolVersion(3);
return $gData;
}catch(Exception $e){
die('Error: ' . $e->getMessage());
}
}
Step:02
Add new account to Google Account using the connection object.
/**
* Add New Contacts to E3 Gmail account
*
* @access public
* @param string $emailAddress
* @param string $fullName [optional]
* @param string $phone [optional]
* @param string $company_name [optional]
* @return string $entryId
*/
public function addContactToE3GoogleAccount( $emailAddress, $fullName='', $phone='', $company_name=''){
// create new entry
$doc = new DOMDocument();
$doc->formatOutput = true;
$entry = $doc->createElement('atom:entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:atom', 'http://www.w3.org/2005/Atom');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/' ,'xmlns:gd', 'http://schemas.google.com/g/2005');
$doc->appendChild($entry);
// add name element
if( !$fullName ){
$fullName = 'Unkown Name';// keep the google db not empty field
}
$name = $doc->createElement('gd:name');
$entry->appendChild($name);
$fullName = $doc->createElement('gd:fullName', $fullName);
$name->appendChild($fullName);
if( !$phone ){
$phone = "000001"; // keep the google db not empty field
}
$phoneNumber = $doc->createElement('gd:phoneNumber', $phone);
$phoneNumber->setAttribute('rel' ,'http://schemas.google.com/g/2005#mobile');
$entry->appendChild($phoneNumber);
// add email element
$email = $doc->createElement('gd:email');
$email->setAttribute('address', $emailAddress);
$email->setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
$entry->appendChild($email);
// connect to google Account and insert entry
$contactObj = $this->_connectToAgentE3GoogleAccount();
$entryResult = $contactObj->insertEntry($doc->saveXML(), 'http://www.google.com/m8/feeds/contacts/default/full');
return $entryResult->id;
}
Note:
So far i am able to insert some certain information using the google api’s. Here is some key note:
In: Linux
28 Mar 2011Example:
1.suppose we have two server source.com and destination.com
2.we are going to transfer a backup.sql from source.com to destination.com server.
3.we have ssh access(username & Password) to both server.
Step:01
Login to destiantion.com using ssh terminal
root@destination.com#:
step:02
Now create a a folder called back_from_source in destination.com
root@destination.com#:mkdir back_from_source root@destination.com#:
step:03
we have backup.sql file at source.com in /var/www/sql/backup.sql. we are going to copy the file in destination.com as backup.sql(you can use different name as well). we are using SCP command to do the job.
command syntax:
scp user@hostname.com:file_path/filename destionation_path/filename
example:
root@destination.com#:scp root@source.com:/var/www/sql/backup.sql /home/destionation_folder/backup.sql root@source.com password: Copy progress information will be shown with bandwidth root@destination.com#:
That’s all. Have fun.
Google has vast number of API’s. Among them Google Contacts API is one of them. Recently i have to work with this API including Codeigniter. But there is very limited number of post which describes everything very clearly. Therefore as i worked with this one, i am sharing my knowledge here.
Tools that i used:
What will be done:
A. Import Contacts from a Google Account
First of all, add the Zend Library folder in codeigniter libraries folder. Create a library file in codeigniter/library folder called Zend.php. Put the following contents into the file:
<?php if (!defined('BASEPATH')) {exit('No direct script access allowed');}
class Zend
{
/**
* Include the Zend library once
* we load the zend Library class
*
* @param none
* @return none
*/
function __construct(){
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . APPPATH . 'libraries');
}
/**
* Load Zend Library
*
* @param string $class
* @return object $class
*/
function load($class){
require_once (string) $class . EXT;
}
}
/* End of Zend.php */
Then we need a Existing Google Email account User Name and Password. We will pass the parameter through our controller methods. Inside the method we will load the library Zend.php. Then using this library we will load the Zend Gdata Library for importing the Contacts using Google API’s.
Have a look on the following code:
/**
* Import Contacts using Zend Library
*
* @access private
* @param string $accountUserName
* @param string $accountPassword
* @return none
*/
private function _importContacts($accountUserName, $accountPassword){
$this->load->library('zend');
$this->zend->load('Zend/Loader');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');
try{
//perform account login and set protocol version
$client = Zend_Gdata_ClientLogin::getHttpClient($accountUserName, $accountPassword, 'cp');
$gData = new Zend_Gdata( $client );
$gData->setMajorProtocolVersion(3);
//perform query and get result from feed
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full');
$query->startIndex = 0;
$query->maxResults = 25;
$query->setParam('orderby', 'lastmodified');
$query->setParam('sortorder', 'descending');
$feed = $gData->getFeed($query);
$this->data['AccountTitle'] = $feed->title;
$this->data['currentNumber'] = 25;
$this->data['TotalResults'] = $feed->totalResults;
$this->data['contactList'] = $this->_processFeedResult($feed);
}catch(Exception $e){
die('Error: ' . $e->getMessage());
}
}
Comming soon…
This blog will have regular article on latest Framework, API’s, Web-service etc. You will get series of articles so that you can use them to your application. Again Professional Service on development is available .
Please follow us on Twitter, Facebook for Updates.
Google API, Youtube API, Twitter API, Flickr API, Zend Framework, Codeigniter Framework are the target post of this Blog.