Laravel custom helper class not found -


i've created custom php helper class use in laravel 4 project.

the sashelper.php file in app/libraries/elf/sas , after adding libraries composer.json file i've done composer dumpautoload.

autload_classmap (last line only):

'elf\\sas\\sashelper' => $basedir . '/app/libraries/elf/sas/sashelper.php', 

helper class (simplified brevity):

<?php  namespace elf\sas;  class sashelper { static public function supportinttotext($status) {         return 'supported'; }  static public function lictypetotext($lic) {         return '32-bit'; } } 

when attempt call either static method controller:

$statustext = sashelper::supportinttotext($client->supportstatus); 

at point fiddler reporting:
"class sashelper not found."

did try global.php? doesn't need composer dump-autoload, , loads class – trying tobemyself rahul

i've tried it: (app_path() .'/libraries' , app_path() .'/libraries/elf/sas') classloader::adddirectories didn't make difference. – steb

try commenting namespace line – trying tobemyself rahul

@tryingtobemyselfrahul - worked (added /libraries/elf/sas path)! if add answer i'll accept, curious, idea why worked (or why other 1 didn't)? – steb

best guess when use namespace available namespace, when directly using class name throwing error.

so either don't use namespace or add namespace before class name, in example $statustext = elf\sas\sashelper::supportinttotext($client->supportstatus); should work


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -