简体   繁体   中英

"Class" not found

Loaded the Natnanmac GUID generator from GitHub for Laravel in a 5.2 project.

I can call it from within a Blade view like:

<?php $myguid = GUID::generate(); ?>
{!! $myguid !!}<br />

and it generates a GUID just fine. If I try to use it within a controller like:

public function generateGUID()
{
    $newguid = GUID::generate();
}

it throws a

FatalErrorException in MainController.php line 86:
Class 'App\Http\Controllers\GUID' not found

I have a feeling it is a use clause I am missing, but have NO idea what.

Any thoughts?

Is trying to find the class inside the App\\Http\\Controllers namespace. Try

public function generateGUID()
{
    $newguid = \GUID::generate();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM