Background
Break News
How to add local font to Tailwind Css and NextJS? - Tutorial Design Pattern? - Blockchain Technology, How to create own Bitcoin virtual currency - Zustand mordern management state - Design Pattern - Flyweight Pattern? - Docker Full training Topic

How to "setup SQL Server Driver" php (XAMP/MAMP) on Window "MacOS"

Wednesday 3 August 2022
|
Read: Completed in minutes

How to "setup SQL Server Driver" php (XAMP/MAMP) on Window "MacOS"

✋✋✋✋Hello Everybody, welcome to Learn Tech Tips blogspot, nice to see you again,

I am Zidane (my chinese nick name is 雞蛋 🥚🥚🥚🥚🥚🥚🥚🥚)

This topic today is show you detail how to setup sql server driver php (using MAMP) on Window and MacOS environment. 

How to setup SQL Server Driver php (XAMP/MAMP) on Window MacOS

Currently when working with PHP, already have many framework support connect with SQL Server Example: Cakephp, Laravel, .... Summary is use PHP connect with SQL Server.

For do that, we need to setup the SQL Server driver first

On this topic I will show you a way on 2 environments


Window

On Window environment will be simple than MACOS

- Step 1:  just go inside below link and download the file setup it (current version is 5.10)

- Step 2: go copy extension from SQL Server driver to MAMP/php/ext or XAMP/php/ext

How to setup sql server driver php (XAMP/MAMP) on window MACOS  
The Important things is which version XAMP/MAMP of your php you should copy the driver same with your version. On my this topic my XAMP version is 7.4.29 and my window is 64 bit so I will copy php_pdo_sqlsrv_74_ts_x64.dll and php_sqlsrv_74_ts_x64.dll to ext of XAMP / MAMP.
 
- Step 3: access your XAMP, MAMP php.ini add above 2 extension into php.ini file

extension=php_pdo_sqlsrv_74_ts_x64.dll
extension=php_sqlsrv_74_ts_x64.dll

- Step 4: Restart XAMP / MAMP for change to take effect


MacOS

This is a guide how you can install Microsoft SQL Driver on MAMP server on a MACOS for PHP

When you tried to communicating with Microsoft SQL Server in PHP  , you would have noticed it is a lot of a hassle, 👿

- Step 1: Install brew

If you don't have Brew installed, open terminal and run:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The above instruction would install Brew. next run:

brew tap

brew tap homebrew/core

- Step 2: Use MAMP's / XAMP's version of PHP instead of the default on OSX

export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

ex: my version is 7.4.29

export PATH=/Applications/MAMP/bin/php/php7.4.29/bin:$PATH

In order to verify that operation was successfully, let's check the php version on the terminal by runnung the following comand

php -v

You should now see the sme php version on yout MAMP / XAMP on your terminal also.

- Step 3: Install prerequisites (my current version is Microsoft ODBC Driver 17 for SQL Server) 


Next, we have to install the prerequsites for the driver by running the following code:
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql17 mssql-tools
In addition, you may need to install the GNU make tools by running:
brew install autoconf automake libtool
 

-Step 4: Install the PHP drivers for Microsoft SQL Server
Next, we proceed to installing the PHP drivers ex: pdo_sqlsrv.so & sqlsrv.so:
First, we navigate to the php version file in mamp

cd /Applications/MAMP/bin/php/php7.4.29/bin

Next, we download the drivers by running:
sudo pecl install sqlsrv


sudo pecl install pdo_sqlsrv
 

After the download is complete, we then have to add the name of the newly installed driver extention to the php.ini file to complete the installation process.

* Copy the downloaded driver extension name on the terminal 

extension=pdo_sqlsrv.so
extension=sqlsrv.so.


* Navigate to /Applications/MAMP/bin/php/php7.4.29/config/ on finder.
* Open the php.ini file with any text editor.
* Use the keyboard shortcut command + F to search for the word extension.
* Paste the copied driver extension names below the listed extension.
* Finally restart the MAMP / XMAP in order to restart the Apache server.

In order to verify if the installation was successfull, Open the MAMP localhost page on the browser.

Click on the php info link to get to the phpinfo.php page.
 

Use the keyboard shortcut command + F to search for the word 'sqlsrv' you should now see the sqlsrv extentions pop up on the page. and you are done.

Reference:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017

https://stackoverflow.com/questions/4145667/how-to-override-the-path-of-php-to-use-the-mamp-path

https://www.youtube.com/watch?v=KrEIoTBeL70


 

 



 

 


Thanks for reading the topic how to setup SQL Server Driver PHP with MAMP, XAMP on WINDOW and MACOS. Any feedback and questions. Leave your comment on below post, we can discuss about it.
✋✋✋✋ Webzone Tech Tips - I am Zidane, See you next time

🙇🏼🙇🏼 We Appreciate Your Comments and Suggestions - Webzone, all things Tech Tips web development
Popular Webzone Tech Tips topic maybe you will be like it - by Webzone Tech Tips - Zidane
As a student, I found Blogspot very useful when I joined in 2014. I have been a developer for years . To give back and share what I learned, I started Webzone, a blog with tech tips. You can also search for tech tips zidane on Google and find my helpful posts. Love you all,

I am glad you visited my blog. I hope you find it useful for learning tech tips and webzone tricks. If you have any technical issues, feel free to browse my posts and see if they can help you solve them. You can also leave a comment or contact me if you need more assistance. Here is my blog address: https://learn-tech-tips.blogspot.com.

My blog where I share my passion for web development, webzone design, and tech tips. You will find tutorials on how to build websites from scratch, using hot trends frameworks like nestjs, nextjs, cakephp, devops, docker, and more. You will also learn how to fix common bugs on development, like a mini stackoverflow. Plus, you will discover how to easily learn programming languages such as PHP (CAKEPHP, LARAVEL), C#, C++, Web(HTML, CSS, javascript), and other useful things like Office (Excel, Photoshop). I hope you enjoy my blog and find it helpful for your projects. :)

Thanks and Best Regards!
Follow me on Tiktok @learntechtips and send me a direct message. I will be happy to chat with you.
Webzone - Zidane (huuvi168@gmail.com)
I'm developer, I like code, I like to learn new technology and want to be friend with people for learn each other
I'm a developer who loves coding, learning new technologies, and making friends with people who share the same passion. I have been a full stack developer since 2015, with more than years of experience in web development.
Copyright @2022(November) Version 1.0.0 - By Webzone, all things Tech Tips for Web Development Zidane
https://learn-tech-tips.blogspot.com