Smarter way to use "use" statement in SC?

When trying to use an external library with “use” keyword in SC such as http://opensource.box.com/spout/getting-started/#basic-usage, after using sc_include_library macro, this is what I have to do to get it to work:

  1. replace the require_once and use statements with sc_include_library

  2. use the full namespace when the classes are instantiated. So for the link above,

    $reader = ReaderFactory::create(Type::XLSX);

changes to something like

 $reader = Spout\Reader\ReaderFactory::create(Spout\Common\Type::XLSX);

Anything else I try gives an error.

This means I lose the convenience “use” offers.

Is there anyway to have the “use” keyword or some other short-hand route with SC?

I would be happy with a guide for how to convert the statements in a library that used namespaces to working within Scriptcase.

Could you provide a step by step with examples?

Thanks!

try this:
// remark use statement
//use Spout\Reader\ReaderFactory;
$reader = new Spout\Reader\ReaderFactory();

1 Like