php - Laravel start function not calling from inside a namespace -
so i'm writing laravel 4 app , i've setup namespaces. i'm trying write systemwide functionality can execute anywhere create menus/setup language/currencies etc.
i have directory global called "library" has file called menu.php inside looks follows:
<?php namespace library; use appname\model\menu menumodel; class menu { public static function buildmenu($id = 1) { //retrieve menu $menu = menumodel::getmenu($id); //sort content page $data = $menu->toarray(); print_r($data); } } i attempting call buildmenu function in filters.php file following:
app::before(function($request) { // view::share('menu', library\menu::buildmenu()); }); i class 'library\menu' not found error laravel. i'm presuming lack of knowledge of namespaces clarity appreciated.
did add library path composer.json ?
if not, add autoload > classmap >> app/library
and run artisan dump-autoload
should fine.
Comments
Post a Comment