Eine Sammlung von Docker-Containern mit unterschiedlichen PHP-Versionen, gleichen INI-Einstellungen und PHP-Extensions.
- Anleitung
- Purpose
- Funktionsweise
- PHP
- Datenbanken
- Login ins Container
- Contributing
- Copyright and license
Einfach in Projekt-Verzeichnis ablegen und folgendes in Console ausführen.
docker-compose up
Damit die Webapp auf eine echte Domäne läuft, sollte man jeweilige Container-IP (Apache2-Module) in statische DNS-Tabelle auf eigenem Rechner eintragen.
Fast immer muss ein PHP-Entwickler seine Anwendung unter unterschiedlichen PHP-Version laufen lassen und testen.
Das Aufsetzen von eine PHP-Umgebung kann teilweise Stunden in Anspruch nehmen. Die Sammlung startet gleichzeitig mehrere unterschiedliche PHP-Versionen und mappt sie automatisch auf lokale ports, sodass man ganz ohne Aufwand zwischen unterschiedlichen PHP-Versionen wechseln kann.
Die Automatisierung ist mit Docker Compose realisiert und bleibt somit nach Möglichkeit eine Standard-Lösung.
Alle PHP-Versionen sind offizielle PHP-Docker-Container.
Folgende Versionen sind als Apache2-Module installiert.
PHP | URL | IP |
---|---|---|
5.6.33 | localhost:8056 | 10.100.110.56 |
7.0.27 | localhost:8070 | 10.100.110.70 |
7.1.14 | localhost:8071 | 10.100.110.71 |
7.2.2 | localhost:8072 | 10.100.110.72 |
Liste aller installierten PHP-Extensions
- xdebug
- mcrypt
- gd
- curl
- iconv
- json
- libxml
- mbstring
- mysqlnd
- sqlite3
- pgsql
- mysql
- zip
- libxml
- soap
- mysqli
- IonCube
Beim Starten eines Containers wird automatisch 'tmp' - Verzeichnis im Projekt-Root angelegt. Das Verzeichnis muss unbedingt beschreibbar gemacht werden, weil PHP da die cachegrid.* und trace.* Dateien mit www-data speichert.
Xdebug ist im Standard bereits aktiviert und kann in 'Auto-Mode' ohne besondere IDE- und Server-Einstellungen genutzt werden. Gute Artikel dazu findet man [hier]
Datenbank-Server werden bereits mit eine datenbank installiert. Innerhalb von PHP-Container sind die Host-Namen bekannt. D.h. in eigene Applikation kann man als Host beispielsweise einfach 'mysql' verwenden.
Sollte man die Datenbank von IDE aus verwenden, so muss man die IP statt hostname nutzen.
Es werden keine Dumps automatisch eingespielt, die Datenbanken werden Leer erzeugt. Wenn man bereits eine SQL-Datei mit daten zur verfügung hat kann man sie Manuell Einspielen
Version | IP | Host | Port | User | Password | Database |
---|---|---|---|---|---|---|
MariaDB 10.2 (Like Mysql5.7) | 10.100.110.241 | mysql57 | 3306 | webapp | webapp | webapp |
Die Sicherung-SQL werden im Standard unter ./tmp - Verzeichnis im Root - Verzeichnis des Projektes abgelegt.
Dei Einstellung kann man anpassen in dem man DATABESES_BACKUP_PATH in Environment setzt. (.env-Datei)
docker exec phpenv_mysql57_1 dump
Die gesicherte Datenbanken kann man auch wiederherstellen.
docker exec phpenv_mysql57_1 restore demps/backup.sql
- Den Pfad muss relative zu Projekt-Root sein.
- Die Sym-Links werden nicht funktionieren.
docker exec -it <container_name> /bin/bash
Example: 'docker exec -it phpenv_php56_1 /bin/bash'
Aktualisieren von Inhaltsverzeichnis
doctoc README.md --notitle
Code released under the MIT License.