I am struggling to include an external class the Laravel way. I have a round-about way of doing this right now..
First I have a file app/Http/Requests/Moneris/Moneris.php with the following content:
<?php
namespace App\Http\Requests\Moneris;
class mpgTransaction {
/* stuff */
}
Then in app/Http/Controllers/MyController.php, I have the following content:
<?php
namespace App\Http\Controllers;
require_once(str_replace("/MyController.php","/",__FILE__).'../Requests/Moneris/Moneris.php');
use App\Http\Requests\Moneris as mn;
class MyController extends Controller
{
public function index()
{
$mpg = new mn\mpgTransaction();
}
}
And this works fine. But if I change the content of MyController.php to:
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Moneris\Moneris;
class MyController extends Controller
{
public function index()
{
$mpg = new mpgTransaction();
}
}
I get a 500 internal server error and the logs say mpgTransaction class could not be found. What am I doing wrong?