Not possible to use another Class in Scriptcase?

I have a fully working PHP application that uses an Amazon Class provided by Amazon.

I am trying to bring this code into Scriptcase as a blank application, but it is not working as it calls a “use” statement… and I think thats failing due to how Scriptcase itself is running my onExecute event in its own class.

The error I get is:

Parse error: syntax error, unexpected ‘use’ (T_USE) in #############

Is there any way I can bring this code into Scripcase? Ive been digging around in the forum and think perhaps a work around would be to include my working code as a Library? Then create an app that redirects to that library code?

Im not sure how the external libraries work… the description in the documentation doesn’t really help me understand.

If anyone could please offer advice it would be most appreciated.

Thank you!

during my transition to scriptcase, I used the good old Include statement, declaring it at the beginning of the php procedure in a blank just test it, then integrate it into a php function, etc.

Thank you for your response… I am sorry but I am not following you. You are saying I should include my .PHP file in my blank application in the “onExecute” event?
What I am trying to achieve is the ability to publish my application on any host where all required files are included in the publish. I dont want to manually have to move files to the host.

I have been able to include an external library of my files… then redirect to those .PHP files in the “onExecute” of the blank application.

This is a partial solution since at least my code is in Scriptcase this way and will be deployed on publish…

The include_once statement should include your library code, at least it’s how I used to do that. ‘use’ is used to allocate name spaces. But I don’t see why a blank application should include that. Are you sure you haven’t made a typo in your source code?

use doesn’t work within a function. Instead of using “use” like
use namespace;
try the following:
$obj = new namespace\Another;

See also http://php.net/manual/en/language.namespaces.importing.php

gentlemen, I’m sorry, my translation into English is not always wise, I’m talking about testing in a blank form, not using it.
Nicolas

“Use” can be only used in the first lines of the PHP code. The code you put on a blank app is somewhere in the middle of the file, you can’t do it this way.
On your app, import AWS library. You can do it onInit and save the object on a var to reuse it in other events, or do it in one place if only needed in one event, it all depends on your needs

sc_include_library("prj", "aws", "aws-autoloader.php", true, true);

Now you can use it, for example, on an internal libr this way:

function createS3Client(){
    $s3 = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'us-west-2',
        'credentials' => [
            'key'    => 'yourkey',
            'secret' => 'yoursecretpass',
        ]
    ]);
    return $s3;
}


In this code an S3Client object is returned to use it.

$s3Client = createS3Client();

delete_attachment_s3($s3Client, {glo_filedata}[0][1], {glo_filedata}[0][0]);