Memcached for PHP 5.3 - php

I have looked everywhere for some clues on how to run the Memcached extension in my WAMP windows development environment (thats right, the memcached with an D in the end, not memcache).
I already use memcache (without the D), but it would be handy to take part of memcached's more extended multiple-server features.
How can I get this up and running?
Thanks

memcached uses libmamcached, which -- according to the PHP Windows build team -- doesn't compile on windows. Therefore the extension can't be built either.

Related

Is it possible to install memcacheD (with a D) for php on windows so that I can use it with xampp?

I already know that it is possible to install memcache (not memcached, that is another program!) for PHP on windows to be used with xampp.
I am wondering if there are any solutions for a working memcached (mind the d at the end :))?
I have put several hours into this already, I have found out that you can install it with ease on linux.
And that HHVM has this preinstalled, you just need some dependencies such as libmemcached and so on.
But I develop on windows using xampp, so I would like to be able to use the memcached class from php on windows, too. I don't think swapping the database and using redis is an option for me because it is slow.
Even thoough phpredis is a fast C extension, but it is incompatible with HHVM.
There are countless tutorials on the web marketing how to install "memcache" on windows, but they are all just for the php memcache class (no d), not memcached.
The dll file you need to copy to D:\xampp\php\ext only exists for memcache and not memcached.
Can I develop with HHVM and memcached on windows using the php memcached class instead of the memcache one?

How to use MemcacheD instead of Memcache on PHP and Windows Xampp?

Sorry but, I've searched this question and I found a lot of old answers.
Now, I can use memcacheD instead of memcache on windows?
http://www.codeforest.net/how-to-install-memcached-on-windows-machine
I installed php_memcache.dll extension and memcached.exe server service, but this is memcache! (without "D"). in fact if I use
new Memcache;
it works fine, instead if I use:
new Memcached;
or
new MemcacheD;
doesn't work.
I would like to implement memcacheD (with "D" !!!) because I will use it on amazon Elasticache together Zend Framework Cache/Session and it works with memcacheD. Now I'm working in Xampp (windows) ambient. How to work with memcacheD in windows? I need another libraries?
Thanks a lot, I'm fighting for using this -.-
I'm using Win7 (64bit).
My DDL file is available here (php 5.6 - 5.6 Thread Safe (TS) x86):
http://pecl.php.net/package/memcache/3.0.8/windows
My memcached server version is 1.4.4 32bit version, available here
http://blog.elijaa.org/index.php?post/2010/10/15/Memcached-for-Windows&page
You're confusing the two. memcached is the Memcache daemon program (the d stands for daemon). This has to be running for you to use Memcache. This is NOT what you use inside PHP. You launch this inside Windows like you would any other program.
The Memcache PECL library is how you can connect to your running daemon. You use new Memcache inside PHP to create an object that connects to the daemon and then interacts with it.
I've been struggling with this myself, and it seems that the only solution is to compile the DLL yourself from source, because there are no official Windows binaries for the PHP memcached extension available. This is a related question: Does memcached.dll exist?

What to use instead of apc user data cache in php 5.5?

