nova-framework / framework

Demo application using Nova - this is an extensive playground, use "app" repository for real applications.
http://novaframework.com/
MIT License
418 stars 210 forks source link

Calling classes #2121

Closed JohnRamon closed 4 years ago

JohnRamon commented 4 years ago

If I run this in one of my controller pages.

$im = new Imagick('image.png');

I get

Class 'Controllers\Imagick' not found

LuckyCyborg commented 4 years ago

This is not really an issue of Nova Framework, but this way works the PHP when are used namespaces.

How the Nova applications usually uses the App\\ namespace for the main app tree, is expected to use the full namespace of a class when calling it. For example

use Imagick; // this class lives in the anonymous namespace.

// then later:
$im = new Imagick('image.png');

Another way is to use directly the full defined class name, like:

$im = new \Imagick('image.png');

Please note the \ character which defines the full namespace of this class.

How this "issue" is basically a lack of knowledge of general OOP under PHP, I am so sorry but I will close this issue as there's nothing to fix. :smirk: