ServBay'in Dahili Xdebug Modülünü Nasıl Etkinleştirebilirsiniz?
Güçlü bir entegre web geliştirme aracı olarak ServBay, Xdebug modülü ile birlikte gelir ve bu modülün etkinleştirilmesi oldukça basittir. Xdebug, PHP için bir hata ayıklama ve analiz aracıdır ve geliştiricilerin kod çözümlemesini, performans analizini ve kod kapsamını değerlendirmesini sağlar; bu, PHP uygulamalarının geliştirilmesi ve bakımı için hayati bir araçtır.
Xdebug Modül Tanıtımı
Xdebug, PHP kodunu hata ayıklamak ve analiz etmek için güçlü bir PHP uzantısıdır. Hata ayıklama, yığın izleme, değişken izleme gibi zengin hata ayıklama özellikleri sunar. Ayrıca, Xdebug performans analizini ve kod kapsamını destekler, geliştiricilerin kod performansını optimize etmelerine ve kod kalitesini sağlamalarına yardımcı olur.
Ana Özellikler
- Breakpoint Hata Ayıklama: Xdebug, kod içinde breakpoint belirlemeyi, kodu satır satır hata ayıklamayı destekler, bu da hataları bulmayı ve düzeltmeyi kolaylaştırır.
- Yığın İzleme: Hata durumlarında Xdebug ayrıntılı yığın izleme bilgiler üretebilir, bu da geliştiricilerin sorunları hızlıca tespit etmelerine yardımcı olur.
- Performans Analizi: Xdebug performans analizi özelliği sunar ve geliştiricilere kod performansını optimize etmeleri amacıyla ayrıntılı performans raporları sağlar.
- Kod Kapsamı: Xdebug, kod kapsamı tespitini destekler, bu da geliştiricilere tüm kod yollarının test edildiğini sağlamalarında yardımcı olur.
- Entegre Geliştirme Ortamı Desteği: Xdebug, PHPStorm, Visual Studio Code gibi çeşitli entegre geliştirme ortamları (IDE'ler) ile entegre olabilir ve kullanışlı hata ayıklama deneyimi sağlar.
ServBay'in Dahili Xdebug Modül Versiyonu
ServBay, çeşitli PHP versiyonlarını destekler ve bu versiyonların her biri için ilgili Xdebug modülünü ön yüklü olarak sunar. Detaylı versiyon listesi aşağıdaki gibidir:
- PHP 5.6, 7.0, 7.1: Xdebug 2.5.5
- PHP 7.2, 7.3, 7.4: Xdebug 3.1.6
- PHP 8.0, 8.1, 8.2, 8.3: Xdebug 3.3.1
- PHP 8.4: Xdebug 3.4.0-dev
İpucu
Her PHP versiyonunun Xdebug portu birbirinden bağımsızdır ve versiyon numarasıyla ilişkilidir. Örneğin, PHP 7.2
'nin Xdebug portu 39072
, PHP 8.3
'ün Xdebug portu 39083
'dür.
Xdebug Modülünü Nasıl Etkinleştirebilirsiniz?
Varsayılan olarak, Xdebug modülü devre dışıdır. Xdebug modülünü etkinleştirme adımları oldukça basittir; yalnızca ilgili PHP versiyonunun yapılandırma dosyasını değiştirmeniz yeterlidir. Adım adım talimatlar aşağıda verilmiştir:
Adım 1: Yapılandırma Dosyasını Bulma
Öncelikle, ilgili PHP versiyonunun conf.d
dizinine gidin. Örneğin, PHP 8.3 için Xdebug modülünü etkinleştirmek istiyorsanız aşağıdaki dosyayı düzenlemeniz gerekecektir:
/Applications/ServBay/etc/php/8.3/conf.d/xdebug.ini
Adım 2: Yapılandırma Dosyasını Düzenleme
xdebug.ini
dosyasını açın ve aşağıdaki içeriğin yorum satırını kaldırın:
[Xdebug]
; XDebug'ı etkinleştirmek için aşağıdaki satırın yorumunu kaldırın
zend_extension = xdebug.so
2
3
Adım 3: Xdebug Parametrelerini Yapılandırma
Xdebug'ın özelliklerinden tam anlamıyla yararlanabilmek için xdebug.ini
dosyasında bazı sık kullanılan parametreleri yapılandırabilirsiniz. Örneğin:
xdebug.mode=debug,develop
xdebug.start_with_request=yes
xdebug.client_host=localhost
xdebug.client_port=39083
xdebug.log=/Applications/ServBay/logs/xdebug/8.3/xdebug.log
2
3
4
5
Adım 4: PHP Hizmetini Yeniden Başlatma
ServBay'in hizmet yönetim panelinde ilgili PHP hizmetini yeniden başlatın. Örneğin, PHP 8.3 hizmetini yeniden başlatın. Yeniden başlatmanın ardından, Xdebug modülü başarıyla yüklenecektir.
Xdebug Modülünün Başarıyla Yüklenip Yüklenmediğini Doğrulama
Xdebug modülünün başarılı bir şekilde yüklenip yüklenmediğini teyit etmek için basit bir PHP dosyası oluşturabilirsiniz. Web sunucusunun kök dizininde phpinfo.php
adlı bir dosya oluşturun ve aşağıdaki içeriği ekleyin:
<?php
phpinfo();
?>
2
3
https://servbay.host/phpinfo.php
adresine gidin ve PHP bilgi sayfasında Xdebug modülüne ait bilgileri arayın. Eğer Xdebug ile ilgili bilgileri görüyorsanız, modül başarıyla yüklenmiş demektir.
PHPStorm'da Xdebug'ı Yapılandırma
PHPStorm'da Xdebug kullanarak hata ayıklamak için şu adımları izleyin:
Adım 1: PHPStorm'u Açın ve Ayarlara Gidin
- PHPStorm'u açın.
- Menü çubuğundan
File
'a tıklayın ve ardındanSettings
(Windows/Linux) veyaPreferences
(macOS) seçeneğini seçin.
Adım 2: PHP Yorumlayıcısını Yapılandırma
- Ayarlar penceresinde,
Languages & Frameworks
->PHP
bölümüne gidin. CLI Interpreter
bölümünde, sağ taraftaki...
düğmesine tıklayın.- Açılan pencerede,
+
işaretine tıklayarak yeni bir PHP yorumlayıcısı ekleyin,Local
'ı seçin. - PHP yorumlayıcı yolunu ServBay içindeki ilgili PHP versiyonunun yolu olarak ayarlayın, örneğin
/Applications/ServBay/package/php/8.3/8.3.7/bin/php
. - Ayarları kaydetmek için
OK
düğmesine tıklayın.
Adım 3: Xdebug Hata Ayıklamayı Yapılandırma
İpucu
Her PHP versiyonunun Xdebug portu birbirinden bağımsızdır ve versiyon numarasıyla ilişkilidir. Örneğin, PHP 7.2
'nin Xdebug portu 39072
, PHP 8.3
'ün Xdebug portu 39083
'dür.
- Ayarlar penceresinde,
Languages & Frameworks
->PHP
->Debug
bölümüne gidin. Xdebug
bölümünde,Debug Port
ayarını39083
olarak ayarlayın,xdebug.client_port
ile aynı.Can accept external connections
seçeneğinin işaretli olduğundan emin olun.- Ayarları kaydetmek için
Apply
ardındanOK
düğmesine tıklayın.
Adım 4: PHP Web Uygulama Sunucusunu Yapılandırma
- Ayarlar penceresinde,
Languages & Frameworks
->PHP
->Servers
bölümüne gidin. - Yeni bir sunucu yapılandırması eklemek için sağ taraftaki
+
simgesine tıklayın. - Sunucu adını ayarlayın, örneğin
ServBay Localhost
. Host
ayarını ServBay ana bilgisayarınızdaki host adıyla ve portu 443 (HTTPS) olarak ayarlayın, örneğinservbay.new
.Debugger
olarakXdebug
'ı seçin.- Ayarları kaydetmek için
OK
düğmesine tıklayın.
Adım 5: Hata Ayıklama Oturumunu Başlatma
- PHPStorm'da hata ayıklamak istediğiniz PHP projesini açın.
- Koddaki bir satırın sol tarafındaki boş alana tıklayarak bir breakpoint yerleştirin.
- PHPStorm'un üst araç çubuğunda
Start Listening for PHP Debug Connections
düğmesine tıklayın (küçük böcek simgesi). - Tarayıcınızda PHP uygulamanıza gidin, Xdebug otomatik olarak PHPStorm'a bağlanacak ve breakpoint noktasında duracaktır.
Sonuç
ServBay, Xdebug modülünü yönetmek ve etkinleştirmek için kullanışlı bir yöntem sunar. Basit konfigurasyon ve yeniden başlatma işlemleriyle, geliştiriciler farklı PHP versiyonlarında Xdebug modülünü hızla etkinleştirebilir ve güçlü hata ayıklama ve analiz özelliklerinden tam anlamıyla yararlanabilirler. Xdebug'ın breakpoint hata ayıklaması, performans analizi ve kod kapsamı değerlendirme özellikleri, PHP geliştiricileri için vazgeçilmez bir araç haline getirir.