skip to Main Content

I have created a class in AppHelpersIdTransformer
theres just two functions there.

I have registered it in aliases array in my app.php in configapp

'aliases' => Facade::defaultAliases()->merge([
        // 'Example' => AppFacadesExample::class,
        'IdTransformer' => AppHelpersIdTransformer::class,
    ])->toArray(),

then i do, php artisan config:clear and php artisan config:cache

i can successfully access the file, in my code, but the Intelephense cannot find it.
and it is so annoying.
what must i do?

2

Answers


  1. Chosen as BEST ANSWER

    What i did to solve this is,

    I just put this line in the composer.json

    "autoload": {
        "psr-4": {
            ...
            "App\Helpers\": "app/Helpers",
            ...
        }
    },
    

    then i run composer dump-autoload


  2. If you want to use your favorite helper file in Laravel programs, you should put it in the composer.json file and provide autoload, please pay attention to the example below:

    .
    .
    .
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        },
        "files": [
            "app/Helpers/IdTransformer.php"
        ]
    },
    .
    .
    .
    

    Add the following presentation to the ./composer.json file and in the autoload section:

            "files": [
            "app/Helpers/IdTransformer.php"
        ]
    

    At the end type the following command:

    composer update
    

    In any part of your Laravel application, you can use the functions in IdTransformer.php as follows:

    NameFunction();
    

    At the same time, hit the command

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search