Page MenuHomeSolus

Microsoft PHP 7.1 & 7.2 SQL Server Driver Package
Open, NormalPublic

Description

Hi Solus Team. I want to make a Package Request.

  1. Software Name : Microsoft Drivers for PHP (7.1 & 7.2) for Microsoft SQL Server
  2. Project & Product homepage : https://github.com/Microsoft/msphpsql
  3. Other homepage : https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017
  4. Main Reason: More and more Solus users are growing. Of course more and more programmers are also interested in using it. Many friends (PHP and SQL Server programmers) in Indonesia are hesitant to use Solus because they have not found PHP drivers to SQL Server.
  5. Is is open source? : Yes
  6. Source Link : https://github.com/Microsoft/msphpsql.git

Thanks.

Details

Differential Revisions
D3786: Initial commit of php-mssql
DataDrake triaged this task as Normal priority.Aug 28 2018, 11:18 AM
DataDrake moved this task from Backlog to Accepted For Inclusion on the Package Requests board.
This comment was removed by JoshStrobl.

@arihtakid Removed your comment and I discourage you doing that, especially given you haven't consulted us about it. Spamming groups in various messaging channels and social media about Solus is not how I'd want it "marketed". Your comment is also not relevant to the task.

I wanted to give it a try, but I'm not sure if it is possible. The PHP packages rely on the Microsoft ODBC Driver for SQL Server on Linux, which has a proprietary license ans only packages for Ubuntu, RHEL etc.

We could ship the driver in 3rd party and then use it as a rundep.. but that's far from easy to use.

kyrios123 added a subscriber: kyrios123.EditedAug 28 2018, 6:05 PM

I extracted the license from the source. This statement is very funny as it's a linux/macOS driver:
distribute Distributable Code to run on a platform other than the Windows platform;

a. Distributable Code.
i. Right to Use and Distribute. If you comply with the terms below:
• You may copy and distribute the object code form of the software (“Distributable Code”) in programs you develop; and
• You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.
ii. Distribution Requirements. For any Distributable Code you distribute, you must
• add significant primary functionality to it in your programs;
• for any Distributable Code having a filename extension of .lib, distribute only the results of running such Distributable Code through a linker with your program;
• distribute Distributable Code included in a setup program only as part of that setup program without modification;
• require distributors and external end users to agree to terms that protect it at least as much as this agreement;
• display your valid copyright notice on your programs; and
• indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs.
iii. Distribution Restrictions. You may not
• alter any copyright, trademark or patent notice in the Distributable Code;
• use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft;
• distribute Distributable Code to run on a platform other than the Windows platform;
• include Distributable Code in malicious, deceptive or unlawful programs; or
• modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a >condition of use, modification or distribution, that
• the code be disclosed or distributed in source code form; or
• others have the right to modify it.

I wanted to give it a try, but I'm not sure if it is possible. The PHP packages rely on the Microsoft ODBC Driver for SQL Server on Linux, which has a proprietary license ans only packages for Ubuntu, RHEL etc.

We could ship the driver in 3rd party and then use it as a rundep.. but that's far from easy to use.

I have also sent a request on the Github page about about 3 months ago, on this link : Solus Projects Support. But they gave less satisfying answers.

I have also sent a request on the Github page about about 3 months ago, on this link : Solus Projects Support. But they gave less satisfying answers.

That's not really a surprise since there are lots of other distros who are still bigger and more popular than Solus and they don't want to maintain all of them. So we have to do it ourselves :)

Alright... had some time to try it and it seems to work, but unfortunately not completely out-of-the-box. You can see the packages at D3785 and D3786.
The ODBC driver needs some info in the odbcinst.ini which is already provided by the package unixodbc and therefore must be edited by hand (copy the contens of /etc/msodbcsql/odbcinst.ini to /etc/odbcinst.ini).
I currently don't have a MSSQL database installed, so if anybody could test it... that would be fine.

Alright... had some time to try it and it seems to work, but unfortunately not completely out-of-the-box. You can see the packages at D3785 and D3786.
The ODBC driver needs some info in the odbcinst.ini which is already provided by the package unixodbc and therefore must be edited by hand (copy the contens of /etc/msodbcsql/odbcinst.ini to /etc/odbcinst.ini).
I currently don't have a MSSQL database installed, so if anybody could test it... that would be fine.

Incredible!

