I have a function in php that needs to connect to ftp using ftp_ssl_connect. Iam using windows seven and as per the answers from google I need to rebuild the php to include the ssl functions. Now my question if is there a way to enable ssl on Windows without rebuilding php? Or is there a donwloadable version where ssl already included for windows?
thanks
From PHP doc:
Note: Why this function may not exist
ftp_ssl_connect() is only available if both the ftp module and the
OpenSSL support is built statically into php, this means that on
Windows this function will be undefined in the official PHP builds. To
make this function available on Windows you must compile your own PHP
binaries.
Emphasis mine.
However, I've downloaded PHP binary for windows from official php.net and I noticed there's a specific DLL (ext/php_openssl.dll) for openssl. It means maybe it's not necessary rebuild PHP in order to get openssl working. Just remember add an entry for the dll in php.ini file.
It should be something like this:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"
...
extension=php_openssl.dll
NOTE
I haven't tested the above case.
As of PHP 7.0, the core FTP extension on Windows is by default built with OpenSSL support. In the earlier PHP versions, while SSL support is possible, it is not provided with the standard builds for various reasons. The only solution for PHP 5 is to make a custom build of PHP, while the standard PHP 7.0 builds on windows.php.net provide the ftp_ssl_connect() function.
Thanks.
Related
I'm trying to use SQL Server with PHP but I don't know how to install this feature. I have enabled extension=php_mssql.dll in my php.ini file but after restarting apache I got a error message saying that don't found the DLL file.
After much attempts I reinstalled XAMPP 1.81, and I'm starting now from zero.
Thanks for any help.
Edit MSSQL has been discontinued as of 5.3
I believe the correct driver is php_sqlsrv.dll.
http://www.php.net/manual/en/sqlsrv.installation.php
Here are the available functions: http://www.php.net/manual/en/ref.sqlsrv.php
I am using the mime_content_type() function for file upload, it works fine on localhost however I'm encountering the following error on my live server:
Fatal error: Call to undefined function mime_content_type()
Update:
mime_content_type() is no longer deprecated, php7 has support for this function now.
Earlier version of my answer:
mime_content_type() is deprecated, probably because [fileinfo][1]
can give you those information about the file and more.
You can use finfo() like shown below,
function _mime_content_type($filename) {
$result = new finfo();
if (is_resource($result) === true) {
return $result->file($filename, FILEINFO_MIME_TYPE);
}
return false;
}
Ref: https://stackoverflow.com/a/1263977/1161412
[1]: http://php.net/manual/en/class.finfo.php
You must have the mime_magic extension on. Check your php.ini and look in phpinfo(). By the way this function has been deprecated as the PECL extension Fileinfo provides the same functionality (and more) in a much cleaner way.
Windows users must include the bundled php_fileinfo.dll DLL file in
php.ini to enable this extension.
The libmagic library is bundled with PHP, but includes PHP specific
changes. A patch against libmagic named libmagic.patch is maintained
and may be found within the PHP fileinfo extensions source.
Read more
PHP 8
Edit your php.ini file and uncomment extension=fileinfo.
Restart your HTTP server (e.g. Apache).
echo mime_content_type($path_absolute.$file);//Outputs: application/pdf
PHP 7
Edit your php.ini file and uncomment extension=php_fileinfo.dll.
Restart your HTTP server (e.g. Apache).
echo mime_content_type($path_absolute.$file);//Outputs: application/pdf
If you are on shared hosting, chances are that the fileinfo PHP extension is either not enabled or installed.
In the case where it's not enabled, navigate to the Software section of CPanel (consult documentation of your control panel if you're not using CPanel) and click Select PHP Version (or something related to that) and enable the extension by checking its box and saving your action.
If it's not installed, the extension won't be part of the PHP extensions at cPanel > Software > Select PHP Version > Extensions, edit your php.ini file and uncomment extension=php_fileinfo.dll if you're on Windows. Consult your hosting provider's docs if any of these don't work.
I changed my php version from 7.1 to 5.6 it works for me
Likely missing \php\extras\magic.mime file.
I installed memcached by reading this article on Windows7 but unfortunately i keep getting error Fatal error: Class 'Memcache' not found in D:\xampp\htdocs\test\memcache\test.php on line 2
Line 2: $memcache = new Memcache;
Win7 64, Xampp Installed. I am using net start "memcached Server" on command line but it says service is already started.
Some other info which may help;
On php.ini file:
extension=php_memcache.dll
[Memcache]
memcache.allow_failover = 1
memcache.max_failover_attempts=20
memcache.chunk_size =8192
memcache.default_port = 11211
Update: phpinfo(); show dll is not loaded. Tried several different dll files so far, didn't work. Also dll is located correct. It is in the right folder as it seems.
(P.S. Some may think there are possible duplicates about this topic but there is only 1 person who followed the same instructions and had same error in SO. That question has no answer or solution since march.)
I found the working dll files for PHP 5.4.4
I don't knowhow stable they are but they work for sure. Credits goes to this link.
http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip
http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip
It is the 2.2.5.0 version, I noticed after compiling it (for PHP
5.4.4).
Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP.
Mirror links:
http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip
http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip
Add this to your php.ini:
extension="php_memcache.dll"
and restart apache
Memcached just uses standard text interface so its possible to use it without the module.
// connect
$link = fsockopen($host,$port,$errno,$errst,$timeout);
// set
$data = sprintf("set %s 0 %s %s\r\n%s\r\n",
$key,$expire,strlen($value),$value);
fwrite($link,$data);
$result = trim(fgets($link));
if ($result == 'ERROR') {
// :(
}
// get
$data = sprintf("get %s\r\n",$key);
fwrite($link,$data);
$line = rtrim(fgets($link));
if ($line != 'END') {
return rtrim(fgets($link));
}
So i have looked now for a solution. Here you can download some compiled extensions.
http://downloads.php.net/pierre/
The problem is that at the moment there is no memcache extension for PHP 5.4. this is the problem why your extension could not be loaded. You need the extension for the correct PHP version and Tead Safe for Windows.
So the easiest way is to work with PHP 5.3 if you need the extension.
The newest version of memcache is the version 3.0.6 but its a beta version you can see it here.
http://pecl.php.net/package/memcache
You could try to take the beta version and compile it with your windows system. But its a lot of work.
Also problem can be in loading another version of php module somewhere in apache .conf files. Need to check duplicated "LoadModule php..." directives and if that module compiled to correct version of apache.
It seems sound simply, but not when you have several versions of php on one machine :)
Or it can be SElinux problem too.
xampp windows version is 32bit ,you must be use 32bit memcache.dll
I hole that would be useful for you!
I installed the latest XAMPP package which includes PHP 5.3.0. I am trying to enable Xdebug, but it just won't work.
Here's what I changed in the php.ini shipped with XAMPP:
; uncommented
zend_extension = "X:\xampp\php\ext\php_xdebug.dll"
; added the following lines:
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Apache starts fine, but when I open http://localhost/ in my browser, I get the following error:
If I click the Close the program button, the error message will reappear in a second as if it was in an infinite loop. I'd greatly appreciate any help in getting this to work.
I am running a fresh install of Windows 7 Ultimate 64-bit.
EDIT:
From the result of phpinfo():
Zend Extension Build API220090626,TS,VC6
PHP Extension Build API20090626,TS,VC6
Debug Build no
Thread Safety enabled
It's possible you have the wrong version of Xdebug. I would take a look at phpinfo() and compare the information there to the different versions of the Xdebug dll.
Specifically, you want to see if "Thread Safety" is enabled, and you need to know whether you're running a VC6-compiled PHP or a VC9 (if you're using Apache, it's almost guaranteed that you want the VC6).
Have you tried custom installation wizard of XDEBUG, it analyses your php installation and provides exact steps you need to follow
The Windows binaries generally work for every mini release for the mentioned PHP version, although the extension is built against the most current PHP version at that time. The VCx marker tells with which compiler the extension was built, and Non-thread-safe whether ZTS was disabled. Those qualifiers need to match the PHP version you're using. If you don't know which one you need, please refer to the custom installation instructions.
http://xdebug.org/wizard.php
Just paste your phpinfo out put in the text box and you will get exact xdebug dll you would need for your php
frank-ly, I also had 2 REALLY bad days, and I don't now what finally fixed it,
so here's my collection of Do's and pitfalls:
; this is the thread safe version,
; the absence of _nts_ in the dll name 'shows' this
; do not use _ts, your library won't get registered and won't show in phpInfo()
zend_extension = "D:/wamp/bin/php/php5.3.8/zend_ext/php_xdebug-2.1.2-5.3-vc9-x86_64.dll"
check your php.ini, check phpinfo() if all values (arrive)
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
; if you have multiple virtual hosts ( like 'local.fooclient' )
; maybe using the IP is safer (for any same-machine-debugging)
xdebug.remote_host=127.0.0.1
; maybe a -much- lower port helped, 84 was free. use netstat to figure out.
xdebug.remote_port=84
; idekey! also see note below
xdebug.idekey=netbeans-xdebug
More Pitfalls:
I have seen a typo of xdebug.remote_handle (without r) several times on the web. beware.
A note on the idekey: The above idekey did show in phpinfo() as master value, BUT
was overridden with a 'local value' like MYMACHINENAME$. ==> Setting a global env var (in computer properties) named DBGP_IDEKEY and rebooting (or maybe just logging out) to (also) netbeans-xdebug helps! Again: re-check in phpInfo() it took effect.
Of course adjust netbeans-menu:options->php tab->debugging section to this port and session id.
Here is a script, to check (by php means) if that port you intend to talk to is open. (further below also in the comments, for those to lazy too type from the image)
For your browser to connect, don't start to forget (amidst frustration) to always attach the debug-starting get-argument:
http://localhost/myTest.php?XDEBUG_SESSION_START=netbeans-xdebug
On the port frontier, also this tool might help.
Quadruplecheck you are keeping VC6 and VC9 compiled versions of everything apart.
Running your whatever/path/php.exe myTest.php from the command line (once the above settings are done) might also reveal additional errors (it did, while I was tinkering with an incorrect dll).
I can recommend http://www.wampserver.com
(for personal reasons it fits me better than the popular xampp package...)
Yes, there is a known problem - is almost impossible to get Xdebug working with latest Xampp and 64-bit Vista/Win 7.
There is a bug reported with many users complaining about it.
The solution seems to be latest beta version on Xampp. It includes version 2.0.6 (dev) of xdebug and it is working just fine.
I tested it on 64-bit Vista for approx 10 days and not encountered any problem yet.
When xdebug is installed not with XAMPP, just with PHP (32bit, TS, VC6, in C:\Program Files (x86)\PHP) and Apache (32bit) on Windows 7 (64bit), in php.ini you need to specify the full path to x86 folder of Program Files like.
zend_extension="C:\Program Files (x86)\PHP\ext\php_xdebug-2.1.1-5.3-vc6.dll"
and NOT
zend_extension="C:\Program Files\PHP\ext\php_xdebug-2.1.1-5.3-vc6.dll"
This was my mistake, when changed to x86 folder, xdebug started to work perfectly. Hope this help you, too.
Like others have said, you need to match your xdebug version with your php version.
You've already matched up PHP version number, thread safety, and compiler.
If you haven't already figured it out (this is an old thread), what you're missing is the INI configuration. If you are loading a module that's thread safe, you need to use the following line:
zend_extension="C:\Path\To\The\Extension.dll"
If the module is not thread safe, then you use the INI directive you've been trying to use.
This only applies to zend_extension's and not regular extensions.
I am running Apache 2.2.13 and PHP 5.2.12. Just installed PHP 5.2.12 manually (to have access to all extensions) and enabled OpenSSL. phpinfo() indicates OpenSSL is enabled and running OpenSSL 0.9.8k 25 Mar 2009.
I'm getting this error: PHP Fatal error: Call to undefined function ftp_ssl_connect().
I've seen where the PHP manual suggests 'ftp_ssl_connect() is only available if both the ftp module and the OpenSSL support is built statically into php' and further states that 'you must compile your own PHP binaries' to make it work with Windows.
I have the suspicion that phpinfo() only indicates OpenSSL as being 'enabled' because I have uncommented the line 'extension=php_openssl.dll' and have the correct dlls in the correct folders and the correct path in the environment variables. And perhaps a static build into PHP must be accomplished regardless of what phpinfo() indicates.
I believe the objective of distribution (as described above) is for dynamic extensions, but recompiling (for OpenSSL) is to encode a static extension.
ftp extension is working fine (built into PHP 5.2). I test this with the following code:
$conn_id = ftp_connect($url);
$login_result = ftp_login($conn_id, $username, $password);
ftp_close($conn_id);
Note that to check ssl, I only change ftp_connect to ftp_ssl_connect. When reaching this line, I get the PHP error above in my Apache error log file.
As the documentation states (quoting what you already quoted) :
Note: Why this function may not exist
ftp_ssl_connect() is only
available if both the ftp module and
the OpenSSL support is built
statically into php, this means that
on Windows this function will be
undefined in the official PHP builds.
To make this function available
on Windows you must compile your own
PHP binaries.
You say you installed PHP "manually" ; but this probably still means you used an "official" build from php.net -- which means you have not compiled your own PHP binaries... So, that function is not available.
There is no magic : it seems you'll have to re-compile PHP, using the right configuration options at compile-time, if you want to be able to use that function...
Here's some documentation about that : Build your own PHP on Windows -- but... good luck... i've never heard it was "simple" to compile PHP on windows, actually (it's not that hard on Linux, but Linux is maybe a bit more well suited when it comes to compilation)
A couple of other solutions :
switching to Linux for your developments (even if it's only using a Virtual Machine) -- but you might still have to recompile PHP to get that (might not be enabled by default)
just not using that function ; after all, do you know if your hosting service will provide you with it ? (If you can't use it on your production server, no need to use on your development/testing machine)