Issue with Facade and Service Provider in Laravel-4

I am trying to set up a Facade for a custom built class in laravel-4. However, when I try to load my website I get an error which reads

Class 'PlaneSaleing\ResizerServiceProvider' not found

I have followed the tutorial here:

My custom class is called Resizer.php and is saved in laravel\app\library\ and looks like this:


namespace PlaneSaleing;

class Resizer {
    // My custom methods

I have then created a Facade called ResizerFacade.php, saved in the same folder, and it looks like this:


namespace PlaneSaleing\Facades;

use Illuminate\Support\Facades\Facade;

class Resizer extends Facade {

    protected static function getFacadeAccessor() { return 'resizer'; }


Thirdly, I have created a ResizerServiceProvider.php file and saved it in the same folder, which looks like:


namespace PlaneSaleing;

use Illuminate\Support\ServiceProvider;

class ResizerServiceProvider extends ServiceProvider {

    public function register()
        // Register 'resizer' instance container to our UnderlyingClass object
        $this->app['resizer'] = $this->app->share(function($app)
            return new Resizer;

        // Shortcut so developers don't need to add an Alias in app/config/app.php
            $loader = AliasLoader::getInstance();
            $loader->alias('Resizer', 'PlaneSaleing\Facades\Resizer');

Finally, I have added the following line to the 'providers' => array (...) in laravel/config/app.php file


Any help, much appreciated


You have to add app/library to you composer autoload path, then regenerate autoloader with artisan dump-auto.

The second error you're getting (Class 'PlaneSaleing\AliasLoader' not found) is because the class ResizerServiceProvider is in the PlaneSaleing namespace and this class try to call AliasLoader which is not in the same namespace.

You just have to add a \ in front of AliasLoader to specify that it's in the main namespace instead of the current namespace.

Need Your Help

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.