-
-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Community Discussion) Run multiply PHP versions at the same time #146
Comments
There is a huge benefit to allowing multiple PHP versions. Setting a specific project to a different version of PHP other than the default is extremely useful. I personally don't need to test against multiple versions...but I can certainly see how that might be useful for some developers. The main benefit for me is that I can make sure a specific project is running the same version of PHP that is on the production server. My own server runs the same version of PHP for virtually every project...but that's not always the case for some of my other clients. While most of my projects run either PHP 7.0 or 7.1, I do have some that are still running on PHP 5.6. The ability to run a project on PHP 5.6 without having to spin up a completely different container is incredibly helpful. Definitely would welcome this feature for sure! :D |
I think, this would be great. There are many projects running with a different php version, so this would make my work easier. I don't know, how you will make this possible, but maybe you can combine it with server version. |
Well, one way that might be possible is to setup handlers for each version installed. Pretty much the way most hosting providers do it. That way, if the default is set to PHP 7.0 but you want to use PHP 7.1 to test an application, all you would need to do is add the following to your .htaccess file:
Pretty straight-forward solution. However, I have no idea how this gets configured on a server. I'm assuming that you would install various versions and then just setup the handlers for each. |
Hi guys, 1.
|
Hi, |
@cytopia: I have a comment to the possibility to chose the php version over domain name (3. vHosts). |
This doesn't make any sense. If you have one project which should be server by php54 and one for php56, you will have to start both containers anyway and could also use both versions on both projects or? |
Yes sure, the containers have to be started. When a project runs with php7, it is not nesseary to test it with php5. In most cases a project is build for a specific php version. |
If it is easier for you to go this way
i think, this is somethink, we can live with ;) |
If this proposal does the job that projects can be tested against multiple php versions in general then I would say lets go with this implementation. All other improvements are very valid to follow, however getting it done in the most simple way at the beginning is prioritized, so we might find other flaws as early as possible as well. |
Great! Please, be free to tell me, if i can make some tests. |
Sounds really great, in case someone is upgrading a project from php version this new feature will give capability to test the entire functionally through php versions. In the current stack which i'm working, we have projects since php 5.4 to 7.1. Some of those are only cli applications, i suppose that its in mind that each php container will have a shell like root_bash.sh or we could pass some flags. @cytopia thanks for your work, devilbox it's a really amazing project ! |
Definitely can see the value in what is being discussed. For projects that need testing like this, this would indeed be the right approach. However, I still think it would be good to be able to use handlers though. The need for different versions of PHP for different projects is a different problem than testing a single project with multiple versions of PHP. If multiple versions of PHP are available, wouldn’t they all be accessible from different directories anyways? Handlers could be setup with each within the config of each container. If you had multiple projects and needed a different version of PHP that isn’t the default you could simply add a handler to your htaccess file and that would be it. Food for thought. |
@jeffwhitfield not quite sure If I fully understood you.
No, one project in one directory would be accessible with multiple php versions only differentiated by different domains.
Does this make more sense? Or did you mean something else? |
Let's say you have the following PHP CGI executables setup in the following directories:
Granted, the actual paths for each version might be different. Now, let's say the default is set for 7.2 but you have one project that needs to be set with 5.6 for some reason. You could then setup your Apache config like so:
Then, in the htaccess file for the project, you could simply add the hander:
Something like this would allow for simple overrides with any version of PHP. Basically just need to make sure that a default is set while allowing direct access to all other versions through the file system. |
@jeffwhitfield unfortunately PHP is not installed on the |
Ah, I see. Still new to Docker so there's bits that I probably don't get. Access to each container would definitely pose a problem. That said, if there was a way for the |
There is no need to physically access the PHP-FPM executables. It's done via an IP addresses/hostnam (hosts: |
@cytopia how is it registered on http site? is it registered in vhost or anywhere else? |
General setupThe
Httpd directives (Apache)
The important line is Httpd directives (Nginx)
The important line is New ideaSo basically instead of only having one PHP-FPM server with hostname
And there is not just one vhost, but as many vhost for one project as there are PHP-FPM container. Example:
... One of them could also be the default vhost such as for PHP-FPM 7.1:
Does this make any sense? |
Why not running php in different ports? Let's assume we use the php version as portnumber like 9056, 9070, 9071 , 9072 etc. I think it should be possible to say one global setting for all vhosts
and if someone needs a specific php version for a project, he could do it in the project vhost-gen
could this be possible? In this case you could let the php bin as php in the container. Please correct me, if i'm wrong, but in your case, it could be, that you have to name the php bin to php56, php71 etc. ? What do you think about this? P.S. I don't think, that a developer needs to test a project against different php versions. And if so, he could copy it in multiple folders and change the php version for that projects. |
@mavimedia when using different ports then all PHP versions must be on the same machine So from what you are recommending, the user could specify a different hostname (instead of different port) via vhost-gen to accomplish exactly this. |
Does this mean, that i can put a vhost-gen conf into the projects folder like the following (the global configuration is e.g. php71)
and it runs test.loc as php56 and additionally test.php56.loc, test.php70.loc, test.php71.loc etc.? |
Not at the moment, as there is always only one PHP-FPM container running (hostname: However, you will still have to start all PHP-FPM container that you want to use. |
Yes sure, that's clear, not now, but in future. Great! 👍 |
I'm trying to come away from using MAMP Pro and would find it much easier to transition if we could run a different php version per project like this. Would love to see it happen! |
Just to be clear here. From what I have already come up with, it won't be possible to run different PHP versions on a per project base, but to be able to run multiple PHP versions at the same time and to have each of the projects be served by all currently started php versions like so: (If you would start PHP 54, 55 and 56):
This would then be for all projects. |
I have another possible feature that might be nice to roll into this. I have 2 subdomains and they run different php.ini error warning levels. Would it be possible to run 2 php containers with a different php.ini file for them? Or is there an easier way of making php.ini changes based on apache/nginx virtualhost? Would that be 2 php-fpm pools? Thanks |
any news about this ? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Here is an example configuration that switches the PHP backend (upstream) based on the host name requested: https://github.com/Tuurlijk/docker-local/blob/master/.docker/web/default.conf Prefix is the project name in my case.
You can define as much php machines in your docker-compose.yml as you wish. Map them to the backends in your default.conf. This way of setup is nice because I can generate a wildcard SSL root cert for *.dev.local, *.xdebug.local and *.blackfire.local. I could add more domains like *.php71.local or *.hhvm.local. I can switch the backend by changing the domain name. I use a single docker-local project set for each new project. I usually work on a project that requires a single PHP version. So if I need ad different version, I rebuild the php containers with that version. This is however a different way from the way that devilbox is set up. A similar setup with prefixing the domain names is described above. But I need SSL support now, so I switched to using my docker-local setup that aims to be 'thin' and not to support all PHP and database versions pre-baked. |
Any easier way to get this setup? Or news on it being a feature added in? I'd love to have multiple sites with different PHP versions, under one Docker setup, rather than create multiple Docker setups. |
Thanks a lot for sharing theses snippets, it seems to work for me as i needed one of my website to run php5.6 while default version is 7.2 here is what i did to get a php5.6 shell (for composer and php cli compatibility):
|
I currently solve this issue by running multiple Devilbox instances in different IP addresses. |
I work in a system that has multiple subsystems that work on different PHP versions. So locally in my dev environment I have 3 subdomains to each one of these subsystems, and some of them call API funcions from the others, so currently I don't see how I could work this out with current devilbox... So there it is: another use case for this issue. |
That would work! Do you have a link on this? How to run multiple Devilbox instances in different IPs? |
this may be helpful, but i couldn't get it to work https://devilbox.discourse.group/t/multiple-versions-of-php/352/5 i may have to switch to laradock for now https://medium.com/@msirius/1-n-php-versions-and-projects-via-laradock-51938b337071 |
did we implemented this in 1.9 .. i am still trying to have projects which different php-version running at same time ! |
Not yet. For now you can follow the instructions above to get this feature working: #146 (comment) |
Some CMS don't support having a different domain name. So the |
The good news: I bodged this together locally (and manually). Anyways, this is currently in progress. Don't expect it this year though 😅 I might have a beta release ready by January. |
🎅🎄🎁 #942 |
FYI: @Alexandre-Fernandez @RaffyeMemon @Tuurlijk @adrienne @daanggc @dbrw @eortega @ghost @jeffwhitfield @johnwbaxter @lucasvignolireis @mavimedia @mohamed-ea @molteber @panigrc @science695 @shmocs Now available and released.
|
Community Discussion: multiple PHP versions
Hi everybody,
hope you enjoy the devilbox so far. I was thinking about a new feature, which might be a bit difficult to get it done, could however be something very useful for some of you:
Feature
Be able to run multiple PHP-FPM container at the same time
Benefits
Feedback
Before I am going to wrap my head around this, I wanted to check back with you guys, If it is actually any useful for you. So if this is of any use for you, let me know. Also if you have something similar in mind, just give me a comment here.
The text was updated successfully, but these errors were encountered: