Search code examples
laravellumen

Getting undefined function public_path() error in lumen


I am trying to upload image in lumen. I got some examples and when i tried to implement it, got below error <!-- Call to undefined function App\Http\Controllers\public_path() (500 Internal Server Error) -->

Just want to confirm is this function got changed or do i need to include helper file.

Thanks


Solution

  • Many of Laravel helpers don't exist in Lumen including public_path() and storage_path() you can include both methods in your Lumen project by creating a helpers.php file in your App directory or wherever you want and autoload that file in your composer.json files like so

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

    Don't forget to run composer dump-autoload