Utility class structure, include, use and namespaces

Permalink
I want to write a utility class with a bunch of static methods and make that class available to my block controllers of a package.

Where do I store the utility class file in a package ?

How do I namespace the utility class ?

How do I include and use the utility class in my controllers ?

Sorry if some of this is basic PHP, I have a Java background and I am fairly new to PHP.

Thanks,

Warren Bell

warish
 
WillemAnchor replied on at Permalink Reply
WillemAnchor
- Where do I store the utility class file in a package ?
packages/yourpackage/src/Util.php
might work with util.php, but not sure about that

- How do I namespace the utility class ?
namespace Concrete\Package\Yourpackage\Src;
class Util {
public function hello() {
return 'world';
}

- How do I include and use the utility class in my controllers ?
use Concrete\Package\Yourpackage\Src\Util as Util;
...
echo Util::hello();
warish replied on at Permalink Reply
warish
Any significance to putting it in a src directory, meaning is that special to C5 ?