Thursday, February 26, 2015

HOWTO: Install xdebug for PHP5

Here is a mini-howto in how to install the xdebug extension with PHP5 in Ubuntu 7.04

This will install xdebug 2.0 (or whatever is latest version in PEAR repository when you try this).

It is assumed you have Apache2 + PHP5 working already.

Code:
sudo apt-get install php5-dev php-pear
Now install xdebug thru PECL.

Code:
sudo pecl install xdebug
Now we need to find where xdebug.so went (the compiled module)

Code:
martin@martin-dev:/$ find / -name 'xdebug.so' 2> /dev/null
/usr/lib/php5/20060613/xdebug.so
Then edit php.ini:

Code:
sudo gedit /etc/php/apache2/php.ini
Add the following line:

Code:
zend_extension="/usr/lib/php5/20060613/xdebug.so"
Then restart apache for changes to take effect

Code:
sudo /etc/init.d/apache2 restart
Check phpinfo() to make sure the extension is loaded correctly. The following line should have been appended to the copyright lines:

Wednesday, February 25, 2015

Introduction to Redis

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain stringshasheslistssetssorted setsbitmaps and hyperloglogs.
In order to achieve its outstanding performance, Redis works with an in-memory dataset. Depending on your use case, you can persist it either by dumping the dataset to disk every once in a while, or by appending each command to a log. Persistence can be optionally disabled, if you just need a feature-rich, networked, in-memory cache.
Redis also supports trivial-to-setup master-slave asynchronous replication, with very fast non-blocking first synchronization, auto-reconnection with partial resynchronization on net split.
Other features include:
You can use Redis from most programming languages out there.
Redis is written in ANSI C and works in most POSIX systems like Linux, *BSD, OS X without external dependencies. Linux and OSX are the two operating systems where Redis is developed and more tested, and we recommend using Linux for deploying. Redis may work in Solaris-derived systems like SmartOS, but the support is best effort. There is no official support for Windows builds, but Microsoft develops and maintains a Win-64 port of Redis.

Tuesday, February 24, 2015

Configuring Magento for development

New to the Magento or just used to doing things one way? Here are few tips for configuring Magento for development, in case you overlooked them. Please note, the more proper title of this article would be something like: Configuring Magento for development on local machine (after installation config). Meaning the tips outlined here only apply after the Magento is already installed.
Here are the steps that you should do in order to set your Magento more suited for development:
  • System > Cache Management > Disable All
  • System > Configuration > Advanced > Developer > Log Settings > Enabled => Yes
  • System > Configuration > Web > Search Engine Optimization > Use Wbe Server Rewrites => Yes
  • System > Index Management > Reindex All
  • Open .htaccess and set: SetEnv MAGE_IS_DEVELOPER_MODE “true” at the end of the file
  • Open .htaccess and set: php_value display_errors On somewhere within <IfModule mod_php5.c>
  • Rename /errors/local.xml.sample to /errors/local.xml
  • Create one sample customer with full valid American address (for example use US/California, city Alamo with ZIP 94507), and one with full valid non American address (other country) to test payment and shipping gateways properly
  • Compensate for the possible lack of email server by doing something like explained in this article
Hope it helps.

Sunday, February 22, 2015

Laravel 4 Custom Class

The Problem

How to add custom class on Laravel 4 Application?
In most case, we want to leverage our Laravel 4 application capabilities by adding custom class. We don’t want to insert class inside Controller and Model to do this, so we have to write our class in separate files and group it by folder

My Solution 

  • We Create folder inside app. For example app/classes
  • Register ClassLoader to app/start/global .
    ClassLoader::addDirectories(array(
    
     app_path().'/commands',
     app_path().'/controllers',
     app_path().'/models',
     app_path().'/database/seeds',
     app_path().'/classes', // we've added classes folder on Laravel ClassLoader
    
    ));
    
    As long as the folder structure within new app/classes folder follows your namespacing convention, Laravel will autoload all classes / files within this folder. 
  • Write your class
    For example, we want to add EmailNotifier which handle about email sending. We createEmailNotifier.php on app/classes/Notifier/EmailNotifier.php
    <?php namespace Notifier;
    
    class EmailNotifier {
    
        public static function notify()
        {
            return 'User Notified';
        }
    }
    

    Please note that we are using Notifier namespace as the same folder with Notifier
  • Call your class using Notifier\EmailNotifier::notify()
  • If we want to add it on alias so you can do EmailNotifier::notify(), we have add alias to app/config/app.php . Add 'EmailNotifier' => 'Notifier\EmailNotifier' at the end ofaliases array.

Another Solution

Don’t forget that we have Composer. We can always utilze Composer to load our classes. You can refer to http://laravel.com/docs/packages for package development and if you want to publish your class topackagist.

Tuesday, February 17, 2015

TWEET SHARE SHARE SHARE How To Install Git on Ubuntu 14.04

Introduction

An indispensable tool in modern software development is some kind of version control system. Version control systems allow you to keep track of your software at the source level. You can track changes, revert to previous stages, and branch to create alternate versions of files and directories.
One of the most popular version control systems is git, a distributed version control system. Many projects maintain their files in a git repository, and sites like GitHub and Bitbucket have made sharing and contributing to code simple and valuable.
In this guide, we will demonstrate how to install git on an Ubuntu 14.04 VPS instance. We will cover how to install the software in two different ways, each of which have benefits.
This tutorial assumes you are signed in as a non-root user which you can learn how to create here.

How To Install Git with Apt

