swoole / library

📚 Swoole Library
https://wiki.swoole.com/#/library
Apache License 2.0
239 stars 56 forks source link

PHP Fatal error: Cannot redeclare Swoole\Coroutine\run() (previously declared in @swoole/library/core/Coroutine/functions.php:16) in [my_project_folder]/vendor/swoole/library/src/core/Coroutine/functions.php on line 24 #175

Closed fakharksa closed 3 months ago

fakharksa commented 3 months ago

I m using Swoole version 5.1.2

I installed Swoole\Library v5.1.3 using command composer require swoole/library

I did that to use ConnectionPool from my Postgres Database.

Now when i try to start server, i get following warning / error:

PHP Warning: Constant SWOOLE_LIBRARY already defined in [my_project_folder]/vendor/swoole/library/src/constants.php on line 12 PHP Fatal error: Cannot redeclare Swoole\Coroutine\run() (previously declared in @swoole/library/core/Coroutine/functions.php:16) in [my_project_folder]/vendor/swoole/library/src/core/Coroutine/functions.php on line 24

My Swoole version (php --ri swoole) is:

swoole

Swoole => enabled Author => Swoole Team team@swoole.com Version => 5.1.2 Built => Jun 23 2024 18:11:32 coroutine => enabled with thread context debug => enabled trace_log => enabled epoll => enabled eventfd => enabled signalfd => enabled cpu_affinity => enabled spinlock => enabled rwlock => enabled sockets => enabled openssl => OpenSSL 3.0.2 15 Mar 2022 dtls => enabled http2 => enabled json => enabled curl-native => enabled c-ares => 1.18.1 zlib => 1.2.11 mutex_timedlock => enabled pthread_barrier => enabled futex => enabled mysqlnd => enabled async_redis => enabled coroutine_pgsql => enabled

Directive => Local Value => Master Value swoole.enable_coroutine => On => On swoole.enable_library => On => On swoole.enable_fiber_mock => Off => Off swoole.enable_preemptive_scheduler => On => On swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 8388608 => 8388608

My System Details:

Linux HP-Laptop 5.17.5-76051705-generic #202204271406165150484020.04~63e51bd-Ubuntu SMP PREEMPT Wed Ma x86_64 x86_64 x86_64 GNU/Linux

PHP 8.3.8 (cli) (built: Jun 6 2024 16:58:27) (NTS) Copyright (c) The PHP Group Zend Engine v4.3.8, Copyright (c) Zend Technologies with Zend OPcache v8.3.8, Copyright (c), by Zend Technologies

COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu122.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu122.04)

deminy commented 3 months ago

Swoole Library is included in the Swoole extension by default. When Swoole is loaded, constants, functions and classes defined in Swoole Library are also loaded already.

If you want to use your own copy over of Swoole Library via Composer, please set PHP option swoole.enable_library to off in your php.ini. When running PHP from CLI, you can turn the option off by running PHP like php -d swoole.enable_library=Off /path/to/php/file.