Switch php version

Berikut adalah untuk switch dari satu versi php ke versi lainnya

sudo update-alternatives --config php

Setelah itu akan muncul pilihan sebagai berikut (tergantung php version yang sudah/pernah di install):

There are 5 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
  0            /usr/bin/php8.1   81        auto mode
  1            /usr/bin/php7.1   71        manual mode
  2            /usr/bin/php7.2   72        manual mode
* 3            /usr/bin/php7.4   74        manual mode
  4            /usr/bin/php8.0   80        manual mode
  5            /usr/bin/php8.1   81        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Reference: https://php.tutorials24x7.com/blog/how-to-switch-php-version-on-ubuntu-20-04-lts

Upgrade PHP 5.5.x to PHP 5.6 on Ubuntu 14.04

Kebutuhan ini muncul ketika bermaksud menggunakan PHPUnit 5.6 yang mensyaratkan PHP 5.6 padahal saat ini masih menggunakan PHP 5.5.9. Tetap diperhatikan jika Anda memiliki modul-modul tambahan lainnya bisa terjadi akan hilang begitu Anda upgrade biasanya karena link/file-file modul *.so nya tidak ada.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5

Pada saat proses di atas saya lakukan, eeh phalcon.so tidak berada lagi pada tempatnya sebagaimana ketika menggunakan PHP 5.5.9. So be carefull ya teman2.

 

Salam,

 

 

Crayon Code Highlighter … and welcome back :)

Sudah lama gak coding akhirnya kembali perlu berenang – renang kembali, ternyata nikmat nya sensasional. Semacam passion yang hilang terus ketemu lagi 🙂 Dan kembali sebagai bayi programmer … meniti satu-persatu wk kkkk

Ops sudah basa-basinya ya … jadi gak nyambung dengan judul di atas he he he

Ok untuk bisa menampilkan code-code saya gunakan plugin di wordpress yang bernama Crayon Code Highlighter. Kenapa Crayon ? karena enak sih 🙂 dan cantik tentunya …

Just  try :

<?php
   echo "Welcome to PHP tutorial";
?>

Cantik kan tampilan si Crayon … and hey code(s) … welcome back !

 

Eclipse untuk PHP Editor (PDT)

Versi Eclipse terbaru saat tulisan ini diturunkan adalah Eclipse 3.7 dengan nama Indigo.

Untuk menggunakan Eclipse sebagai editor bagai script PHP Anda, maka perlu ditambahkan package yang disebut dengan PDT (PHP Development Tools), Eclipse 3.7 Indigo menggunakan PDT 3.0

Instalasi Tools ini tidak lah terlalu sulit.

 

Alur proses instalasi

  • Buka Help -> Install New Software.
  • Pilih situs  the Indigo update site.
  • Eclipse akan mengambil daftar plugin dari internet, tunggulah sebentar (tergantung kecepatan internet di tempat Anda), jika daftar fitur yang ada sudah ditampilkan semua – pilih/check 'PHP Development Tools'.
  • Pastikan bahwa 'Contact all update sites…' sudah di'pilih' (Checked).

  • Selanjutnya proses dilanjutkan dengan klik pada 'Next', kemudian pilih 'Next' lagi di layar berikutnyan.
  • Silahkan setujui jika ditanya tentang EULA.

Proses instalasi :

  • Instalasi selesai, silahkan Eclipse di restart.

  • Setelah restart pilihkan perspective PHP, Selesai !

 

Warning: date() on ZendServer

Apabila Anda menemukan error seperti ini ketika menggunakan fungsi date()  :

Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Asia/Jakarta’ for ‘WIT/7.0/no DST’ instead in /home/toosa/public_html/basicphp/date1.php on line 2

Ini tandanya Zend Server Anda belum terisi dengan benar. Karena itu masuklah ke Administrasi Zend Server, masuk ke Server Setup lalu cari directive date.timezone , isilah sesuai dengan time zone yang Anda inginkan, misalnya Asia/Jakarta.

 

Memfungsikan PHP di userdir Apache Ubuntu 10.10

Ketika apache dan php di install di Linux Ubuntu 10.10, php memang sudah bisa dijalankan di /var/www, tetapi ketika kita mengaktifkan modul userdir agar /home/username/public_html bisa digunakan, ternyata baru .html yang bisa diaktifkan, sedangkan *.php belum bisa berjalan. ini karena secara default php5.conf belum mengaktifkan php di public_html.

Bukalah file /etc/apache2/mods-enabled/php5.conf :

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule …> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    <IfModule mod_userdir.c>
         <Directory /home/*/public_html>
             php_admin_value engine Off
         </Directory>
    </IfModule>
</IfModule>
 

Anda harus memberikan remark (#) seperti di bawah ini :

<IfModule mod_php5.c>
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch "\.phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>
    # To re-enable php in user directories comment the following lines
    # (from <IfModule …> to </IfModule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
   # <IfModule mod_userdir.c>
   #     <Directory /home/*/public_html>
   #          php_admin_value engine Off
   #     </Directory>
   # </IfModule>

</IfModule>

Terakhir jangan lupa merestart Apache nya :

$ /etc.init.d/apache2 restart

Start Using Zend Framework 1.11

Zend Framework is one of popular PHP Framework which mostly use for enterprise application. So it will be a little bit complex for the beginers. But don’t worry, I am a beginers too :). I assume that your server is the same with mine, it use linux/unix operating system and can be accessed by ssh/telnet. When I wrote this post, I still use ZF ver. 1.11.

Ok then, lets rock !

1. Get Zend Framework and prepare your site based on Zend Framework

We will get the latest zend framework ini minimal configuration , extract and rename it (I choose ZendFramework-1.11.9-minimal) to ZendFramework then place it under public_html directory (or you can place as you like).

# cd /home/username/public_html

# tar -zxvf  ZendFramework-1.11.9-minimal.tar.gz

# mv ZendFramework-1.11.9-minimal ZendFramework

We will use Zend Tools which located in ZendFramework/bin/zf.sh, so we need to create an alias. You need to modify /home/username/.bashrc by add the text bellow at the end of file :

alias zf.sh=/home/username/public_html/ZendFramework/bin/zf.sh

After you modify this file, you need to re-login. Now, every time You login, Zend tools is ready to use 🙂

Check your Zend Tools :

# zf.sh show version

Zend Framework Version: 1.11.9

2. Create a ZF project (let say “zfstart”).

# cd /home/username/public_html

# zf.sh create project zfstart

3. Create a symbolic link of your zend library to your project library directory

# cd /home/username/public_html/zfstart/library

# ln -s /home/username/public_html/ZendFramework/library/Zend

4. And finaly you will have zfstart project directory structure bellow:

5. Test your project

http://yourdomain/zfstart/public

Then you should see like this bellow :

Congratulation !