By far the easiest way of getting git installed and ready to use is by using Ubuntu's default repositories. This is the fastest method, but the version may be older than the newest version. If you need the latest release, consider following the steps to compile git from source.
You can use the apt package management tools to update your local package index. Afterwards, you can download and install the program:
sudo apt-get update
sudo apt-get install git
This will download and install git to your system. You will still have to complete the configuration steps that we cover in the "setup" section, so feel free to skip to that section now.

How To Install Git from Source

A more flexible method of installing git is to compile the software from source. This takes longer and will not be maintained through your package manager, but it will allow you to download the latest release and will give you some control over the options you include if you wish to customize.
Before you begin, you need to install the software that git depends on. This is all available in the default repositories, so we can update our local package index and then install the packages:
sudo apt-get update
sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
After you have installed the necessary dependencies, you can go ahead and get the version of git you want by visiting the git project's page on GitHub.
The version you see when you arrive at the project's page is the branch that is actively being committed to. If you want the latest stable release, you should go change the branch to the latest non-"rc" tag using this button along the left side of the project header:
git change branch
Next, on the right side of the page, right-click the "Download ZIP" button and select the option similar to "Copy Link Address":
git download zip
Back on your Ubuntu 14.04 server, you can type wget and follow it by pasting the address you copied. The URL that you copied may be different from mine:
wget https://github.com/git/git/archive/v1.9.2.zip -O git.zip
Unzip the file that you downloaded and move into the resulting directory by typing:
unzip git.zip
cd git-*
Now, you can make the package and install it by typing these two commands:
make prefix=/usr/local all
sudo make prefix=/usr/local install
Now that you have git installed, if you want to upgrade to a later version, you can simply clone the repository and then build and install:
git clone https://github.com/git/git.git
To find the URL to use for the clone operation, navigate to the branch or tag that you want on the project's GitHub page and then copy the clone URL on the right side:
git clone URL
This will create a new directory within your current directory where you can rebuild the package and reinstall the newer version, just like you did above. This will overwrite your older version with the new version:
make prefix=/usr/local all
sudo make prefix=/usr/local install

How To Set Up Git

Now that you have git installed, you need to do a few things so that the commit messages that will be generated for you will contain your correct information.
The easiest way of doing this is through the git config command. Specifically, we need to provide our name and email address because git embeds this information into each commit we do. We can go ahead and add this information by typing:
git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"
We can see all of the configuration items that have been set by typing:
git config --list
user.name=Your Name
user.email=youremail@domain.com
As you can see, this has a slightly different format. The information is stored in the configuration file, which you can optionally edit by hand with your text editor like this:
nano ~/.gitconfig
[user]
       name = Your Name
       email = youremail@domain.com
There are many other options that you can set, but these are the two essential ones needed. If you skip this step, you'll likely see warnings when you commit to git that are similar to this:
[master 0d9d21d] initial project version
 Committer: root 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author
This makes more work for you because you will then have to revise the commits you have done with the corrected information.


Thursday, February 12, 2015

mcrypt php extension required in ubuntu

Try this:
sudo updatedb 
locate mcrypt.ini
Should show it located at /etc/php5/mods-available
locate mcrypt.so
Edit mcrypt.ini and change extension to match the path to mcrypt.so, example:
extension=/usr/lib/php5/20121212/mcrypt.so
Now this:
php5enmod mcrypt - (optional since its already enabled during phpmyadmin setup)
Verify that new files exists here (they should be auto created from the issue above)
ls -al /etc/php5/cli/conf.d/20-mcrypt.ini
ls -al /etc/php5/apache2/conf.d/20-mcrypt.ini
Otherwise do the following
Create symbol links now
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
Restart Apacahe
service apache2 restart

Monday, February 9, 2015

MSVCR100.dll is missing when WAMP server install

You may get following error message when installing WAMP,
The program can’t start because MSVCR100.dll is missing from your computer.
Try reinstalling the program to fix this problem.
Step to Install - MSVCR100.dll is missing when WAMP server install - wamp shows error msvcr100.dll is missing when install

After this alert, If you run WAMP it’ll start to run. But WAMP icon color stay in ‘yellow’ color.
It won’t change to ‘Green’ color.

Solution for MSVCR100.dll is missing when WAMP server install

This MSVCR100.dll is missing when WAMP server install problem mostly happen when you install new ‘Operating system’.
That MSVCR100.dll file is one part of Microsoft Visual C++. IF this component is missing means, ‘Apache Server’ won’t run. So, download following exe file and just install that. It’s enough for MSVCR100.dll is missing when WAMP server install problem.
For Windows 32 bit OS:
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)

Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)

Here just select your Language and click ‘Download’ Button. You will get ‘vcredist_x86.exe’ file. Just Download that file and install as usual( double click ).
For Windows 64 bit OS:
Visual C++ Redistributable for Visual Studio 2012 Update 4

Microsoft Visual C++ 2008 Redistributable Package (x64)

Microsoft Visual C++ 2010 SP1 Redistributable Package (x64)

Here just select your Language and click ‘Download’ Button. You will get ‘vcredist_x64.exe’ file. Just Download that file and install as usual( double click ).
Notes:
1) Make sure you have the latest service pack and critical updates for the version of Windows that you are running. To find recent security updates, visit Windows Update.
2)Supported Operating System: Windows 7, Windows Server 2003, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP
3)Make sure you have the latest version of packages of these Microsoft C++ Redistributable runtime libraries. We recommended 2008 Packages for over-all.