Make sure you have PHP8.x installed and setup to use on Cli, using php -v
(For Docker Images check Swoole / OpenSwoole Official Documentation)
sudo apt-get update
sudo apt install gcc -y && \
sudo apt-get install libssl-dev -y && \
sudo apt install openssl -y && \
sudo apt install build-essential -y && \
sudo apt-get install bzip2 -y && \
sudo apt-get install zlib1g-dev -y && \
sudo apt-get install libzip-dev -y && \
sudo apt-get install autoconf -y && \
sudo apt install libpcre3-dev -y && \
sudo apt-get install -y libc-ares2 -y && \
sudo apt install libc-ares-dev -y && \
sudo apt-get install libpq-dev -y && \
sudo apt-get install libcurl4-openssl-dev -y && \
sudo apt-get install inotify-tools -y && \
sudo apt install libbrotli-dev -y
pecl install -D 'enable-sockets="yes" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-json="no" enable-swoole-curl="yes" enable-cares="yes"' swoole
if /tmp directory not created, then create it as below
sudo mkdir -m 775 /tmp
To install Swoole on PHP 8.3, use command below (For a different version of php replace all instances of '8.3' in command below with your version of php)
cd /tmp && \
git clone https://github.com/swoole/swoole-src && \
cd swoole-src && \
git checkout v5.1.3 && \
phpize8.3 clean && \
phpize8.3 && \
./configure --enable-openssl \
--enable-mysqlnd \
--enable-sockets \
--enable-swoole-curl \
--enable-swoole-pgsql \
--enable-debug \
--enable-debug-log \
--enable-trace-log \
--enable-thread-context \
--enable-cares \
--with-php-config=/usr/bin/php-config8.3 && \
sudo make clean && make && sudo make install && \
sudo bash -c "cat > /etc/php/8.3/mods-available/swoole.ini << EOF
; Configuration for OpenSwoole
; priority=25
extension=swoole
swoole.enable_preemptive_scheduler=On
EOF"
sudo phpenmod -s cli -v 8.3 openswoole
sudo pear channel-update pear.php.net && \
sudo pecl channel-update pecl.php.net && \
sudo pecl install -D 'enable-sockets="yes" enable-openssl="yes" enable-http2="yes" enable-mysqlnd="yes" enable-swoole-pgsql="yes" with-postgres="yes" enable-swoole-json="yes" enable-hook-curl="yes" enable-swoole-curl="yes" enable-debug="yes" enable-swoole-trace="yes" enable-thread-context="yes" enable-debug-log="yes" enable-trace-log="yes" enable-cares="yes"' openswoole-22.1.2 && \
sudo bash -c "cat > /etc/php/8.3/mods-available/openswoole.ini << EOF
; Configuration for OpenSwoole
; priority=25
extension=openswoole
openswoole.enable_preemptive_scheduler=On
openswoole.use_shortname=On
swoole.use_shortname=On
EOF" && \
sudo phpenmod -s cli -v 8.3 openswoole
composer require openswoole/core:22.1.5
git clone https://github.com/fakharak/swoole-serv.git
composer install
composer dump-autoload
cd to swoole-serv folder, and then run the command below;
php sw_service.php websocket
sudo php ./websocketclient/websocketclient_usage.php
php sw_service.php reload
sudo php ./websocketclient/websocketclient_usage.php reload-code
php sw_service.php shutdown
php sw_service.php restart
kill -USR1 `cat server.pid`
kill -USR2 `cat server.pid`
sudo kill -SIGTERM $(sudo lsof -t -i:9501)
OR
sudo kill -15 $(sudo lsof -t -i:9501)
OR
kill -15 [process_id]]
OR (specially when daemon = 1 (daemonize mode))
sudo kill `cat server.pid`
sudo phpdismod -s cli swoole && \
sudo phpenmod -s cli openswoole
sudo phpdismod -s cli openswoole && \
sudo phpenmod -s cli swoole
ps -aux | grep swool
ps faux | grep -i sw_service.php
sudo lsof -t -i:9501
You can setup the database and other Phinx configuration inside config/phinx.php
file
The Create command is used to create a new migration file. It requires one argument: the name of the migration. The migration name should be specified in CamelCase format.
composer run-script phinx:create MigrationFileName
The Migrate command runs all of the available migrations, optionally up to a specific version.
composer run-script phinx:migrate -- -e <environment>
To migrate to a specific version then use the --target
parameter or -t
for short.
Example:
composer run-script phinx:migrate -- -e local -t 20110103081132
Use --dry-run
to print the queries to standard output without executing them
composer run-script phinx:migrate -- --dry-run
The Rollback command is used to undo previous migrations executed by Phinx. It is the opposite of the Migrate command.
You can rollback to the previous migration by using the rollback
command with no arguments.
composer run-script phinx:rollback -- -e local
To rollback all migrations to a specific version then use the --target
parameter or -t
for short.
composer run-script phinx:rollback -- -e local -t 20120103083322
Specifying 0 as the target version will revert all migrations.
composer run-script phinx:rollback -- -e local -t 0
Use --dry-run
to print the queries to standard output without executing them
composer run-script phinx:rollback -- -e local --dry-run
The Seed Create command can be used to create new database seed classes. It requires one argument, the name of the class. The class name should be specified in CamelCase format.
composer run-script phinx:seed-create MyNewSeeder
The Seed Run command runs all of the available seed classes or optionally just one.
composer run-script phinx:seed-run -- -e local
To run only one seed class use the --seed
parameter or -s
for short.
composer run-script phinx:seed-run -- -e local -s MyNewSeeder