Thursday, December 7, 2017

Top 10 Best PHP IDE for Website Developers


  1. NetBeans IDE
  2. Eclipse
  3. Aptana Studio PHP Editor
  4. Codelobster PHP Edition
  5. Zend Studio
  6. Komodo IDE
  7. PhpStorm
  8. PHP Designer
  9. NuSphere PhpED
  10. Notepad++

Monday, March 7, 2016

PHP Convert Digit into Words

Use below code to convert digit into words.

 $number = 132560;
 $no = round($number);
 $point = round($number - $no, 2) * 100;
 $hundred = null;
 $digits_1 = strlen($no);
 $i = 0;
 $str = array();
 $words = array('0' => '', '1' => 'one', '2' => 'two',
    '3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
    '7' => 'seven', '8' => 'eight', '9' => 'nine',
    '10' => 'ten', '11' => 'eleven', '12' => 'twelve',
    '13' => 'thirteen', '14' => 'fourteen',
    '15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
    '18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
    '30' => 'thirty', '40' => 'forty', '50' => 'fifty',
    '60' => 'sixty', '70' => 'seventy',
    '80' => 'eighty', '90' => 'ninety');
 $digits = array('', 'hundred', 'thousand', 'lakh', 'crore');
 while ($i < $digits_1) {
     $divider = ($i == 2) ? 10 : 100;
     $number = floor($no % $divider);
     $no = floor($no / $divider);
     $i += ($divider == 10) ? 1 : 2;
     if ($number) {
        $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
        $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
        $str [] = ($number < 21) ? $words[$number] .
            " " . $digits[$counter] . $plural . " " . $hundred
            :
            $words[floor($number / 10) * 10]
            . " " . $words[$number % 10] . " "
            . $digits[$counter] . $plural . " " . $hundred;
     } else $str[] = null;
  }
  $str = array_reverse($str);
  $result = implode('', $str);
  echo $result;

Tuesday, August 18, 2015

PHP Convert Text into Unicode hex for Sending SMS

Use below function to convert text into Unicode hex value.

$text = 'अ';

function hex_chars($data){
    $mb_hex = '';
    for($i = 0 ; $i < mb_strlen($data,'UTF-8') ; $i++){
        $c = mb_substr($data,$i,1,'UTF-8');
        $o = unpack('N',mb_convert_encoding($c,'UCS-4BE','UTF-8'));
        $mb_hex .= sprintf('%04X',$o[1]);
    }
    return $mb_hex;

}

echo hex_chars($text);

Saturday, July 11, 2015

Install Laravel 5 Framework on Ubuntu OS

Laravel is a free, open-source PHP web application framework, created by Taylor Otwell and intended for the development of web applications following the model–view–controller (MVC) architectural pattern.

Website : laravel.com

1) Install LAMP server
  • sudo apt-get install python-software-properties
  • sudo add-apt-repository ppa:ondrej/php5-oldstable
  • sudo apt-get update
  • sudo apt-get install -y php5 php5-mcrypt
2) Install Apache
  • sudo apt-get install apache2 libapache2-mod-php5
3) Install MySQL
  • sudo apt-get install mysql-server php5-mysql
4) Install Composer
  • curl -sS https://getcomposer.org/installer | php
  • sudo mv composer.phar /usr/local/bin/composer
  • sudo chmod +x /usr/local/bin/composer
5) Install Laravel
  • cd /var/www/html/
  • git clone https://github.com/laravel/laravel.git
  • cd /var/www/html/laravel/
  • sudo composer install
  • sudo chown -R www-data.www-data /var/www/html/laravel
  • sudo chmod -R 755 /var/www/html/laravel
  • sudo chmod -R 777 /var/www/html/laravel/storage
6) New Apache VirtualHost
  • sudo vim /etc/apache2/sites-available/laravel.example.com.conf
    • Add Below code and save file.
<VirtualHost *:80>
        
        ServerName laravel.example.com
        DocumentRoot /var/www/html/laravel/public

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/html/laravel>
                AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

7) Start Website
  • a2ensite laravel.example.com
  • sudo service apache2 reload
8) Visit URL
If URL is not working then follow below steps:

A) Add new site entry in hosts file.
  • sudo vim /etc/hosts
  • Add "127.0.0.1 laravel.example.com"
B) Generate APP_KEY
  • php artisan key:generate
  • Vim "/var/www/html/laravel/config/app.php"
  • If app key is not updated in above file then enter key manually in below code.
  • 'key' => env('APP_KEY', '<ENTER_YOUR_NEW_APP_KEY>'),

If you get any issue in above then put it in comment.

Total Pageviews