KNitinSaini I don't know if it is too late, but I found this topic through search and I think it deserves an answer even if it's old ?
But I'm not sure I understand the question correctly. If that's about implementing a "login with Flarum" features there are plenty of discussions about it.
However for the question "how to get online users (username+avatar) from php ?" there is no current explanation on the forum I believe.
(As of beta 6) You can use other libraries to query the database directly (like PDO or Laravel Query Builder). All you need is in the users table:
username: Username (obviously)
avatar_path: Avatar (need to prepend the public path to your Flarum assets folder), can be null !
last_seen_time: You should do a time diff on your side with a library like Carbon configured with the same time zone as Flarum/the database and query for users whose value is higher than that
The tricky part would be to honor the "do not show online" part, as it is saved sarialized in the preferences column along with the other user's setting.
Maybe this solution would not have applied with the Flarum version of 2016/02... I wasn't there at that time ?