lundi 21 août 2017

Can't use public_path() in a helper file Laravel 5.3

I have a helper.php file in app/Helpers directory. I included that file in composer.json:

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

Helper works fine but I can't use public_path() method there. I need to include another file (please don't ask me why because it's old code that I don't need to rewrite). So I have the following:

require_once public_path() . '/appadmin/bootstrap.php';

I know that by default Laravel looks in /public/ folder but I faced with a problem. If I need to perform composer update I have to use public/appadmin/bootstrap.php path in helper.php, but after performing I have to change that path to /appadmin/bootstrap.php for correct work. That's why I decide to use piblic_path() method to receive correct path for both cases. And if I use it I'm getting an error:

 Generating optimized autoload files
    > Illuminate\Foundation\ComposerScripts::postUpdate
    Script Illuminate\Foundation\ComposerScripts::postUpdate handling
 the post-update-cmd event terminated with an exception


      [ReflectionException]             
      Class path.public does not exist  

Thank's in advance!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2wwbHqb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire