I am getting a namespacing issue when trying to extend the Response facade in Laravel 5. I have created a new folder tree under the app
directory called Extensions\Facades
. In this folder I have a file called AjaxResponse.php
which has the following contents:
<?php namespace App\Extensions\Facades;
use Illuminate\Support\Facades\Response;
class AjaxResponse extends Response{
public static function send($code,$body,$http_code=200){
parent::json( array(
'status'=>(string)$code,
'body' =>$body
) )->setStatusCode($http_code)->send();
exit();
}
}
I am registering this as a service provider in config/app.php
like I understand I am supposed to:
providers=[
//..normal stuff
'App\Extensions\Facades\AjaxResponse',
]
And this is throwing the normal namespace error of class not found:
FatalErrorException in ProviderRepository.php line 150:
Class 'App\Extensions\Facades\AjaxResponse' not found
Can anyone shed any light on why the class is not found?