Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,.

like image 603
AbingPj Avatar asked May 19 '20 02:05

AbingPj


Video Answer


1 Answers

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

like image 155
AbingPj Avatar answered Oct 12 '22 09:10

AbingPj