Load non-namespaced library

Permalink 1 user found helpful
Currently I am working on upgrading my own made packages to concrete 5.7. I am using an external library in one of my models, but cant figure out how to load the class from that library using the new namespaced design.

I tried to just include the file containing the class above my model class and then use it, but this results in a Class 'Concrete\Package\<packagename>\Models\classname' not found error:

namespace Concrete\Package\<packagename>\Models;
defined('C5_EXECUTE') or die("Access Denied.");
use \Concrete\Core\Legacy\Model;
require <path to file containing class>;
class MyModel extends Model{
    function myFunction(){
        $newInstance = new classname();
    }
}



What is the (best) way to use an external class in my code?

 
rklomp replied on at Permalink Reply
Solved by using
$newInstance = new \classname();


Mind the backslash. This creates an object of the class defined in global scope.

:)