0

In my PagesRepository.php I created a function

use Ramsey\Uuid\Uuid;


  function generateUid()
  {
     return Uuid::uuid4();
  }

Now I want to use this function in my PagesController.php:

$unique_id = generateUid();

But I get the error message:

Attempted to call function "generateUid" from namespace "App\Controller".

1 Answer 1

2

you may use the class name for static method call:

namespace App\Controller;

use App\Repository\PagesRepository;

class PagesController
{
    // ...

    $unique_id = PagesRepository::generateUid();

    // ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.