Closed IVoyt closed 3 weeks ago
Try to place the priority of Swoole at the end when loading the extension.
Try loading the Swoole extension at the end.
Try to place the priority of Swoole at the end when loading the extension.
you mean extensions order in php.ini? If so it did not help :(
Are you directly adding extension=swoole.so
to the php.ini file? If so, try adding it to another configuration file, like this.
root@iZ7xv05bnlqyyku0ks7bzqZ:/home# php --ini
Configuration File (php.ini) Path: /etc/php/8.3/cli
Loaded Configuration File: /etc/php/8.3/cli/php.ini
Scan for additional .ini files in: /etc/php/8.3/cli/conf.d
Additional .ini files parsed: /etc/php/8.3/cli/conf.d/10-opcache.ini,
/etc/php/8.3/cli/conf.d/10-pdo.ini,
/etc/php/8.3/cli/conf.d/15-xml.ini,
/etc/php/8.3/cli/conf.d/20-calendar.ini,
/etc/php/8.3/cli/conf.d/20-ctype.ini,
/etc/php/8.3/cli/conf.d/20-curl.ini,
/etc/php/8.3/cli/conf.d/20-dom.ini,
/etc/php/8.3/cli/conf.d/20-exif.ini,
/etc/php/8.3/cli/conf.d/20-ffi.ini,
/etc/php/8.3/cli/conf.d/20-fileinfo.ini,
/etc/php/8.3/cli/conf.d/20-ftp.ini,
/etc/php/8.3/cli/conf.d/20-gettext.ini,
/etc/php/8.3/cli/conf.d/20-iconv.ini,
/etc/php/8.3/cli/conf.d/20-phar.ini,
/etc/php/8.3/cli/conf.d/20-posix.ini,
/etc/php/8.3/cli/conf.d/20-readline.ini,
/etc/php/8.3/cli/conf.d/20-shmop.ini,
/etc/php/8.3/cli/conf.d/20-simplexml.ini,
/etc/php/8.3/cli/conf.d/20-sockets.ini,
/etc/php/8.3/cli/conf.d/20-swoole.ini,
/etc/php/8.3/cli/conf.d/20-sysvmsg.ini,
/etc/php/8.3/cli/conf.d/20-sysvsem.ini,
/etc/php/8.3/cli/conf.d/20-sysvshm.ini,
/etc/php/8.3/cli/conf.d/20-tokenizer.ini,
/etc/php/8.3/cli/conf.d/20-xmlreader.ini,
/etc/php/8.3/cli/conf.d/20-xmlwriter.ini,
/etc/php/8.3/cli/conf.d/20-xsl.ini,
/etc/php/8.3/cli/conf.d/30-event.ini
I have only one php.ini. My setup is MAMP PRO 7 with manually built and added extension to /Applications/MAMP/bin/php/php8.2.21/conf/php.ini
It's possible that your computer has multiple PHP versions.
it looks like I have only one php version loaded at the moment
upd: I even checked if I have a brew version of php but nothing there
php -r "var_dump(SWOOLE_SOCK_TCP);"
Run this and check the output.
I assume this means the constant is visible to the interpreter. This is weird. Then why laravel octane is falling with exception!?
php -m
to see the list of extensions.
❯ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imap
intl
json
ldap
libxml
mbstring
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
random
readline
redis
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
swoole
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
phpinfo also displays that module is loaded
Have you execute the octane:install
Artisan command?
Of course I did
Can you show me the full error message?
It looks like Octane has been successfully started here, and this error seems to have occurred after the startup.
I'm throwing this exception explicitly
because by default the error is Fatal error: Uncaught Error: Class "Laravel\Octane\Octane" not found in /Users/<projectPath>/vendor/laravel/octane/src/Stream.php:56
which is unclear
Can you directly access http://127.0.0.1:8000? If there is output, then Octane has been successfully started, and the issue is caused elsewhere.
No, I can't. It fails immediately after the start.
The weird thing is that the constant is available everywhere except one particular file vendor/laravel/octane/bin/createSwooleServer.php
Maybe I need to ask help at Laravel maintainers. Thanks for your help!
I'll write back if I'll have any updates on this issue
php --ini
Command execution output ?
php --ini
Command execution output ?
Block interference from the system environment
try static build php : https://github.com/swoole/build-static-php/releases/download/v1.3.2/php-cli-v8.2.13-macos-arm64.tar.xz
https://github.com/swoole/build-static-php/releases/tag/v1.3.2
curl -fSL https://github.com/swoole/build-static-php/blob/main/setup-php-cli-runtime.sh?raw=true | bash
Please provide the execution output result ?
the static build shows that ini is located in /usr/local/lib, but there is nothing related to php
upd: maybe you meant to reproduce problem with undefined constant? Yep, with static build it seems to work
the static build shows that ini is located in /usr/local/lib, but there is nothing related to php
export PATH=/your-workpath/php-cli-v8.2.13/bin/runtime/:$PATH alias php='php -c /your-workpath/php-cli-v8.2.13/bin/runtime/php.ini' php -v php --ri swoole
php artisan octane:install php artisan octane:start --works=4
the static build shows that ini is located in /usr/local/lib, but there is nothing related to php
export PATH=/your-workpath/php-cli-v8.2.13/bin/runtime/:$PATH alias php='php -c /your-workpath/php-cli-v8.2.13/bin/runtime/php.ini' php -v php --ri swoole
php artisan octane:install php artisan octane:start --works=4
thanks, I already tested and it works.
But can you give me an advice how to fix this on my setup not using static build. Because I already have compiled extension with pecl by instructions from the documentation
Missing sockets extensions and c-ares library
brew install c-ares
and
reinstall swoole
pecl install --configureoptions 'enable-sockets="yes" enable-openssl="yes" enable-mysqlnd="yes" enable-swoole-curl="yes" enable-cares="yes"' swoole
I've installed brew install c-ares
and recompiled the extension with command you provided but unfortunately it does not help
I've installed
brew install c-ares
and recompiled the extension with command you provided but unfortunately it does not help
enable extension sockets?
yes, I used exact command you provided
This is because the swoole extension has not been loaded
Check if you have executed composer install laravel/octane
Undefined constant "SWOOLE_SOCK_TCP"
This is because the swoole extension has not been loaded
Uncaught Error: Class "Laravel\Octane\Octane"
Check if you have executed composer install laravel/octane
thank you for your contribution to solving the problem
Did you read carefully all this thread? If you did, you should notice that I executed composer install laravel/octane
and that the extension was loaded when the laravel is initiated. But when the control of execution is transfered to the Octane package the Swoole constants become inaccessible for php
I've found the problem. Thank you @NathanFreeman & @jingjingxyk for pointing me to the direction of the solution.
The problem was in MAMP PRO. When installed it creates another ini file located at /Library/Application Support/appsolute/MAMP PRO/conf/
where it writes own directives (let's call it "custom"). I was adding the swoole extension into the custom ini.
So there are 2 ini files in the system. And changing custom ini does not mirror changes on default ini. And that was the problem since when control of execution was transferred to the Octane package, there was probably created some sub process of php which for some reason uses default ini, in which the extension was missing. So the solution was to specify extension in the default ini.
Please answer these questions before submitting your issue.
pecl install swoole
with optionsrun
php artisan octane:start
What did you expect to see? started octane server
What did you see instead?
Uncaught Error: Class "Laravel\Octane\Octane"
debugging led me to the error in the titleWhat version of Swoole are you using (show your
php --ri swoole
)?Swoole => enabled Author => Swoole Team team@swoole.com Version => 5.1.3 Built => Aug 13 2024 15:05:59 coroutine => enabled with boost asm context kqueue => enabled rwlock => enabled openssl => OpenSSL 3.3.1 4 Jun 2024 dtls => enabled http2 => enabled json => enabled curl-native => enabled pcre => enabled zlib => 1.2.12 brotli => E16781312/D16781312 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 => Off => Off swoole.display_errors => On => On swoole.use_shortname => On => On swoole.unixsock_buffer_size => 262144 => 262144
Darwin MacBook-Pro-Igor.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64
PHP 8.2.21 (cli) (built: Jul 22 2024 11:20:42) (NTS)
Apple clang version 15.0.0 (clang-1500.3.9.4)