J
J
JohnDoe0002022-04-07 10:24:32
PHP
JohnDoe000, 2022-04-07 10:24:32

What is the problem of connecting the trait?

src\Controllers\Commands.php:

namespace Project\Controllers;

use Library\SubDir\Traits\Trait;

class Commands
{
    use Trait;

...


autoload_psr4.php:
'Library\\SubDir\\' => array($vendorDir . '/library/name/src'),


Trait.php is located in the external package. /library/name/src/Traits/Trait.php

At the same time, it works inside the external package, and when trying to connect the trait to the project, an error about the trait not found:
Fatal error: Trait "Library\SubDir\Traits\Trait" not found in /project/src/Controllers/Commands.php on line 8


Update:

/library/name/src/Traits/Trait.php:
namespace Library\SubDir\Traits;

use Library\SubDir\Api;

trait Trait
{
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JohnDoe000, 2022-04-07
@JohnDoe000

The problem was in the specifics of the package, where for the trait to work correctly, you need to set certain properties for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question