-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolves Laravel Error: Class UDPSocket cannot extend final class Socket #26
base: master
Are you sure you want to change the base?
Conversation
Renamed Socket to scSocket to avoid conflict with Laravel framework built in class name.
Renamed Socket to scSocket to avoid conflict with Laravel framework built in class name.
Renamed Socket to scSocket to avoid conflict with Laravel framework built in class name.
This can’t be a thing. The library operates in its own namespace. If you’re using Composer and its autoloader you shouldn’t be having any issues. The Socket class here is abstract, not final. It sounds like you’re pulling in the files manually and removing or mixing namespaces oddly causing conflicts with an existing finalised Socket class. Seems unlikely to be caused by this project. |
So this came about when I restored an old project which worked quite a few years ago. I installed the latest laravel, php and condenser library. When i first tested it, I set it up in composer and composer was generating the exact same error message. E.g. when I typed the command in the debian shell 'composer update'. So then I temporarily removed the condenser autoload entries - 'files' and 'psr-4', which got past the composer error. But then when I tried to run a server query via my php code I got the error again. I thought the issue was related to laravel, like it somehow loaded another socket class that conflicted. Because it was saying the class was 'final', but when I checked it the condenser class is not set as 'final'. That gave me the idea to use a different class name, which solved it. I am not an expert on these things, but I got it working so got inspired to do a pull request. So I think Laravel is the cause but I understand if you guys decide not to use the changes. I guess If someone finds my fork from a google search, then that should be enough. cheers |
also, as you mention, technically what you said was correct. I was pulling in the files manually. I was adding the composer parts myself to an already populated comopser file (which gets filled by laravel). Im then calling the extension using a Controller. Using commands like: |
For Composer dependencies you shouldn't be touching those yourself. Especially entries in lockfiles or the autoloader. The Composer errors are probably dependency / conflicts? in which case you do need to resolve those on your own. I doubt Laravel has an odd setup for Composer, so getting this library should be a matter of |
I replied to you before with 2 messages at once, I feel you may have missed the first one? |
I imported Condenser into a Laravel Framework 10 project and I got the error "Class UDPSocket cannot extend final class Socket". I troubleshooted it for a few hours and then realized that it might be a name conflict. So first I changed UDPSocket.php and changed:
class UDPSocket extends Socket {
to: class UDPSocket extends scSocket {
Then in socket.php I changed:
abstract class Socket {
to: abstract class scSocket {
Then TCPSocket.php I changed:
class TCPSocket extends Socket {
to: class TCPSocket extends scSocket {
This worked!
Also to get it working on Laravel 10 with Php 8 I also modified my composer.json with different versions:
"require": {
"monolog/monolog": "~3.5"
"require-dev": {
"phpunit/phpunit": "^10.1",
and removed phpdocumentor, not sure what that breaks?
Note, I didn't modify the composer.json file in the pull request.