PHP 5.5 includes zend opcache by default, which basically means that almost nobody will use APC.
But what to use instead of the user data cache part of APC (apc_store & apc_fetch & similar)?
One use case where I really like to use APC user data cache are "versions" of static assets (javascript, css..). Whenever I reference static file, I add hash of its content into the url (e.g. <script src=/script.js> will became <script src=/script.js?v=hash>), so that browser always uses current version and can cache it permanently.
I can imagine using redis or memcache to store the hashes of static files, but it seems silly to ask another process over network or socket just to get a hash of file content. APC user data cache (which is in shared memory and accessing it is almost as fast as accesing php variable) seems just the right thing to use for such data.
So the question is: what to use in php 5.5 to cache small bits of data instead of APC?
Starting from PHP 5.5 the APC user data storage is packaged separately as PECL APCu.
Source code: http://pecl.php.net/package/APCu
MacOS homebrew package is php55-apcu (brew install php55-apcu)
Debian/ubuntu is called php5-apcu (apt-get install php5-apcu)
Fedora/RedHat is called php-pecl-apcu (yum install php-pecl-apcu)
Windows - use precompiled APCu dll - follow instructions provided in the answer below.
This allows you to use all user cache functions, such as apc_store(). It will also return true for extension_loaded('apc') - this means that all libraries depending on APC will work similarly to PHP 5.4.
I recently dealt with this question after upgrading from php 5.3 to php 5.5 beta 2.
I looked at Memcache and Redis. Depending upon whom you ask, the performance between the two is approximately the same. Some claim that Redis is marginally faster. However, Redis has a lot more features than Memcahe so I decided to go with Redis.
For a PHP client, I chose Phpredis over Predis. Phpredis is a C extension whereas Predis a pure PHP implementation. Thus, Phpredis is generally faster.
I'm primarily using Redis to cache and retrieve serialized objects. I started the project I'm currently developing in PHP 5.3 with APC. I'm continuing to develop the project with php 5.5 and Redis. While I don't have benchmark statistics, I can tell you that the app "feels" faster. This is likely due to performance enhancements in php 5.5 as opposed to APC user cache verses Redis. Either way, I'm happy with my choice.
I hope that helps. Good luck and happy hacking :-)
Nothing more to say. You got the correct answer already. I guess I can provide you with a link to tutorial to how to download and install APCu on XAMPP on Windows for php 5.5 and 5.6:
Link do download APCu for php build from 5.3 and higher:
download APCu different versions
Installation tutorial: installation instructions (The newest version should be on the very bottom of the file list - use this one)
Also bear in mind that you will have two to choose from few options like 64 or 84 version as well as nts or ts and vc9 or vc11 (it can be different in your case) and of course the correct PHP version (in my case that would be PHP 5.6 for my xampp).
EXAMPLE:
if you want to pick right you have to run phpinfo() first and check for those parameters:
Zend Extension Build and Architecture
In my case that would be:
[Zend Extension Build:] API220131226,TS,VC11
[Architecture:] x86
That mean that in my case I would have to choose ACLu wchich contain
in file name those parameters 5.6, TS, VC11, 86
file name to download: php_apcu-4.0.7-5.6-ts-vc11-x86.zip
Hope that clear things up for you.
Some aditional explanations on different PHP builds:
difference ts vs nts:
TS refers to multithread capable builds. NTS refers to single thread only builds. Use case for TS binaries involves interaction with a multithreaded SAPI and PHP loaded as a module into a web server. For NTS binaries the widespread use case is interaction with a web server through the FastCGI protocol, utilizing no multithreading (but also for example CLI).
difference vc9 vs vc11 vs vc14:
More recent versions of PHP are built with VC9, VC11 or VC14 (Visual Studio 2008, 2012 or 2015 compiler respectively) and include improvements in performance and stability.
The VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed
The VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012 x86 or x64 installed
The VC14 builds require to have the Visual C++ Redistributable for Visual Studio 2015 x86 or x64 installed
difference 86 vs 64:
The x64 builds of PHP for Windows should be considered experimental, and do not yet provide 64-bit integer or large file support.
Take a look at the XCache opcode cacher, from the authors of lighttpd. It supports both php 5.5 and user data cache: http://xcache.lighttpd.net/wiki/XcacheApi
I didn't try it my self (still using APC and php 5.4).

How to make PHP5 emulate older version?

I'm writing a web app on my system using PHP5, but the app needs to be compatible with PHP4. Is there any way to emulate PHP4, or at least issue warnings?
Thanks.
As a general rule, if you avoid functions and arguments that were added in PHP5 (as shown in the documentation for each function), then it should work just fine with PHP4. PHP is good at backwards-compatibility like that.
There is no way to emulate PHP4 that I'm aware of. You need to run your code in a real PHP4 environment. Here's what I'd suggest:
Grab an old distro which includes a PHP4 package. Apparently, Ubuntu Dapper (6.06) does.
Install it into a VM (VirtualBox or VMWare) on your box.
Create a shared directory for the VM which points to your app dir on the real box.
Inside your VM, create a symlink from the webroot to the mount point of the shared directory.
Once that is done, you can more or less forget about the VM. All you need to do is keep it running. Change your code in your app dir as before. You can run it from your browser with the IP of the virtual machine.
(Perhaps you could even install an old version of XDebug in the VM and do proper remote debugging from within your IDE. But I don't know if XDebug is compatible with PHP4 at all.)
No, there isn't. You will have to install PHP 4 on the machine to provide the runtime environment. Or, even better, convince the client that PHP 4 in 2012 is... outdated.

Does memcached.dll exist?

Does the memcached (not memcache) extension exist for Windows? I have looked through old answers and haven't found anything.
It does not exist and is very unlikely to exist any time soon. The main problem is not the extension itself but the libmemcached library. This library is barely portable to anything but a linux system, so windows support won't happen anytime soon (using Visual C).
You can get the php extension "memcache" to use memcached with php on windows here http://downloads.php.net/pierre/
Memcached is the server daemon and you can get it for windows here http://splinedancer.com/memcached-win32/
The php extension also called memcached requires libmemcached which doesn't seem well supported on windows which is probably why that extension doesn't exist for windows.

Categories