0
votes

I have a custom folder inside the resources folder like this : resources/test_folder/index.php

Now i want to access a helper function inside this index.php.

Getting undefined function error.

Its working fine in the resources/views.Is there any default mapping between the resources/views and helper functions?

Helpers are autoloaded in the composer file like this:

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/Http/GlobalFunctions.php"
        ]
    }

Function inside the helper:

function debug($data = array())
{
    echo '<pre>';
    print_r($data);
    echo '</pre>';
}
1

1 Answers

0
votes

The public/index.php file executes before the composer autoloader is called. You could either include you helper file manuelly on top of the index.php (not recommended) or rewrite your logic to use it after loading the autoloader.

Notice that editing your index.php file is not recommended. You should use your app directory for your logic.