Buka terminal:
php -v
Contoh hasil:
PHP 8.3.16
php -i | findstr Thread
Jika hasil:
Thread Safety => enabled
berarti:
TS (Thread Safe)
Jika:
Thread Safety => disabled
NTS (Non Thread Safe)
WAJIB install.
Download:
https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?utm_source=chatgpt.com
Install versi:
x64
https://github.com/microsoft/msphpsql/releases?utm_source=chatgpt.com
Jika PHP TS:
Gunakan:
php_sqlsrv_83_ts_x64.dll php_pdo_sqlsrv_83_ts_x64.dll
Jika PHP NTS:
php_sqlsrv_83_nts_x64.dll php_pdo_sqlsrv_83_nts_x64.dll
Contoh lokasi:
C:\laragon\bin\php\php-8.3.16-Win32-vs16-x64\ext
Lokasi:
C:\laragon\bin\php\php-8.3.16-Win32-vs16-x64\php.ini
Tambahkan:
TS extension=php_sqlsrv_83_ts_x64.dll extension=php_pdo_sqlsrv_83_ts_x64.dll
NTS extension=php_sqlsrv_83_nts_x64.dll extension=php_pdo_sqlsrv_83_nts_x64.dll
Menu:
Laragon → PHP → Reload
atau restart Laragon.
php -m
Harus muncul:
sqlsrv pdo_sqlsrv
Contoh file test_koneksi.php:
<?php $serverName = "10.100.1.25"; $connectionOptions = array( "Database" => "master", "Uid" => "sa", "PWD" => "password", // bypass SSL internal/self-signed "TrustServerCertificate" => true, "Encrypt" => false ); $conn = sqlsrv_connect($serverName, $connectionOptions); if ($conn) { echo "Koneksi berhasil!"; } else { print_r(sqlsrv_errors()); }
Jalankan pada terminal vs code
php .\test_koneksi.php
Jika berhasil:
Koneksi berhasil!
No due date set.
This issue currently doesn't have any dependencies.
Deleting a branch is permanent. It CANNOT be undone. Continue?
1. Cek versi PHP
Buka terminal:
Contoh hasil:
2. Cek TS atau NTS
Jika hasil:
berarti:
Jika:
berarti:
NTS (Non Thread Safe)
3. Install ODBC Driver SQL Server
WAJIB install.
Download:
Install versi:
4. Download SQLSRV Driver PHP
Download:
5. Pilih DLL sesuai PHP
Jika PHP TS:
Gunakan:
Jika PHP NTS:
Gunakan:
6. Copy DLL ke folder ext
Contoh lokasi:
7. Edit php.ini
Lokasi:
Tambahkan:
8. Restart Laragon
Menu:
atau restart Laragon.
9. Verifikasi extension aktif
Harus muncul:
10. Test koneksi SQL Server
Contoh file test_koneksi.php:
11. Jalankan file
Jalankan pada terminal vs code
Jika berhasil: