Can't use public_path() in a helper file Laravel 5.4 -
i have helper.php file in app/helpers directory. included file in composer.json:
... "files": [ "app/helpers/helpers.php" ] ... helper works fine can't use public_path() method there. need include file (please don't ask me why because it's old code don't need rewrite). have following:
require_once public_path() . '/appadmin/bootstrap.php'; i know default laravel looks in /public/ folder faced problem. if need perform composer update have use public/appadmin/bootstrap.php path in helper.php, after performing have change path /appadmin/bootstrap.php correct work. that's why decide use public_path() method receive correct path both cases. , if use i'm getting error:
generating optimized autoload files > illuminate\foundation\composerscripts::postupdate script illuminate\foundation\composerscripts::postupdate handling post-update-cmd event terminated exception [reflectionexception] class path.public not exist thank's in advance!
have tried updating app current revision?
there files in framework need updated.
check out config files, bootstrap files, server.php , start files here https://github.com/laravel/laravel/tree/develop.
you open index.php (in public directory) , change:
$app = require_once __dir__.'/../bootstrap/app.php'; // set public path directory $app->bind('path.public', function() { return __dir__; }); now dont need change public path when public directory has changed.
Comments
Post a Comment