Ok, in laravel 4, if I want to add my own custom class, for example: library \ myFunction.php, follow these steps:
- add " myFunctions.php " to the application /library/myFunctiosn.php
- app / start / global.php , in ClassLoader :: addDirectories (array ( ), I add app_path (). '/ library',
- And to name it in my view with blades, I add the following codes
<?php $FmyFunctions1 = new myFunctions; $is_ok1=($FmyFunctions1->is_ok()); ?>
- The contents of app / library / myFunctions.php:
<?php namespace App\library { class myFunctions { public function is_ok() { return 'myFunction is OK'; } } } ?>
And it works.
But how to do it in Laravel 5 ???
PS: I read. What are the best practices and best places for laravel 4 helpers or core functions?
And tried to add "app / library /" to the autoload array and run the composer dum-autoload , but it continues to give me error:
FatalErrorException on line xxxx xx: class 'myFunctions' not found
I am also trying to use:
composer update composer dump-autoload php artisan dump php artisan clear-compiled php artisan dump-autoload php artisan optimize php artisan route:clear php artisan route:scan php artisan route:list
But still does not work ...
source share