Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
e8562272b0 | |||
1614f0fb2d | |||
5232d6a84f | |||
391602a811 | |||
b4760ac703 | |||
aabb0cded8 | |||
d3a6116a42 | |||
eb81dfc1be | |||
a6e04aa659 | |||
d8a4537efb | |||
28b4077a49 | |||
651430c7a9 | |||
3be9dee1c7 | |||
8ef37a71fb | |||
a30bf83269 | |||
1fdf800988 | |||
82cbad75d4 |
@ -54,9 +54,21 @@ Help us to maximize the effort we can spend fixing issues and adding new
|
||||
features, by not reporting duplicate issues.
|
||||
|
||||
|
||||
### Before Submitting a Pull Request (PR)
|
||||
|
||||
### Submitting a Pull Request (PR)
|
||||
Before you submit your pull request consider the following guidelines:
|
||||
Always Test everything and make sure its working:
|
||||
|
||||
- Pull the latest updates (or fork of you don’t have permission)
|
||||
- Before editing anything:
|
||||
- Test building the container (docker-compose build --no-cache container-name) build with no cache first.
|
||||
- Test running the container with some other containers in real app and see of everything is working fine.
|
||||
- Now edit the container (edit section by section and test rebuilding the container after every edited section)
|
||||
- Testing building the container (docker-compose build container-name) with no errors.
|
||||
- Test it in real App.
|
||||
|
||||
|
||||
### Submitting a PR
|
||||
Consider the following guidelines:
|
||||
|
||||
* Search [GitHub](https://github.com/LaraDock/laradock/pulls) for an open or closed Pull Request that relates to your submission. You don't want to duplicate effort.
|
||||
|
||||
@ -93,7 +105,7 @@ git push origin my-fix-branch -f
|
||||
|
||||
|
||||
|
||||
### After your pull request is merged
|
||||
### After your PR is merged
|
||||
|
||||
After your pull request is merged, you can safely delete your branch and pull the changes
|
||||
from the main (upstream) repository:
|
||||
|
256
README.md
256
README.md
@ -49,6 +49,9 @@ It's like Laravel Homestead but for Docker instead of Vagrant.
|
||||
- [Change the PHP-FPM Version](#Change-the-PHP-FPM-Version)
|
||||
- [Change the PHP-CLI Version](#Change-the-PHP-CLI-Version)
|
||||
- [Install xDebug](#Install-xDebug)
|
||||
- [Start/Stop xDebug](#Controll-xDebug)
|
||||
- [Production](#Production)
|
||||
- [Setup Laravel and Docker on Digital Ocean](#Digital-Ocean)
|
||||
- [Misc](#Misc)
|
||||
- [Use custom Domain](#Use-custom-Domain)
|
||||
- [Enable Global Composer Build Install](#Enable-Global-Composer-Build-Install)
|
||||
@ -833,6 +836,253 @@ It should be like this:
|
||||
2 - Re-build the containers `docker-compose build workspace php-fpm`
|
||||
|
||||
|
||||
For information on how to configure xDebug with your IDE and work it out, check this [Repository](https://github.com/LarryEitel/laravel-laradock-phpstorm).
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Controll-xDebug"></a>
|
||||
### Start/Stop xDebug:
|
||||
|
||||
By installing xDebug, you are enabling it to run on startup by default.
|
||||
|
||||
To controll the behavior of xDebug (in the `php-fpm` Container), you can run the following commands from the LaraDock root folder:
|
||||
|
||||
- Stop xDebug from running by default: `./xdebugPhpFpm stop`.
|
||||
- Start xDebug by default: `./xdebugPhpFpm start`.
|
||||
- See the status: `./xdebugPhpFpm status`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Production"></a>
|
||||
### [Production]
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Digital-Ocean"></a>
|
||||
### Setup Laravel and Docker on Digital Ocean
|
||||
|
||||
|
||||
#### Install Docker
|
||||
```
|
||||
Login Digital Ocean
|
||||
Add Droplet
|
||||
1 Click Install docker
|
||||
Choose Droplet
|
||||
reset ROOT password
|
||||
check email
|
||||
```
|
||||
|
||||
#### SSH to your Server
|
||||
|
||||
```
|
||||
ssh root@ipaddress
|
||||
```
|
||||
you will be prompt of that password.
|
||||
type the password you receive in your email
|
||||
|
||||
then it will ask to you to change a new password
|
||||
just change it to the custom root password you want
|
||||
|
||||
After SSH
|
||||
you can check that docker command is working by typing
|
||||
|
||||
```
|
||||
$root@midascode:~# docker
|
||||
```
|
||||
|
||||
#### Set Up Your Laravel Project
|
||||
|
||||
```
|
||||
$root@midascode:~# apt-get install git
|
||||
$root@midascode:~# git clone https://github.com/laravel/laravel
|
||||
$root@midascode:~# cd laravel
|
||||
$root@midascode:~/laravel# git checkout develop
|
||||
$root@midascode:~/laravel/ git submodule add https://github.com/LaraDock/laradock.git
|
||||
$root@midascode:~/laravel/ cd laradock
|
||||
```
|
||||
|
||||
#### Install docker-compose command
|
||||
|
||||
```
|
||||
$root@midascode:~/laravel/laradock# curl -L https://github.com/docker/compose/releases/download/1.8.0/run.sh > /usr/local/bin/docker-compose
|
||||
$root@midascode:~/chmod +x /usr/local/bin/docker-compose
|
||||
```
|
||||
|
||||
#### Create Your LaraDock Containers
|
||||
|
||||
```
|
||||
$root@midascode:~/laravel/laradock# docker-compose up -d nginx mysql
|
||||
```
|
||||
|
||||
#### Go to Your Workspace
|
||||
|
||||
```
|
||||
docker-compose exec workspace bash
|
||||
```
|
||||
|
||||
#### Install laravel Dependencies, Add .env , generate Key and give proper permission certain folder
|
||||
|
||||
```
|
||||
$ root@0e77851d27d3:/var/www/laravel# composer install
|
||||
$ root@0e77851d27d3:/var/www/laravel# cp .env.example .env
|
||||
$ root@0e77851d27d3:/var/www/laravel# php artisan key:generate
|
||||
$ root@0e77851d27d3:/var/www/laravel# exit
|
||||
$root@midascode:~/laravel/laradock# cd ..
|
||||
$root@midascode:~/laravel# sudo chmod -R 777 storage bootstrap/cache
|
||||
```
|
||||
|
||||
you can then view your laravel site at your ipaddress
|
||||
for example
|
||||
```
|
||||
192.168.1.1
|
||||
```
|
||||
|
||||
You will see there Laravel Default Welcome Page
|
||||
|
||||
but if you need to view on your custom domain name
|
||||
which you would.
|
||||
|
||||
#### Using Your Own Domain Name
|
||||
login to your DNS provider
|
||||
Godaddy, Namecheap what ever...
|
||||
And Point the Custom Domain Name Server to
|
||||
|
||||
```
|
||||
ns1.digitalocean.com
|
||||
ns2.digitalocean.com
|
||||
ns3.digitalocean.com
|
||||
```
|
||||
In Your Digital Ocean Account go to
|
||||
```
|
||||
https://cloud.digitalocean.com/networking/domains
|
||||
```
|
||||
add your domain name and choose the server ip you provision earlier
|
||||
|
||||
#### Serve Site With NGINX (HTTP ONLY)
|
||||
Go back to command line
|
||||
```
|
||||
$root@midascode:~/laravel/laradock# cd nginx
|
||||
$root@midascode:~/laravel/laradock/nginx# vim laravel.conf
|
||||
```
|
||||
remove default_server
|
||||
```
|
||||
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server ipv6only=on;
|
||||
|
||||
```
|
||||
and add server_name (your custom domain)
|
||||
```
|
||||
listen 80;
|
||||
listen [::]:80 ipv6only=on;
|
||||
server_name yourdomain.com;
|
||||
```
|
||||
|
||||
#### Rebuild Your Nginx
|
||||
```
|
||||
$root@midascode:~/laravel/laradock/nginx# docker-compose down
|
||||
$root@midascode:~/laravel/laradock/nginx# docker-compose build nginx
|
||||
```
|
||||
|
||||
#### Re Run Your Containers MYSQL and NGINX
|
||||
```
|
||||
$root@midascode:~/laravel/laradock/nginx# docker-compose up -d nginx mysql
|
||||
```
|
||||
|
||||
###### View Your Site with HTTP ONLY (http://yourdomain.com)
|
||||
|
||||
#### Run Site on SSL with Let's Encrypt Certificate
|
||||
|
||||
###### Note: You need to Use Caddy here Instead of Nginx
|
||||
|
||||
###### To go Caddy Folders and Edit CaddyFile
|
||||
|
||||
```
|
||||
$root@midascode:~/laravel/laradock# cd caddy
|
||||
$root@midascode:~/laravel/laradock/caddy# vim Caddyfile
|
||||
```
|
||||
|
||||
Remove 0.0.0.0:80
|
||||
|
||||
```
|
||||
0.0.0.0:80
|
||||
root /var/www/laravel/public
|
||||
```
|
||||
and replace with your https://yourdomain.com
|
||||
|
||||
```
|
||||
https://yourdomain.com
|
||||
root /var/www/laravel/public
|
||||
```
|
||||
uncomment tls
|
||||
|
||||
```
|
||||
#tls self-signed
|
||||
```
|
||||
and replace self-signed with your email address
|
||||
|
||||
```
|
||||
tls midascodebreaker@gmai.com
|
||||
```
|
||||
This is needed Prior to Creating Let's Encypt
|
||||
|
||||
#### Run Your Caddy Container without the -d flag and Generate SSL with Let's Encrypt
|
||||
|
||||
```
|
||||
$root@midascode:~/laravel/laradock/caddy# docker-compose up caddy
|
||||
```
|
||||
|
||||
you will be prompt here to enter your email... you may enter it or not
|
||||
```
|
||||
Attaching to laradock_mysql_1, laradock_caddy_1
|
||||
caddy_1 | Activating privacy features...
|
||||
caddy_1 | Your sites will be served over HTTPS automatically using Let's Encrypt.
|
||||
caddy_1 | By continuing, you agree to the Let's Encrypt Subscriber Agreement at:
|
||||
caddy_1 | https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf
|
||||
caddy_1 | Activating privacy features... done.
|
||||
caddy_1 | https://yourdomain.com
|
||||
caddy_1 | http://yourdomain.com
|
||||
```
|
||||
|
||||
After it finish Press Ctrl + C to exit ...
|
||||
|
||||
#### Stop All Containers and ReRun Caddy and Other Containers on Background
|
||||
|
||||
```
|
||||
$root@midascode:~/laravel/laradock/caddy# docker-compose down
|
||||
$root@midascode:~/laravel/laradock/caddy# docker-compose up -d mysql caddy
|
||||
```
|
||||
View your Site in the Browser Securely Using HTTPS (https://yourdomain.com)
|
||||
|
||||
##### Note that Certificate will be Automatically Renew By Caddy
|
||||
|
||||
>References:
|
||||
>
|
||||
- [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04)
|
||||
- [https://www.digitalocean.com/products/one-click-apps/docker/](https://www.digitalocean.com/products/one-click-apps/docker/)
|
||||
- [https://docs.docker.com/engine/installation/linux/ubuntulinux/](https://docs.docker.com/engine/installation/linux/ubuntulinux/)
|
||||
- [https://docs.docker.com/compose/install/](https://docs.docker.com/compose/install/)
|
||||
- [https://caddyserver.com/docs/automatic-https](https://caddyserver.com/docs/automatic-https)
|
||||
- [https://caddyserver.com/docs/tls](https://caddyserver.com/docs/tls)
|
||||
- [https://caddyserver.com/docs/caddyfile](https://caddyserver.com/docs/caddyfile)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<a name="Misc"></a>
|
||||
@ -960,6 +1210,8 @@ Make sure the ports for the services that you are trying to run (80, 3306, etc.)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<br>
|
||||
<a name="upgrading-laradock"></a>
|
||||
### Upgrading LaraDock
|
||||
@ -1006,6 +1258,10 @@ For special help with Docker and/or Laravel, you can schedule a live call with t
|
||||
|
||||
**Main Contributors:**
|
||||
|
||||
- [Larry Eitel (LarryEitel)](https://github.com/LarryEitel)
|
||||
- [Suteepat (tianissimo)](https://github.com/tianissimo)
|
||||
- [David (davidavz)](https://github.com/davidavz)
|
||||
- [Lialosiu](https://github.com/lialosiu)
|
||||
- [Eric Pfeiffer (computerfr33k)](https://github.com/computerfr33k)
|
||||
- [Orette](https://github.com/orette)
|
||||
- [Jack Fletcher (Kauhat)](https://github.com/Kauhat)
|
||||
|
@ -16,6 +16,11 @@ services:
|
||||
- PGID=1000
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
extra_hosts:
|
||||
# IMPORTANT: Replace with your Docker Host IP
|
||||
# this will be appended to /etc/hosts
|
||||
# Note that this IP can perhaps be better injected via .env
|
||||
- "dockerhost:10.0.75.1"
|
||||
tty: true
|
||||
|
||||
### PHP-FPM Container #######################################
|
||||
@ -26,6 +31,8 @@ services:
|
||||
args:
|
||||
- INSTALL_MONGO=false
|
||||
- INSTALL_XDEBUG=false
|
||||
- INSTALL_ZIP_ARCHIVE=false
|
||||
- INSTALL_MEMCACHED=false
|
||||
dockerfile: Dockerfile-70
|
||||
volumes_from:
|
||||
- volumes_source
|
||||
@ -33,6 +40,17 @@ services:
|
||||
- "9000"
|
||||
links:
|
||||
- workspace
|
||||
extra_hosts:
|
||||
# IMPORTANT: Replace with your Docker Host IP
|
||||
# this will be appended to /etc/hosts
|
||||
# Note that this IP can perhaps be better injected via .env
|
||||
- "dockerhost:10.0.75.1"
|
||||
environment:
|
||||
# IMPORTANT: You must have a Remote Interpreter entry matching this name
|
||||
# In settings, search for interpreter...
|
||||
# PHP > Languages & Frameworks > PHP > Interpreter > click on [...]
|
||||
# Need to have a Remote Interpreter named 'laravel'
|
||||
- PHP_IDE_CONFIG="serverName=laravel"
|
||||
|
||||
### Nginx Server Container ##################################
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
# https://hub.docker.com/r/laradock/php-fpm/tags/
|
||||
#
|
||||
|
||||
FROM laradock/php-fpm:5.6--1.1
|
||||
FROM laradock/php-fpm:5.6--1.2
|
||||
|
||||
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
|
||||
@ -35,6 +35,8 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
#
|
||||
# - INSTALL_XDEBUG= false
|
||||
# - INSTALL_MONGO= false
|
||||
# - INSTALL_ZIP_ARCHIVE= false
|
||||
# - INSTALL_MEMCACHED= false
|
||||
#
|
||||
|
||||
#####################################
|
||||
@ -44,10 +46,12 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
ARG INSTALL_XDEBUG=true
|
||||
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# Install the xdebug extention
|
||||
# Install the xdebug extension
|
||||
pecl install xdebug && \
|
||||
docker-php-ext-enable xdebug \
|
||||
;fi
|
||||
# ADD for REMOTE debugging
|
||||
COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini
|
||||
|
||||
#####################################
|
||||
# MongoDB:
|
||||
@ -56,10 +60,36 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
ARG INSTALL_MONGO=true
|
||||
ENV INSTALL_MONGO ${INSTALL_MONGO}
|
||||
RUN if [ ${INSTALL_MONGO} = true ]; then \
|
||||
# Install the mongodb extention
|
||||
pecl install mongodb \
|
||||
# Install the mongodb extension
|
||||
pecl install mongodb && \
|
||||
docker-php-ext-enable mongodb \
|
||||
;fi
|
||||
|
||||
#####################################
|
||||
# ZipArchive:
|
||||
#####################################
|
||||
|
||||
ARG INSTALL_ZIP_ARCHIVE=true
|
||||
ENV INSTALL_ZIP_ARCHIVE ${INSTALL_ZIP_ARCHIVE}
|
||||
RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
|
||||
# Install the zip extension
|
||||
pecl install zip && \
|
||||
docker-php-ext-enable zip \
|
||||
;fi
|
||||
|
||||
#####################################
|
||||
# PHP Memcached:
|
||||
#####################################
|
||||
|
||||
ARG INSTALL_MEMCACHED=true
|
||||
ENV INSTALL_MEMCACHED ${INSTALL_MEMCACHED}
|
||||
RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
|
||||
# Install the php memcached extension
|
||||
pecl install memcached && \
|
||||
docker-php-ext-enable memcached \
|
||||
;fi
|
||||
|
||||
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
# Final Touch
|
||||
|
@ -10,7 +10,7 @@
|
||||
# https://hub.docker.com/r/laradock/php-fpm/tags/
|
||||
#
|
||||
|
||||
FROM laradock/php-fpm:7.0--1.1
|
||||
FROM laradock/php-fpm:7.0--1.2
|
||||
|
||||
MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
|
||||
@ -35,6 +35,8 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
#
|
||||
# - INSTALL_XDEBUG= false
|
||||
# - INSTALL_MONGO= false
|
||||
# - INSTALL_ZIP_ARCHIVE= false
|
||||
# - INSTALL_MEMCACHED= false
|
||||
#
|
||||
|
||||
#####################################
|
||||
@ -44,10 +46,12 @@ MAINTAINER Mahmoud Zalt <mahmoud@zalt.me>
|
||||
ARG INSTALL_XDEBUG=true
|
||||
ENV INSTALL_XDEBUG ${INSTALL_XDEBUG}
|
||||
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
# Install the xdebug extention
|
||||
# Install the xdebug extension
|
||||
pecl install xdebug && \
|
||||
docker-php-ext-enable xdebug \
|
||||
;fi
|
||||
# ADD for REMOTE debugging
|
||||
COPY ./xdebug_settings_only.ini /usr/local/etc/php/conf.d/xdebug_settings_only.ini
|
||||
|
||||
#####################################
|
||||
# MongoDB:
|
||||
@ -56,10 +60,47 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
ARG INSTALL_MONGO=true
|
||||
ENV INSTALL_MONGO ${INSTALL_MONGO}
|
||||
RUN if [ ${INSTALL_MONGO} = true ]; then \
|
||||
# Install the mongodb extention
|
||||
pecl install mongodb \
|
||||
# Install the mongodb extension
|
||||
pecl install mongodb && \
|
||||
docker-php-ext-enable mongodb \
|
||||
;fi
|
||||
|
||||
#####################################
|
||||
# ZipArchive:
|
||||
#####################################
|
||||
|
||||
ARG INSTALL_ZIP_ARCHIVE=true
|
||||
ENV INSTALL_ZIP_ARCHIVE ${INSTALL_ZIP_ARCHIVE}
|
||||
RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
|
||||
# Install the zip extension
|
||||
pecl install zip && \
|
||||
docker-php-ext-enable zip \
|
||||
;fi
|
||||
|
||||
#####################################
|
||||
# PHP Memcached:
|
||||
#####################################
|
||||
|
||||
ARG INSTALL_MEMCACHED=true
|
||||
ENV INSTALL_MEMCACHED ${INSTALL_MEMCACHED}
|
||||
RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
|
||||
# Install the php memcached extension
|
||||
curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz" \
|
||||
&& mkdir -p memcached \
|
||||
&& tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \
|
||||
&& ( \
|
||||
cd memcached \
|
||||
&& phpize \
|
||||
&& ./configure \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
) \
|
||||
&& rm -r memcached \
|
||||
&& rm /tmp/memcached.tar.gz \
|
||||
&& docker-php-ext-enable memcached \
|
||||
;fi
|
||||
|
||||
|
||||
#
|
||||
#--------------------------------------------------------------------------
|
||||
# Final Touch
|
||||
|
@ -1,7 +1,6 @@
|
||||
date.timezone=UTC
|
||||
display_errors=Off
|
||||
log_errors=On
|
||||
extension=mongodb.so
|
||||
|
||||
; Maximum amount of memory a script may consume (128MB)
|
||||
; http://php.net/memory-limit
|
||||
|
21
php-fpm/xdebug_settings_only.ini
Normal file
21
php-fpm/xdebug_settings_only.ini
Normal file
@ -0,0 +1,21 @@
|
||||
; NOTE: The actual debug.so extention is NOT SET HERE but rather
|
||||
; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||
; For example:
|
||||
; zend_extension=xdebug.so
|
||||
|
||||
xdebug.remote_autostart=1
|
||||
xdebug.remote_enable=1
|
||||
xdebug.remote_handler=dbgp
|
||||
xdebug.remote_mode=req
|
||||
|
||||
; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port
|
||||
xdebug.remote_port=9000
|
||||
|
||||
; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1"
|
||||
; It will set 10.0.75.1 dockerhost
|
||||
; This will allow xdebug to connect to the host running PHPStorm.
|
||||
xdebug.remote_host=dockerhost
|
||||
|
||||
; PHPStorm needs this
|
||||
xdebug.idekey=PHPSTORM
|
||||
|
@ -52,6 +52,8 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \
|
||||
sed -i 's/^/;/g' /etc/php/7.0/cli/conf.d/20-xdebug.ini && \
|
||||
echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/laravel/vendor/bin/phpunit'" >> ~/.bashrc \
|
||||
;fi
|
||||
# ADD for REMOTE debugging
|
||||
COPY ./xdebug_settings_only.ini /etc/php/7.0/cli/conf.d/xdebug_settings_only.ini
|
||||
|
||||
#####################################
|
||||
# MongoDB:
|
||||
|
20
workspace/xdebug_settings_only.ini
Normal file
20
workspace/xdebug_settings_only.ini
Normal file
@ -0,0 +1,20 @@
|
||||
; NOTE: The actual debug.so extention is NOT SET HERE but rather
|
||||
; /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||
; For example:
|
||||
; zend_extension=xdebug.so
|
||||
|
||||
xdebug.remote_autostart=1
|
||||
xdebug.remote_enable=1
|
||||
xdebug.remote_handler=dbgp
|
||||
xdebug.remote_mode=req
|
||||
|
||||
; In PHPStorm: Settings > Languages & Frameworks > PHP > Debug > Xdebug > Debug port
|
||||
xdebug.remote_port=9000
|
||||
|
||||
; This is passed with by docker-compose / workspace / extra_hosts / - "dockerhost:10.0.75.1"
|
||||
; It will set 10.0.75.1 dockerhost
|
||||
; This will allow xdebug to connect to the host running PHPStorm.
|
||||
xdebug.remote_host=dockerhost
|
||||
|
||||
; PHPStorm needs this
|
||||
xdebug.idekey=PHPSTORM
|
91
xdebugPhpFpm
Normal file
91
xdebugPhpFpm
Normal file
@ -0,0 +1,91 @@
|
||||
#! /bin/bash
|
||||
|
||||
# NOTE: At the moment, this has only been confirmed to work PHP 7
|
||||
|
||||
|
||||
# Grab full name of php-fpm container
|
||||
PHP_FPM_CONTAINER=$(docker-compose ps | grep php-fpm | cut -d" " -f 1)
|
||||
|
||||
xdebug_status ()
|
||||
{
|
||||
echo 'xDebug status'
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
xdebug_start ()
|
||||
{
|
||||
echo 'Start xDebug'
|
||||
|
||||
# And uncomment line with xdebug extension, thus enabling it
|
||||
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \
|
||||
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
||||
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
xdebug_stop ()
|
||||
{
|
||||
echo 'Stop xDebug'
|
||||
|
||||
# Comment out xdebug extension line
|
||||
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
||||
|
||||
|
||||
# If running on Windows, need to prepend with winpty :(
|
||||
if [[ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]]; then
|
||||
# This is the equivalent of:
|
||||
# winpty docker exec -it laradock_php-fpm_1 bash -c 'bla bla bla'
|
||||
# Thanks to @michaelarnauts at https://github.com/docker/compose/issues/593
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
#docker-compose restart php-fpm
|
||||
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
|
||||
else
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
||||
# docker-compose restart php-fpm
|
||||
docker restart $PHP_FPM_CONTAINER
|
||||
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case $@ in
|
||||
stop|STOP)
|
||||
xdebug_stop
|
||||
;;
|
||||
start|START)
|
||||
xdebug_start
|
||||
;;
|
||||
status|STATUS)
|
||||
xdebug_status
|
||||
;;
|
||||
*)
|
||||
echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container."
|
||||
echo "xDebug must have already been installed."
|
||||
echo "Usage:"
|
||||
echo " ./xdebugPhpFpm stop|start|status"
|
||||
|
||||
esac
|
||||
|
||||
exit 1
|
Reference in New Issue
Block a user