I want to be a tester, but I have no idea how to start. I have never been a developer of Solus. Do you have instructions for the steps? Or if you want to get access to our SQL Server for testing purposes, I would love to give (of course via personal email to yusrenz@gmail.com).
Thanks in advance

Are you using Windows/AD-Logins or mixed authentication?
I installed MS SQL 2017 Evaluation in a Windows VM, created a user with "SQL Server Authentication" and successfully connected & executed a query. But I couldn't get it to work with kerberos.

$ sqlcmd -S 192.168.103.66 -U sysop -P "password"
1> select * from dbo.MSreplication_options
2> GO
optname                                                                                                                          value major_version minor_version revision    install_failures
-------------------------------------------------------------------------------------------------------------------------------- ----- ------------- ------------- ----------- ----------------
transactional                                                                                                                        1            90             0           0                0
merge                                                                                                                                1            90             0           0                0
security_model                                                                                                                       1            90             0           0                0

(3 rows affected)

Haven't tried it with PHP yet. You can download these packages and install them by hand with sudo eopkg it *.eopkg: msodbcsql & php-mssql
If you want to build it yourself you can start by reading the articles in the help center.

Alright, seems to work with PHP as well:

<?php
    echo "\n";
    $serverName = "tcp:192.168.103.66,1433";
    $connectionOptions = array("Database"=>"master", "Uid"=>"sysop", "PWD"=>"Password");
	
	 //Establishes the connection
	 $conn = sqlsrv_connect($serverName, $connectionOptions);
	 //Select Query
	 $tsql = "SELECT * FROM dbo.MSreplication_options";
	 //Executes the query
	 $getProducts = sqlsrv_query($conn, $tsql);
	 var_dump(sqlsrv_fetch_array($getProducts, SQLSRV_FETCH_ASSOC));
	 die();

Output:

array(6) {
  'optname' =>
  string(13) "transactional"
  'value' =>
  int(1)
  'major_version' =>
  int(90)
  'minor_version' =>
  int(0)
  'revision' =>
  int(0)
  'install_failures' =>
  int(0)
}
arihtakid added a comment.EditedSep 4 2018, 3:41 PM

Are you using Windows/AD-Logins or mixed authentication?
I installed MS SQL 2017 Evaluation in a Windows VM, created a user with "SQL Server Authentication" and successfully connected & executed a query. But I couldn't get it to work with kerberos.
Haven't tried it with PHP yet. You can download these packages and install them by hand with sudo eopkg it *.eopkg: msodbcsql & php-mssql
If you want to build it yourself you can start by reading the articles in the help center.

I'm using mixed auth for SQL Server DB conn.
So, I've tested it by installing 2 .eopkg links that you provided. And it runs perfectly with PHP7.2. (Laravel 5.7) !
But won't work with PHP7.1 version.
Error appears as below, when I reload Apache Server.

[04-Sep-2018 15:26:33 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/sqlsrv.so' - /opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/sqlsrv.so) in Unknown on line 0
[04-Sep-2018 15:26:33 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/pdo_sqlsrv.so' - /opt/lampp/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/pdo_sqlsrv.so) in Unknown on line 0

I tried installing gclib and libstdc++, but the system says that it already exists.

We only have PHP 7.2 in the repos and don't plan to support multiple versions. Where did you get PHP 7.1?

arihtakid added a comment.EditedSep 5 2018, 1:23 AM

We only have PHP 7.2 in the repos and don't plan to support multiple versions. Where did you get PHP 7.1?

I'm doing this way
PHP7.1 and Composer

So I've tested all my project (Laravel 5.6 and 5.7) with PHP7.2 and PHP7.2 SQL Driver. The results are very satisfying. I was hesitant about PHP7.2 before, which I remember many deprecated functions. After I tried all the modules and found no errors. Thank you very much for your help. Long Life Solus!

Yeah the XAMPP way won't work because the SQL plugins are compiled against our PHP version. You can't just use them with another PHP build.

Good to know that this setup is working for you! However please keep in mind that this is some kind of "preview" and I am no member of the Solus team, just a contributor. So follow D3785 and D3786 - maybe the package names will change, maybe it won't be accepted at all.. we'll see. For the future: As you can see in R2424 we moved from PHP 7.0.18 to 7.1.4 and from 7.1.16 to 7.2.5, this will probably happen again with PHP 7.3. If you need to use a specific version you should think about setting up your development environment inside a VM or Docker container.