I'm trying to build a class with some frequently used functions that I can use from anywhere in my project. I don't know where to build the PHP file with the classes in it or how to recall them... Can anyone help me figure out where all this stuff fits in? THANKS!!!
/App/Http/Helpers/MyClasses.php
<?php
class PopularFunctions {
public function sayhi() {
echo 'hi';
}
}
?>
/App/Http/Controllers/TasksController.php
<?php
namespace App\Http\Controllers;
use App\Http\Helpers\MyClasses;
class TasksController extends Controller {
public function index() {
$myfunctions = new PopularFunctions();
$myfunctions->sayhi();
}
}
This returns: Class 'App\Http\Controllers\PopularFunctions' not found.
appdirectory. There's no real restrictions. If you post your code and structure etc. we might be able to help you pinpoint the problem.Appand is under theappfolder so as long as you follow the standard and place your files underappthey should be picked up. If not trycomposer dump-autoloadto re-create the autoload file