├── .gitignore
├── LICENSE
├── README.md
├── bin
└── console
├── composer.json
├── composer.lock
├── docker
├── .gitignore
├── build
│ ├── nginx
│ │ ├── Dockerfile
│ │ ├── nginx.conf
│ │ └── sites-enabled
│ │ │ └── ws-chat.conf
│ ├── php
│ │ ├── Dockerfile
│ │ ├── docker-php-entrypoint
│ │ ├── docker-php-ext-configure
│ │ ├── docker-php-ext-enable
│ │ ├── docker-php-ext-install
│ │ ├── docker-php-source
│ │ └── systemd
│ │ │ └── app.target
│ └── workspace
│ │ └── Dockerfile
├── docker-compose.yml
├── env-example
└── shortcuts
│ ├── exec_db
│ ├── exec_php
│ └── exec_workspace
├── mix-manifest.json
├── output
├── alias
│ ├── Client.php
│ ├── Http
│ │ ├── Client.php
│ │ ├── Request.php
│ │ ├── Response.php
│ │ └── Server.php
│ ├── Http2
│ │ ├── Client.php
│ │ └── Request.php
│ ├── Mysql.php
│ ├── Mysql
│ │ ├── Exception.php
│ │ └── Statement.php
│ ├── Redis.php
│ ├── Redis
│ │ └── Server.php
│ ├── Server.php
│ ├── Server
│ │ └── Port.php
│ ├── Socket.php
│ ├── Socket
│ │ └── Exception.php
│ └── Websocket
│ │ ├── Frame.php
│ │ └── Server.php
├── classes.php
├── constants.php
├── functions.php
└── namespace
│ ├── Async.php
│ ├── Atomic.php
│ ├── Atomic
│ └── Long.php
│ ├── Buffer.php
│ ├── Channel.php
│ ├── Client.php
│ ├── Connection
│ └── Iterator.php
│ ├── Coro
│ └── Channel.php
│ ├── Coroutine.php
│ ├── Coroutine
│ ├── Channel.php
│ ├── Client.php
│ ├── Http
│ │ └── Client.php
│ ├── Http2
│ │ ├── Client.php
│ │ └── Request.php
│ ├── MySQL.php
│ ├── MySQL
│ │ ├── Exception.php
│ │ └── Statement.php
│ ├── Redis.php
│ ├── Socket.php
│ └── Socket
│ │ └── Exception.php
│ ├── Event.php
│ ├── Exception.php
│ ├── Http
│ ├── Client.php
│ ├── Request.php
│ ├── Response.php
│ └── Server.php
│ ├── Http2
│ ├── Client.php
│ ├── Request.php
│ └── Response.php
│ ├── Lock.php
│ ├── Memory
│ ├── Pool.php
│ └── Pool
│ │ └── Slice.php
│ ├── Mmap.php
│ ├── MsgQueue.php
│ ├── MySQL.php
│ ├── MySQL
│ └── Exception.php
│ ├── Mysql.php
│ ├── Mysql
│ ├── Exception.php
│ └── Statement.php
│ ├── Process.php
│ ├── Process
│ └── Pool.php
│ ├── Redis.php
│ ├── Redis
│ └── Server.php
│ ├── RingQueue.php
│ ├── Serialize.php
│ ├── Server.php
│ ├── Server
│ └── Port.php
│ ├── Socket.php
│ ├── Socket
│ └── Exception.php
│ ├── Table.php
│ ├── Table
│ └── Row.php
│ ├── Timer.php
│ ├── WebSocket
│ ├── Frame.php
│ └── Server.php
│ └── Websocket
│ ├── Frame.php
│ └── Server.php
├── package-lock.json
├── package.json
├── psalm.xml
├── public
└── index.php
├── resources
├── css
│ └── app.scss
└── js
│ ├── app.js
│ ├── components
│ ├── Chatbox.vue
│ ├── MessagesView.vue
│ └── UsersTable.vue
│ └── services
│ └── ChatClientRequestBuilder.js
├── src
├── Commands
│ ├── CreateDatabaseCommand.php
│ ├── CreateMigrationCommand.php
│ ├── MigrateCommand.php
│ └── StartAppCommand.php
├── Config.php.sample
├── Helper
│ ├── DatabaseHelper.php
│ ├── PurifierHelper.php
│ ├── RequestLimiter.php
│ └── SpamFilter.php
├── Message.php
├── Migration
│ └── Version20190723174016730.php
├── MigrationsComponent
│ ├── Internal
│ │ ├── DBCurrentSchemaVersionProvider.php
│ │ ├── MigrationExecutor.php
│ │ ├── MigrationsLoader.php
│ │ ├── MigratorException.php
│ │ ├── MigratorResultText.php
│ │ └── SchemaUpdater.php
│ ├── Migration.php
│ └── Migrator.php
├── Repository
│ ├── MessagesRepository.php
│ └── UsersRepository.php
├── Request
│ ├── LoginRequest.php
│ └── MessageRequest.php
├── Response
│ ├── ErrorJsonReponse.php
│ ├── JsonReponse.php
│ ├── LoginJsonReponse.php
│ ├── MessagesJsonReponse.php
│ └── UsersJsonReponse.php
├── User.php
└── WebsocketServer.php
└── webpack.mix.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /vendor
3 | app/DBConfig.php
4 | /node_modules
5 | /public/css
6 | /public/js
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Evgeniy Romashkan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
This repository is deprecated and will not be supported by a bunch of reasons, including changing my views on solving such problems, poor code quality and the availability of documentation for the Swoole framework
2 |
3 |
4 |
5 | Online chat on websocket using Swoole (https://www.swoole.co.uk/)
6 |
7 | For using on local machine:
8 | 1. Make sure you have installed Docker and Docker-compose
9 | 2. Clone project using Git and enter project directory
10 | 3. cp src/Config.php.sample src/Config.php and configure it.
11 |
12 | cp ./docker/env-example ./docker/.env and configure it.
13 | 4. cd docker; docker-compose build && docker-compose up -d
14 | 5. docker exec -it ws_chat_workspace bash
15 |
16 | npm install
17 |
18 | composer install
19 |
20 | php bin/console app:database:create
21 |
22 | php bin/console app:migration:migrate (Enter nothing when it`ll ask about the version)
23 |
24 | npm run production
25 |
26 | (May be someday I will automate this process)
27 |
28 |
--------------------------------------------------------------------------------
/bin/console:
--------------------------------------------------------------------------------
1 | add(new StartAppCommand());
12 | $application->add(new CreateMigrationCommand());
13 | $application->add(new CreateDatabaseCommand());
14 | $application->add(new MigrateCommand());
15 |
16 | $application->run();
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "root/ws-chat",
3 | "require": {
4 | "ext-json": "*",
5 | "ezyang/htmlpurifier": "^4.10",
6 | "ext-pdo": "*",
7 | "symfony/console": "^4.3"
8 | },
9 | "autoload": {
10 | "psr-4": {
11 | "App\\": "src/"
12 | }
13 | },
14 | "require-dev": {
15 | "vimeo/psalm": "^3.4"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/docker/.gitignore:
--------------------------------------------------------------------------------
1 | logs/
2 | postgres/
3 | .env
4 |
--------------------------------------------------------------------------------
/docker/build/nginx/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM debian:stretch
2 | RUN apt-get update && apt-get install -y nginx vim nano
3 | COPY nginx.conf /etc/nginx/nginx.conf
4 | ADD sites-enabled /etc/nginx/sites-enabled
5 | RUN rm /etc/nginx/sites-enabled/default
6 | WORKDIR /var/www/html/symfony
7 | EXPOSE 80
8 | EXPOSE 443
9 | CMD ["nginx"]
10 |
--------------------------------------------------------------------------------
/docker/build/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | user www-data;
2 | pid /run/nginx.pid;
3 | worker_processes 1;
4 | daemon off;
5 | events {
6 | worker_connections 768;
7 | # multi_accept on;
8 | }
9 | http {
10 | client_max_body_size 20M;
11 | ##
12 | # Basic Settings
13 | ##
14 | sendfile on;
15 | tcp_nopush on;
16 | tcp_nodelay on;
17 | keepalive_timeout 65;
18 | types_hash_max_size 2048;
19 | # server_tokens off;
20 | # server_names_hash_bucket_size 64;
21 | # server_name_in_redirect off;
22 | include /etc/nginx/mime.types;
23 | default_type application/octet-stream;
24 | ##
25 | # SSL Settings
26 | ##
27 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
28 | ssl_prefer_server_ciphers on;
29 | ##
30 | # Logging Settings
31 | ##
32 | access_log /var/log/nginx/access.log;
33 | error_log /var/log/nginx/error.log;
34 | ##
35 | # Gzip Settings
36 | ##
37 | gzip on;
38 | gzip_disable "msie6";
39 | gzip_vary on;
40 | gzip_proxied any;
41 | gzip_comp_level 6;
42 | gzip_buffers 16 8k;
43 | gzip_http_version 1.1;
44 | gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
45 | ##
46 | # Virtual Host Configs
47 | ##
48 | include /etc/nginx/conf.d/*.conf;
49 | include /etc/nginx/sites-enabled/*;
50 | }
--------------------------------------------------------------------------------
/docker/build/nginx/sites-enabled/ws-chat.conf:
--------------------------------------------------------------------------------
1 | server {
2 | server_name localhost;
3 | root /var/www/html/ws-chat/public;
4 |
5 | location / {
6 | # try to serve file directly, fallback to index.php
7 | try_files $uri /index.php$is_args$args;
8 | }
9 |
10 | location /ws {
11 | proxy_pass http://ws:9502;
12 | proxy_http_version 1.1;
13 | proxy_set_header Upgrade $http_upgrade;
14 | proxy_set_header Connection "Upgrade";
15 | }
16 | # DEV
17 | # This rule swoole_websocket_servershould only be placed on your development environment
18 | # In production, don't include this and don't deploy index_dev.php or config.php
19 | #location ~ ^/(index_dev|config)\.php(/|$) {
20 | # fastcgi_pass php:9000;
21 | # fastcgi_split_path_info ^(.+\.php)(/.*)$;
22 | # include fastcgi_params;
23 | # When you are using symlinks to link the document root to the
24 | # current version of your application, you should pass the real
25 | # application path instead of the path to the symlink to PHP
26 | # FPM.
27 | # Otherwise, PHP's OPcache may not properly detect changes to
28 | # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
29 | # for more information).
30 | # fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
31 | # fastcgi_param DOCUMENT_ROOT $realpath_root;
32 | #}
33 | # PROD
34 | location ~ ^/index\.php(/|$) {
35 | # php-fpm mean container name
36 | fastcgi_pass php-fpm:9000;
37 | fastcgi_split_path_info ^(.+\.php)(/.*)$;
38 | include fastcgi_params;
39 | # When you are using symlinks to link the document root to the
40 | # current version of your application, you should pass the real
41 | # application path instead of the path to the symlink to PHP
42 | # FPM.
43 | # Otherwise, PHP's OPcache may not properly detect changes to
44 | # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
45 | # for more information).
46 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
47 | fastcgi_param DOCUMENT_ROOT $realpath_root;
48 | # Prevents URIs that include the front controller. This will 404:
49 | # http://domain.tld/index.php/some-path
50 | # Remove the internal directive to allow URIs like this
51 | internal;
52 | }
53 | # return 404 for all other php files not matching the front controller
54 | # this prevents access to other php files you don't want to be accessible.
55 | location ~ \.php$ {
56 | return 404;
57 | }
58 | error_log /var/log/nginx/error.log;
59 | access_log /var/log/nginx/access.log;
60 | }
61 |
--------------------------------------------------------------------------------
/docker/build/php/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:7.2-fpm
2 |
3 | RUN apt-get update
4 |
5 | RUN set -ex && \
6 | apt-get install vim -y && \
7 | apt-get install openssl -y && \
8 | apt-get install libssl-dev -y && \
9 | apt-get install wget -y && \
10 | apt-get install libpq-dev -y
11 |
12 | RUN cd /tmp && wget https://pecl.php.net/get/swoole-4.2.9.tgz && \
13 | tar zxvf swoole-4.2.9.tgz && \
14 | cd swoole-4.2.9 && \
15 | phpize && \
16 | ./configure --enable-openssl && \
17 | make && make install
18 |
19 | RUN touch /usr/local/etc/php/conf.d/swoole.ini && \
20 | echo 'extension=swoole.so' > /usr/local/etc/php/conf.d/swoole.ini
21 |
22 | RUN docker-php-ext-install pdo_pgsql
23 |
24 | WORKDIR /var/www/html/ws-chat
25 |
26 | EXPOSE 8101
--------------------------------------------------------------------------------
/docker/build/php/docker-php-entrypoint:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | # first arg is `-f` or `--some-option`
5 | if [ "${1#-}" != "$1" ]; then
6 | set -- php-fpm "$@"
7 | fi
8 |
9 | exec "$@"
10 |
--------------------------------------------------------------------------------
/docker/build/php/docker-php-ext-configure:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | # prefer user supplied CFLAGS, but default to our PHP_CFLAGS
5 | : ${CFLAGS:=$PHP_CFLAGS}
6 | : ${CPPFLAGS:=$PHP_CPPFLAGS}
7 | : ${LDFLAGS:=$PHP_LDFLAGS}
8 | export CFLAGS CPPFLAGS LDFLAGS
9 |
10 | srcExists=
11 | if [ -d /usr/src/php ]; then
12 | srcExists=1
13 | fi
14 | docker-php-source extract
15 | if [ -z "$srcExists" ]; then
16 | touch /usr/src/php/.docker-delete-me
17 | fi
18 |
19 | cd /usr/src/php/ext
20 |
21 | usage() {
22 | echo "usage: $0 ext-name [configure flags]"
23 | echo " ie: $0 gd --with-jpeg-dir=/usr/local/something"
24 | echo
25 | echo 'Possible values for ext-name:'
26 | find . \
27 | -mindepth 2 \
28 | -maxdepth 2 \
29 | -type f \
30 | -name 'config.m4' \
31 | | xargs -n1 dirname \
32 | | xargs -n1 basename \
33 | | sort \
34 | | xargs
35 | echo
36 | echo 'Some of the above modules are already compiled into PHP; please check'
37 | echo 'the output of "php -i" to see which modules are already loaded.'
38 | }
39 |
40 | ext="$1"
41 | if [ -z "$ext" ] || [ ! -d "$ext" ]; then
42 | usage >&2
43 | exit 1
44 | fi
45 | shift
46 |
47 | pm='unknown'
48 | if [ -e /lib/apk/db/installed ]; then
49 | pm='apk'
50 | fi
51 |
52 | if [ "$pm" = 'apk' ]; then
53 | if \
54 | [ -n "$PHPIZE_DEPS" ] \
55 | && ! apk info --installed .phpize-deps > /dev/null \
56 | && ! apk info --installed .phpize-deps-configure > /dev/null \
57 | ; then
58 | apk add --no-cache --virtual .phpize-deps-configure $PHPIZE_DEPS
59 | fi
60 | fi
61 |
62 | if command -v dpkg-architecture > /dev/null; then
63 | gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"
64 | set -- --build="$gnuArch" "$@"
65 | fi
66 |
67 | cd "$ext"
68 | phpize
69 | ./configure "$@"
70 |
--------------------------------------------------------------------------------
/docker/build/php/docker-php-ext-enable:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | extDir="$(php -r 'echo ini_get("extension_dir");')"
5 | cd "$extDir"
6 |
7 | usage() {
8 | echo "usage: $0 [options] module-name [module-name ...]"
9 | echo " ie: $0 gd mysqli"
10 | echo " $0 pdo pdo_mysql"
11 | echo " $0 --ini-name 0-apc.ini apcu apc"
12 | echo
13 | echo 'Possible values for module-name:'
14 | find -maxdepth 1 \
15 | -type f \
16 | -name '*.so' \
17 | -exec basename '{}' ';' \
18 | | sort \
19 | | xargs
20 | echo
21 | echo 'Some of the above modules are already compiled into PHP; please check'
22 | echo 'the output of "php -i" to see which modules are already loaded.'
23 | }
24 |
25 | opts="$(getopt -o 'h?' --long 'help,ini-name:' -- "$@" || { usage >&2 && false; })"
26 | eval set -- "$opts"
27 |
28 | iniName=
29 | while true; do
30 | flag="$1"
31 | shift
32 | case "$flag" in
33 | --help|-h|'-?') usage && exit 0 ;;
34 | --ini-name) iniName="$1" && shift ;;
35 | --) break ;;
36 | *)
37 | {
38 | echo "error: unknown flag: $flag"
39 | usage
40 | } >&2
41 | exit 1
42 | ;;
43 | esac
44 | done
45 |
46 | modules=
47 | for module; do
48 | if [ -z "$module" ]; then
49 | continue
50 | fi
51 | if [ -f "$module.so" ] && ! [ -f "$module" ]; then
52 | # allow ".so" to be optional
53 | module="$module.so"
54 | fi
55 | if ! [ -f "$module" ]; then
56 | echo >&2 "error: '$module' does not exist"
57 | echo >&2
58 | usage >&2
59 | exit 1
60 | fi
61 | modules="$modules $module"
62 | done
63 |
64 | if [ -z "$modules" ]; then
65 | usage >&2
66 | exit 1
67 | fi
68 |
69 | pm='unknown'
70 | if [ -e /lib/apk/db/installed ]; then
71 | pm='apk'
72 | fi
73 |
74 | apkDel=
75 | if [ "$pm" = 'apk' ]; then
76 | if \
77 | [ -n "$PHPIZE_DEPS" ] \
78 | && ! apk info --installed .phpize-deps > /dev/null \
79 | && ! apk info --installed .phpize-deps-configure > /dev/null \
80 | ; then
81 | apk add --no-cache --virtual '.docker-php-ext-enable-deps' binutils
82 | apkDel='.docker-php-ext-enable-deps'
83 | fi
84 | fi
85 |
86 | for module in $modules; do
87 | if readelf --wide --syms "$module" | grep -q ' zend_extension_entry$'; then
88 | # https://wiki.php.net/internals/extensions#loading_zend_extensions
89 | absModule="$(readlink -f "$module")"
90 | line="zend_extension=$absModule"
91 | else
92 | line="extension=$module"
93 | fi
94 |
95 | ext="$(basename "$module")"
96 | ext="${ext%.*}"
97 | if php -r 'exit(extension_loaded("'"$ext"'") ? 0 : 1);'; then
98 | # this isn't perfect, but it's better than nothing
99 | # (for example, 'opcache.so' presents inside PHP as 'Zend OPcache', not 'opcache')
100 | echo >&2
101 | echo >&2 "warning: $ext ($module) is already loaded!"
102 | echo >&2
103 | continue
104 | fi
105 |
106 | ini="$PHP_INI_DIR/conf.d/${iniName:-"docker-php-ext-$ext.ini"}"
107 | if ! grep -q "$line" "$ini" 2>/dev/null; then
108 | echo "$line" >> "$ini"
109 | fi
110 | done
111 |
112 | if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
113 | apk del --no-network $apkDel
114 | fi
115 |
--------------------------------------------------------------------------------
/docker/build/php/docker-php-ext-install:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | # prefer user supplied CFLAGS, but default to our PHP_CFLAGS
5 | : ${CFLAGS:=$PHP_CFLAGS}
6 | : ${CPPFLAGS:=$PHP_CPPFLAGS}
7 | : ${LDFLAGS:=$PHP_LDFLAGS}
8 | export CFLAGS CPPFLAGS LDFLAGS
9 |
10 | srcExists=
11 | if [ -d /usr/src/php ]; then
12 | srcExists=1
13 | fi
14 | docker-php-source extract
15 | if [ -z "$srcExists" ]; then
16 | touch /usr/src/php/.docker-delete-me
17 | fi
18 |
19 | cd /usr/src/php/ext
20 |
21 | usage() {
22 | echo "usage: $0 [-jN] ext-name [ext-name ...]"
23 | echo " ie: $0 gd mysqli"
24 | echo " $0 pdo pdo_mysql"
25 | echo " $0 -j5 gd mbstring mysqli pdo pdo_mysql shmop"
26 | echo
27 | echo 'if custom ./configure arguments are necessary, see docker-php-ext-configure'
28 | echo
29 | echo 'Possible values for ext-name:'
30 | find . \
31 | -mindepth 2 \
32 | -maxdepth 2 \
33 | -type f \
34 | -name 'config.m4' \
35 | | xargs -n1 dirname \
36 | | xargs -n1 basename \
37 | | sort \
38 | | xargs
39 | echo
40 | echo 'Some of the above modules are already compiled into PHP; please check'
41 | echo 'the output of "php -i" to see which modules are already loaded.'
42 | }
43 |
44 | opts="$(getopt -o 'h?j:' --long 'help,jobs:' -- "$@" || { usage >&2 && false; })"
45 | eval set -- "$opts"
46 |
47 | j=1
48 | while true; do
49 | flag="$1"
50 | shift
51 | case "$flag" in
52 | --help|-h|'-?') usage && exit 0 ;;
53 | --jobs|-j) j="$1" && shift ;;
54 | --) break ;;
55 | *)
56 | {
57 | echo "error: unknown flag: $flag"
58 | usage
59 | } >&2
60 | exit 1
61 | ;;
62 | esac
63 | done
64 |
65 | exts=
66 | for ext; do
67 | if [ -z "$ext" ]; then
68 | continue
69 | fi
70 | if [ ! -d "$ext" ]; then
71 | echo >&2 "error: $PWD/$ext does not exist"
72 | echo >&2
73 | usage >&2
74 | exit 1
75 | fi
76 | exts="$exts $ext"
77 | done
78 |
79 | if [ -z "$exts" ]; then
80 | usage >&2
81 | exit 1
82 | fi
83 |
84 | pm='unknown'
85 | if [ -e /lib/apk/db/installed ]; then
86 | pm='apk'
87 | fi
88 |
89 | apkDel=
90 | if [ "$pm" = 'apk' ]; then
91 | if [ -n "$PHPIZE_DEPS" ]; then
92 | if apk info --installed .phpize-deps-configure > /dev/null; then
93 | apkDel='.phpize-deps-configure'
94 | elif ! apk info --installed .phpize-deps > /dev/null; then
95 | apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS
96 | apkDel='.phpize-deps'
97 | fi
98 | fi
99 | fi
100 |
101 | popDir="$PWD"
102 | for ext in $exts; do
103 | cd "$ext"
104 | [ -e Makefile ] || docker-php-ext-configure "$ext"
105 | make -j"$j"
106 | make -j"$j" install
107 | find modules \
108 | -maxdepth 1 \
109 | -name '*.so' \
110 | -exec basename '{}' ';' \
111 | | xargs -r docker-php-ext-enable
112 | make -j"$j" clean
113 | cd "$popDir"
114 | done
115 |
116 | if [ "$pm" = 'apk' ] && [ -n "$apkDel" ]; then
117 | apk del --no-network $apkDel
118 | fi
119 |
120 | if [ -e /usr/src/php/.docker-delete-me ]; then
121 | docker-php-source delete
122 | fi
123 |
--------------------------------------------------------------------------------
/docker/build/php/docker-php-source:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | dir=/usr/src/php
5 |
6 | usage() {
7 | echo "usage: $0 COMMAND"
8 | echo
9 | echo "Manage php source tarball lifecycle."
10 | echo
11 | echo "Commands:"
12 | echo " extract extract php source tarball into directory $dir if not already done."
13 | echo " delete delete extracted php source located into $dir if not already done."
14 | echo
15 | }
16 |
17 | case "$1" in
18 | extract)
19 | mkdir -p "$dir"
20 | if [ ! -f "$dir/.docker-extracted" ]; then
21 | tar -Jxf /usr/src/php.tar.xz -C "$dir" --strip-components=1
22 | touch "$dir/.docker-extracted"
23 | fi
24 | ;;
25 |
26 | delete)
27 | rm -rf "$dir"
28 | ;;
29 |
30 | *)
31 | usage
32 | exit 1
33 | ;;
34 | esac
35 |
--------------------------------------------------------------------------------
/docker/build/php/systemd/app.target:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=App
3 | Type=simple
4 | PIDFile=/work/www/myunit/shared/tmp/pids/service.pid
--------------------------------------------------------------------------------
/docker/build/workspace/Dockerfile:
--------------------------------------------------------------------------------
1 | # Copied & Pasted from Laradock https://github.com/laradock
2 | #
3 | #--------------------------------------------------------------------------
4 | # Image Setup
5 | #--------------------------------------------------------------------------
6 | #
7 |
8 | FROM phusion/baseimage:0.11
9 |
10 | LABEL maintainer="Mahmoud Zalt "
11 |
12 | RUN DEBIAN_FRONTEND=noninteractive
13 | RUN locale-gen en_US.UTF-8
14 |
15 | ENV LANGUAGE=en_US.UTF-8
16 | ENV LC_ALL=en_US.UTF-8
17 | ENV LC_CTYPE=en_US.UTF-8
18 | ENV LANG=en_US.UTF-8
19 | ENV TERM xterm
20 |
21 | # Add the "PHP 7" ppa
22 | RUN apt-get install -y software-properties-common && \
23 | add-apt-repository -y ppa:ondrej/php
24 |
25 | RUN groupadd --system user --gid 1000 && useradd --no-log-init --system --gid 1000 --uid 1000 user
26 |
27 | #
28 | #--------------------------------------------------------------------------
29 | # Software's Installation
30 | #--------------------------------------------------------------------------
31 | #
32 |
33 | # Install "PHP Extentions", "libraries", "Software's"
34 | RUN apt-get update && \
35 | apt-get upgrade -y && \
36 | curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
37 | apt-get install -y --allow-downgrades --allow-remove-essential \
38 | --allow-change-held-packages \
39 | php7.3-cli \
40 | php7.3-common \
41 | php7.3-curl \
42 | php7.3-intl \
43 | php7.3-json \
44 | php7.3-xml \
45 | php7.3-mbstring \
46 | php7.3-mysql \
47 | php7.3-pgsql \
48 | php7.3-sqlite \
49 | php7.3-sqlite3 \
50 | php7.3-zip \
51 | php7.3-bcmath \
52 | php7.3-memcached \
53 | php7.3-gd \
54 | php7.3-dev \
55 | nodejs \
56 | pkg-config \
57 | libcurl4-openssl-dev \
58 | libedit-dev \
59 | libssl-dev \
60 | libxml2-dev \
61 | xz-utils \
62 | libsqlite3-dev \
63 | sqlite3 \
64 | git \
65 | curl \
66 | vim \
67 | nano \
68 | postgresql-client \
69 | && apt-get clean
70 |
71 | #####################################
72 | # Composer:
73 | #####################################
74 |
75 | # Install composer and add its bin to the PATH.
76 | RUN curl -s http://getcomposer.org/installer | php && \
77 | echo "export PATH=${PATH}:/var/www/vendor/bin" >> ~/.bashrc && \
78 | mv composer.phar /usr/local/bin/composer
79 |
80 | WORKDIR /var/www/html/ws-chat
81 |
82 | # Source the bash
83 | RUN sh
84 |
--------------------------------------------------------------------------------
/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | ws:
4 | build: build/php
5 | container_name: ws_chat_ws
6 | expose:
7 | - '9502'
8 | depends_on:
9 | - db
10 | volumes:
11 | - ./../:/var/www/html/ws-chat:cached
12 | - ./logs:/var/log
13 | command: php /var/www/html/ws-chat/bin/console app:start
14 | php-fpm:
15 | build: build/php
16 | container_name: ws_chat_fpm
17 | expose:
18 | - '9000'
19 | depends_on:
20 | - db
21 | volumes:
22 | - ./../:/var/www/html/ws-chat:cached
23 | - ./logs:/var/log
24 | db:
25 | image: postgres:11.2
26 | restart: always
27 | container_name: ws_chat_db
28 | environment:
29 | POSTGRES_PASSWORD: ${DB_PASS}
30 | POSTGRES_USER: ${DB_USER}
31 | volumes:
32 | - ./postgres:/var/lib/postgresql/data
33 | workspace:
34 | build: build/workspace
35 | restart: always
36 | container_name: ws_chat_workspace
37 | depends_on:
38 | - db
39 | volumes:
40 | - ./../:/var/www/html/ws-chat:cached
41 | - ./logs:/var/log/nginx
42 | nginx:
43 | build: build/nginx
44 | restart: always
45 | container_name: ws_chat_nginx
46 | ports:
47 | - 81:80
48 | depends_on:
49 | - php-fpm
50 | - db
51 | volumes:
52 | - ./../:/var/www/html/ws-chat:cached
53 | - ./logs:/var/log/nginx
--------------------------------------------------------------------------------
/docker/env-example:
--------------------------------------------------------------------------------
1 | # cp ./env-example ./.env
2 | DB_USER=test
3 | DB_PASS=test
4 | PHP_INI_DIR=/usr/local/etc/php
5 |
--------------------------------------------------------------------------------
/docker/shortcuts/exec_db:
--------------------------------------------------------------------------------
1 | docker exec -it ws_chat_db bash
2 |
--------------------------------------------------------------------------------
/docker/shortcuts/exec_php:
--------------------------------------------------------------------------------
1 | docker exec -it -u $(id -u):$(id -g) ws_chat_php sh
2 |
--------------------------------------------------------------------------------
/docker/shortcuts/exec_workspace:
--------------------------------------------------------------------------------
1 | docker exec -it -u user ws_chat_workspace bash
--------------------------------------------------------------------------------
/mix-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "/public/js/app.js": "/public/js/app.js",
3 | "/public/css/app.css": "/public/css/app.css"
4 | }
5 |
--------------------------------------------------------------------------------
/output/alias/Client.php:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 | ws-chat
9 |
10 |
11 |