Have you named your class that ? Just give it a look.
Yes, I already do. Those class is working just fine in Laravel 4.
BTW nice Bioman avatar :)
Are you properly importing the class ? I assume you have put that class in global namespace.
L5 uses PSR-4 autoloading, try keeping your classes in namespaced.
... tX !
Here are my steps :
The content for app/library/myFunctions.php is below :
<?php namespace App\library {
class myFunctions {
public function is_ok() {
return 'myFunction is OK';
}
}
}
?>
At resources/views/test.blade.php , I added :
<?php
$FmyFunctions1 = new myFunctions;
$is_ok = ($FmyFunctions1->is_ok());
?>
Then at composer.json within "autoload": I added :
"files": [
"app/library/myFunctions.php"
],
And within app\Http\Controllers\HomeController.php at public index() I add :
return view('test');
But it always give me error messages regarding 'myFunctions' as below :
Whoops, looks like something went wrong. 1/1 FatalErrorException in xxxx line 7: Class 'myFunctions' not found in xxxx line 7 at HandleExceptions->handleShutdown()
BTW already answered at : https://laracasts.com/discuss/channels/requests/l5-how-to-add-my-own-custom-class Thanks for helping me :)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community