php “use” not working in template [closed]

Quoting this answer, which came up when I searched for your error message: (emphasis mine)

You cannot use “use” where you are using it.

The “use” keyword is either in front of a class definition to import other classes/interfaces/traits into it’s own namespace, or it is inside the class (but not inside a method) to add traits to the class.

The use has to be outside of the function I presume you are calling it in. Something like this should work

<?php

use \Aws\Polly\PollyClient;

// some code

function myfunc() {
    require_once ('/polly/aws-autoloader.php');
    // rest of the code
}

It should be no problem that you require the autoloader after the use keyword. After all, it only expands PollyClient to \Aws\Polly\PollyClient when you use it in the code.