PHP Include other code, How!?!?

Hi all!

I’m currently experiencing an issue where I need to use some PHP code outside of Dreamfactory.
I am currently unable to do so as I keep receiving this error
[2018-07-11 22:22:53] local.ERROR: Class 'SourceQuery' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'SourceQuery' not found at C:\\Bitnami\\dreamfactory-2.12.0-1\\apps\\dreamfactory\\htdocs\\vendor\\dreamfactory\\df-script\\src\\Engines\\Php.php(49) : eval()'d code:34)"}

This is part of the code experiencing the issues: https://i.Alexr03.com/kid39sG88284.png

How would I use the require and use that class as so I have heard Dreamfactory will not allow you to use require or use statements.

Many Thanks!

Hello,

The Path to your script may wrong, I have a external file to my scripts and have to put the correct path to get to work.

I put my file here:
.../dreamfactory/storage/scripting/myscripts.inc.php

and in the dreamfactory put:
include(dirname(dirname(__ FILE__))."/../../../../storage/scripting/myscripts.inc.php");

Your can log the path and try until get the correct path to your file.

Regards,
LBat

Just to add to this discussion:

You cannot use use or require as per our docs:

Including Other Scripts
Currently, PHP scripts can not directly include other PHP code via require() methods or use statements as you normally would. However, DreamFactory can access any other code installed in the system by using fully qualified name-spaced class names.

The best way to bring in libraries is to use composer require on the package, and that will make it accessible via the code installed in the system by using fully qualified name-spaced class names.

For instance:

For example, run:

$ composer require abraham/twitteroauth

Then in your script reference $connection = new \Abraham\TwitterOAuth\TwitterOAuth("...

CloudApp

BTW, here is a great tutorial to deploy custom scripts in DreamFactory:
http://www.devops-blog.net/dreamfactory/managing-and-deploying-custom-php-services-in-dreamfactory