Accessing assets in PHP

The docs mention to make use of \Roots\asset('images/path.jpg') but the uri is protected and there is no field for url?

What is your question? What problem are you trying to solve?

Whats the best way to access an asset in PHP composers, providers?

“Best” is a very subjective thing that’s heavily dependent on both your situation and your opinion. What have you tried so far, and what went wrong or didn’t meet your needs?

in a php composer I tried the following:

public function asset() {
 return \Roots\asset('images/path.jpg');

However this return several private properties. that were unaccessible, including uri. The url property, which the theme assets section in the docs say to use, wasn’t present.

The docs don’t mention a url property, they mention a URL method:

echo $asset->url();

The Asset class, which is what’s returned by \Roots\asset('path.jpg') has the uri() method, which amounts to the same thing:

The docs do need to be updated, but you can investigate the possibilities of asset usage by examining the Asset class.