A Python virtualenv is a standalone Python environment, where you can install only the packages that you need for your project.
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
Docker is great at packaging OS-level dependencies together with your application. Virtualenv however, is great at making sure that you have a perfectly controlled environment for your Python application. Sure, you could simply install your project's dependencies inside of your Docker image without using virtualenv.
conda is both a package and environment manager and is language agnostic . Whereas venv creates isolated environments for Python development only, conda can create isolated environments for any language (in theory).
Assuming that you are using mod_php, there is no way to load multiple different versions into the same Apache instance. You can run multiple different versions if you're running PHP as CGI or FastCGI, but this will itself introduce some differences in behavior from mod_php.
Another alternative to virtual machines is docker.
As loading different versions of php within apache with mod_php seems not to be posible, the easiest way of mimicking deployment and development setups will be with a virtualmachine, which you stated you would like to avoid.
One way of making the burden of vm's for developers a bit easier is to use something like vagrant. With two files (the vagrant file, and the chef/puppet file) you can "version" your vm's, easily create them and destroy them for each project and when needed.
virtPHP is a tool for creating and managing multiple isolated PHP environments on a single machine. It's like Python's virtualenv, but for PHP. (README)
https://github.com/virtphp/virtphp
You might be interested in this: https://github.com/phpenv/phpenv
(Haven't coded php in years, so this might be outdated)
As far as I remember you just had to point to another directory where your libraries reside (include PATH), using something like:
include_path = .:/usr/local/lib/php:./include (this goes in php.ini, default libararies)
and in your php files:
ini_set("include_path", ".:../:./include:../include");
PHP never really had a robust packaging system and library repository like perl/python/ruby has, PEAR was trying to move in that direction but it is very closed in comparison and was hard to configure in multiproject environments.
Phark is trying to build a brew/bundler port for php, https://github.com/lox/phark, although it's not deployment ready.
As of now, there is no out of the box solution to this problem. The only solution which comes close is Vagrant and puPHPet.com as discussed here: https://drupal.org/node/2055947 Why can't we have an environment like python's virtualenv or ruby's rbenv? It makes up a nice open source project. Multiple instances of PHP can be handy if we want to test out some libraries in sandboxes rather than globally. We can install dependencies for different projects using a package manager like Composer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With