Panduan Pemula Symfony


Catatan: Tutorial ini menggunakan Sistem Operasi Windows.

Instalasi Webserver, PHP, dan MySQL

Webserver: Apache HTTPD

Sebagai webserver, coba Apache HTTPD (http://httpd.apache.org), download versi terakhir (2.2.x) kemudian install. Setelah instalasi selesai, buka browser:

http://localhost

Dan hasilnya “It works!”, ini menandakan instalasi apache telah selesai, selanjutnya kita akan mengkonfigurasi httpd agar bisa menyajikan aplikasi symfony.

Database: MySQL

Database MySQL dapat diambil di sini (http://dev.mysql.com/downloads/). Untuk klien anda dapat menggunakan MySQL GUI Tools yang juga dapat diambil dari lokasi yang sama. Atau, untuk klien web based gunakan PHPMyAdmin (http://www.phpmyadmin.net/home_page/downloads.php).

PHP

Download PHP di http://www.php.net/downloads.php. Umumnya, paket binari PHP untuk Windows berbentuk arsip atau paket installer. Download paket arsip untuk versi 5.2.x dan ekstrak ke C:\PHP.

Sekarang waktunya menyiapkan php.ini, konfigurasi PHP contoh sudah disertakan dalam arsip–php.ini-dist danphp.ini-recommended–untuk saat ini, kita gunakan file php.ini-dist, cukup copy file tersebut dan ubah menjadi php.ini.

Beberapa konfigurasi PHP perlu dimodifikasi, jadi gunakan teks editor favoritmu–semisal Notepad++–untuk mengedit php.ini:

Jika perlu, atur include path, cari baris berikut (baris 476):

; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Ubah menjadi:

; Windows: "\path1;\path2"
include_path = ".;C:\PHP\PEAR"

Atur direktori extension, cari baris ini (baris 491):

; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"

Ubah menjadi:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP\ext\"

Aktifkan ekstensi-ekstensi yang diperlukan, cari baris ini (baris 604):

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.

;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_msql.dll
;extension=php_mssql.dll
;extension=php_mysql.dll
;extension=php_mysqli.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
;extension=php_zip.dll

Anda bisa mengaktifkan ekstensi mbstring, mysql, pdo, pdo_mysql dan ekstensi lain yang mungkin diperlukan oleh proyek anda semisal gd2 dengan menghapus komentar (;–titik-koma) diawal tiap baris.
Juga, anda dapat menambahkan ekstensi xdebug (http://www.xdebug.org/download.php) dan letakkan di C:\PHP\ext\php_xdebug.dll kemudian tambahkan baris-baris berikut setelah konfigurasi di atas:

zend_extension_ts=C:\PHP\ext\php_xdebug.dll

Untuk membuat ekstensi mysql berjalan baik di PHP, copy libmysql.dll yang disediakan dariC:\PHP\libmysql.dll ke C:\WINDOWS\system32\.

Buka Command Prompt dan ketik perintah berikut untuk menginstall paket PEAR yang di-bundle:
cd C:\PHP
go-pear.bat

Gunakan nilai baku pada waktu menginstall PEAR, cukup tekan saja ENTER untuk menerima.
Berikut contoh output:

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : C:\PHP
 2. Temporary directory for processing            : C:\PHP\tmp
 3. Temporary directory for downloads             : C:\PHP\tmp
 4. Binaries directory                            : C:\PHP
 5. PHP code directory ($php_dir)                 : C:\PHP\pear
 6. Documentation directory                       : C:\PHP\docs
 7. Data directory                                : C:\PHP\data
 8. User-modifiable configuration files directory : C:\PHP\cfg
 9. Public Web Files directory                    : C:\PHP\www
10. Tests directory                               : C:\PHP\tests
11. Name of configuration file                    : C:\WINDOWS\pear.ini
12. Path to CLI php.exe                           : C:\PHP\.

1-12, 'all' or Enter to continue:
Beginning install...
Configuration written to C:\WINDOWS\pear.ini...
Initialized registry...
Preparing to install...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar...

installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.7.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar.
..
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
install ok: channel://pear.php.net/Archive_Tar-1.3.2
install ok: channel://pear.php.net/Console_Getopt-1.2.3
install ok: channel://pear.php.net/Structures_Graph-1.0.2
install ok: channel://pear.php.net/PEAR-1.7.2
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

PEAR: To install optional features use "pear install pear/PEAR#featurename"

** WARNING! Old version found at C:\PHP, please remove it or be sure to use the
new c:\php\pear.bat command

The 'pear' command is now at your service at c:\php\pear.bat

** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\php\pear.bat' until you have added
** 'C:\PHP' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

http://pear.php.net/faq.php
http://pear.php.net/manual/

Thanks for using go-pear!

* WINDOWS ENVIRONMENT VARIABLES *
For convenience, a REG file is available under C:\PHP\PEAR_ENV.reg .
This file creates ENV variables for the current user.

Double-click this file to add it to the current user registry.

Press any key to continue . . .

Setup Sebuah Proyek

Untuk setup proyek symfony lihat Mengintegrasikan Symfony dengan Eclipse PDT.

Menjalankan Symfony

Saatnya menyiapkan Apache agar bisa melayani aplikasi symfony. Konfigurasi apache terletak di C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. Pada tahap ini dan selanjutnya, Saya mengasumsikan proyek anda terletak di C:\Project\myproject dan librari symfony terletak di C:\Project\symfony.

Konfigurasi Apache HTTPD agar Mengenali Skrip PHP

Cari konfigurasi Dynamic Shared Object (DSO) Support, kemudian tambahkan konfigurasi berikut (tambahkan hanya dalam komentar BEGIN s/d END):

#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so

### BEGIN ADD ###

# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

### END ADD ###
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

Tambahkan index.php sebagai DirectoryIndex, cari:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

Ubah menjadi:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
Konfigurasi Modul Apache

Saat ini module apache yang dibutuhkan baru mod_rewrite, cari:

#LoadModule rewrite_module modules/mod_rewrite.so

Dan hapus komentar dari baris tersebut menjadi:

LoadModule rewrite_module modules/mod_rewrite.so

Jika anda membutuhkan modul yang lain, aktifkan modul yang diinginkan sesuai yang diperlukan.

Setup Virtual Host

Untuk mendukung virtual host, tambahkan baris berikut ke akhir konfiurasi apache:

### all vhost configurations
Include conf/myconf/*.conf

Konfigurasi Apache selesai. Sekarang saatnya membuat konfigurasi virtual host untuk aplikasi symfony–myproject. Buat file myproject.conf dan letakkan di C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\myproject.conf
<VirtualHost *:80>
    ServerAdmin admin@myproject.localhost
    #ServerName myproject.localhost
    #ServerAlias www.myproject.localhost
    ErrorLog "logs/myproject.localhost-error.log"
    CustomLog "logs/myproject.localhost-access.log" common
    DocumentRoot "C:/Project/myproject/web"
<Directory "C:/Project/myproject/web">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
<Directory "C:/Project/symfony/data/web/sf">
        AllowOverride All
        Allow from all
</Directory>
    Alias /sf "C:/Project/symfony/data/web/sf"
</VirtualHost>

Tambahkan konfigurasi lain, semisal untuk PHPMyAdmin. File-file PHPMyAdmin dapat diletakkan di C:\Project\phpmyadmin:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\phpmyadmin.conf
<Directory "C:/Project/phpmyadmin">
    AllowOverride All
    Allow from all
</Directory>

Alias /phpmyadmin "C:/Project/phpmyadmin"
Jelajah Aplikasi Anda

Restart web server Apache httpd, buka Command Prompt, ketik:
net stop Apache2.2
net start Apache2.2

Sekarang buka browser anda dan pergi ke:
http://localhost/frontend_dev.php

Advertisements

, , ,

  1. #1 by ira on March 3, 2009 - 3:27 pm

    Thx mas Toha. Ternyata yang kucari udah ada di sini. Kayaknya bisa mulai dicoba nih. Mudah-mudahan ilmunya mas Toha makin bertambah, biar bisa ditularkan ke temen-temen. He he….. Jangan bosen kalo sering ada pertanyaan ya……

  2. #2 by tohenk on March 6, 2009 - 1:07 pm

    Semoga Mbak Ira sukses belajar symfony. Jangan sungkan-sungkan kalo ada pertanyaan. Everything are welcomed…. 🙂

  3. #3 by Haekal Fikri on October 22, 2009 - 4:13 pm

    punya demo aplikasi simpeg, kalau ada boleh dong minta, soal nya ada temen mau nyari simpeg. terima kasih sebelumnya

    • #4 by tohenk on October 23, 2009 - 7:08 pm

      Situs http://bkdjombang.com/ juga sebagai contoh aplikasi Simpeg Online, coba lihat-lihat ke sana dulu…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: