Support the ongoing development of →
IOC Views Blade
Last updated 2 years ago.

Facades are supposed to live in global namespace. Try to use \Ajax::test() instead of Ajax::test in your controller, and see if it works. If it doesn't, your alias is not registering properly.


In my controller it work perfectly in both ways \Ajax::test() and simply Ajax::test() but is not working if I call it from my template file in this way {{ Ajax::test() }} or {!! Ajax::test() !!}

I'm also deleted the cache with php artisan cache command and also force to regenerate the compiled.php file that is inside the /vendor folder..but still nothing.

The alias is registered into the app.php file like any other Facade aliases.

any other ideas?

Last updated 9 years ago.

Right, you should also remove use App\Facades\Ajax\Facade\Ajax; from your controller.

Or, alternatively, try Ajax::test() in php artisan tinker console.


Ok..done already this test using tinker with two different facade defined in the same way..below the result:

Psy Shell v0.4.4 (PHP 5.5.9-1ubuntu4.9 — cli) by Justin Hileman
>>> Currency::test()
hello Currency⏎
=> null
>>> Ajax::test()
PHP Fatal error:  Class 'Ajax' not found in eval()'d code on line 1

both are in app.php aliases and also registered into the FacadeServiceProvider that is loaded into the app.php as showed above.

full FacadeServiceProvider code


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use App\Facades\Currency\Currency;
use App\Repositories\Currency\CurrencyEloquent;
use App\Currency as CurrencyModel;
use App\Facades\Language\Language;
use App\Language as LanguageModel;
use App\Repositories\Language\LanguageEloquent;
use App\Facades\Helper\Helper;
use App\Facades\Ajax\Ajax;

class FacadeServiceProvider extends ServiceProvider {

     * Bootstrap the application services.
     * @return void
    public function boot() {

     * Register the application services.
     * @return void
    public function register() {

        // Repository Facade
        $this->app->bind('currency', function($app) {
            return new Currency(new CurrencyEloquent(new CurrencyModel()), new LanguageEloquent(new LanguageModel()));

        // Language Facade
        $this->app->bind('language', function($app) {
            return new Language();

        // Helper Facade
        $this->app->bind('helper', function($app) {
            return new Helper(

        // Ajax Facade
        $this->app->bind('ajax', function($app) {
            return new Ajax();



Last updated 9 years ago.

Does the log file have a backtrace for the "Class not found" error?


The test :

class AjaxTest extends TestCase{
    //put your code here
    public function tearDown() {
    public function testTest(){
//      \Currency:shouldReceive('test')->withAnyArgs();       // WORK FINE

The trace :

PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Configuration read from /var/www/html/immogobid/phpunit.xml

.PHP Fatal error:  Class 'Ajax' not found in /var/www/html/immogobid/tests/AjaxTest.php on line 24
PHP Fatal error:  Uncaught exception 'Illuminate\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.' in /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Container/Container.php:785
Stack trace:
#0 /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Container/Container.php(656): Illuminate\Container\Container->build('Illuminate\Cont...', Array)
#1 /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(644): Illuminate\Container\Container->make('Illuminate\Cont...', Array)
#2 /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(152): Illuminate\Foundation\Application->make('Illuminate\Cont...')
#3 /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 /var/www/html/immogobid/vendor/laravel/framework/src/Illuminat in /var/www/html/immogobid/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 785

really don't know what to do..I check everything. I understand that for some reason this class is not instantiated by laravel but don't know why...Also look like any other facade I define are not working anymore..I'm gonna try to put the same code in a fresh project and see what happen! I'll let you know.

Last updated 9 years ago.

Ok..same code on different project and it work perfectly! what can I do? I can't rewrite all the code because is a big project...any ideas? thank you all..


Ok..reload all my code from my machine to the server, reset all permission and the problem is fixed! Thank you Xum! Probably there was something missed or some file permissions.

Problem fixed.


Bloody file permissions!

I'm moving from Windows to Mac at the moment and this is a constant issue.

I'm actually looking at going on some kind of network admin course so I can get my head round this once and for all


Sign in to participate in this thread!


Your banner here too?

luca83 luca83 Joined 27 Mar 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.