websavers Posted Friday at 07:06 PM Share Posted Friday at 07:06 PM Am I just using the classdoc wrong, or is it inadequate for most use cases? Classdoc being here: https://classdocs.whmcs.com/8.13/ Normally I'd use $_SESSSION['uid'] to access a user session, but then I randomly see this here in the community: use WHMCS\Session; Session::get('uid') This feels like the 'right' way to be doing things, but then I go to look it up in the classdoc linked above, and the Session class is nowhere to be found. Then I see Authentication\CurrentUser in the ClassDoc, which allows me to get the current user as an object like this: $user = CurrentUser::user(); But then the classdoc provides no indication as to how to obtain that User ID. You'd think it would be something like one of these: $user->id; $user->getId(); But there's nothing under WHMCS\User and WHMCS\User\Client shows neither an ID property nor a getId() method. Are we not really meant to utilize the classdoc because nobody at WHMCS maintains it? Or am I missing ways of finding this data? 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted Friday at 08:57 PM Share Posted Friday at 08:57 PM Take a look at your /vendor/whmcs/whmcs-foundation/lib/ folder. Every single one of those files contains a class built for WHMCS. Only a fraction of those classes have made it into the classdocs. In your case, Session::get('uid') and $_SESSION['uid'] basically does the same. When you call Session::get, it just returns $_SESSION[$key] - and returns false if it doesn't exist. It's just a small helper function. There's a lot of useful classes in WHMCS that isn't documented. You can do something like this to get a list of all methods provided by a given class, along with the parameters needed: <?php include __DIR__.'/init.php'; $reflectionClass = new ReflectionClass('WHMCS\Session'); $methods = $reflectionClass->getMethods(); foreach ($methods as $method) { echo "Method: " . $method->getName() . "\n"; echo "Parameters:\n"; foreach ($method->getParameters() as $param) { echo "- " . $param->getName(); if ($param->isOptional()) { echo " (Optional)"; } echo "\n"; } echo "\n"; } 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Support Manager WHMCS John Posted 23 hours ago WHMCS Support Manager Share Posted 23 hours ago Hi there, The classdocs are automatically generated when a new release is published, so they are always up-to-date. All classes intended for public use are documented at https://classdocs.whmcs.com Not all classes are documented, this is intentional. For example a class may not be documented if the functionality is not intended to be extended, a work in progress, or potentially subject to breaking changes in future. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.