Welcome Guest, Not a member yet? Register   Sign In
Could CodeIgniter\Debug\ExceptionHandler be more object oriented and less coupled?
#1

My projects run codeigniter with Swoole, which is a 'Resident Process Mode'. That means 'public coupled'  is strictly restricted. For example, when using services, I can't set the param $getShared to true because the static properties like $instances will be shared among all requests, and the coroutine mechanism will cause to conflicts. So I've paid some time to modify codeigniter to adapt to swoole. If you ask me: why not use some framework developed for swoole? Because I like 'Do It Yourself' and codeigniter's manual is very friendly to fresh man like me.

Recently, after learned a little about Architecture Design, I found that some modification I did may originally can be avoided. So those are my first group of bafflement:
1. Now that $request and $response are required in BaseExceptionHandler's abstract method 'handle', why not use them in the method 'render'? For example, set them as properties of BaseExceptionHandler rather than ExceptionHandler, or just pass them to 'render'. After then, we can respond to client by the response instance instead of 'echo', which can only output contents to 'stdout'. What's more, call static method to get request instance and response instance in view file error_exception.php is 'public coupled', pass them to this file may be less coupled?
2. Now that we've got response instance in method 'handle', why not use it to check if headers have been sent or not and send headers, but call Process-oriented functions headers_sent and header?
3. Is there some other way to end the current request safely except for call exit after view be rendered?
Thank you for any response!

I'm a Chinese with broken English, if any inappropriate diction is used, apologize !
If anyone want my modified code to adapt to Swoole, I'm glad to share with you by free!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB