1

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 public_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!

Rahul
  • 18,271
  • 7
  • 41
  • 60
Andrey P.
  • 139
  • 2
  • 14

1 Answers1

0

Have you tried updating your app to the current revision?

There are some files in the framework itself who need to be updated.

Check out the config files, the bootstrap files, server.php and the start files here https://github.com/laravel/laravel/tree/develop.

You could open index.php (in your public directory) and change:

$app = require_once __DIR__.'/../bootstrap/app.php';

// set the public path to this directory
$app->bind('path.public', function() {
    return __DIR__;
});

Now you dont need to change your public path when your public directory has changed.

l.g.karolos
  • 1,131
  • 1
  • 10
  • 25