-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
using HTTP\Request instance to pull ip address instead of $_SERVER['REMOTE_ADDR'] #1180
using HTTP\Request instance to pull ip address instead of $_SERVER['REMOTE_ADDR'] #1180
Conversation
i guess its not necessary to create a new config instance each time -> would use config( App::class ) for the global instance. I also think the same should be possible for HTTP/Request instances or are there reasons not to do so? |
using |
? its the same as you do, but no new instance ( ok you will have to do config( \Config\App::class ), sry for forgetting namespace ) |
What I meant is, using new instance in class property is not doable in php, eg; class App
{
public $ip = (new Request())->getIpAddress();
} The alternative is by define as constant |
It's better to use a service for that instead of creating a new instance every time:
Or, better yet, have the Request object passed into the class' constructor and saved as a class property.... |
08863a6
to
18161d2
Compare
I've updated to set |
@lonnieezell I am good with this. Ok to merge? |
That's not exactly what I meant. The preferred way to do this is to grab a copy of the IP address in the services class, where the driver is instantiated and pass it in the constructor of the driver. |
dc57094
to
d063916
Compare
@lonnieezell implemented |
a6a4be9
to
5192e31
Compare
as all handlers has ipAddress property, I add ipAddress property to BaseHandler with inject in 2nd parameter. |
Looks good. Thanks! |
No description provided.