Search code examples
phplaravelhtml-emaillumen

How to call app_path() function in laravel lumen?


How to call app_path() function or to make a Helper for app_path() function in Laravel lumen? I need it because i got this error,.. "Call to undefined function app_path()" It has a package here for that,.. but is not supported for Laravel Lumen version 7 Anyone knows hot to make it?

enter image description here

thanks,.. sorry for my english,.


Solution

  • I fixed the error now,. i added this to my app/Helpers/helpers.php file.

    <?php
    
    if (!function_exists('app_path')) {
        /**
         * Get the path to the application folder.
         *
         * @param  string $path
         * @return string
         */
        function app_path($path = '')
        {
            return app('path') . ($path ? DIRECTORY_SEPARATOR . $path : $path);
        }
    }
    

    for the other config. dont forget to add this in composer.json file:

    "autoload": {
            "files": [
                "app/Helpers/helpers.php"
            ]
        },
    
    

    and run this command: composer dump-autoload