0

OK, so I am trying to create a working Facade for the Resizer bundle for Laravel 3 (https://github.com/maikeldaloo/Resizer).

So far I have:

  • Created a "Resizer.php" file with the code from the Reszier bundle and added the namespace BARThompson\Planesaleing;
  • Created a "ResizerFacade.php" the contents of which are contained at the bottom of this post;
  • Created a "ResizerServiceProvider.php", the contents of which are contained at the bottom of this post;
  • These three files are all saved in: app\library\;
  • Added an autoloader to \app\config\app.php under the 'providers' => array which reads:

    'BARThompson\Planesaleing\ResizerServiceProvider',

  • Added an alias to \app\config\app.php under the 'aliases' => array which reads:

    'Resizer' => 'BARThompson\Planesaleing\Resizer',

  • Added the following directory to the autoload classmap in composer.json:

    "app/library"

However, I can load the website successfully, but when I call Resizer::open, I get the following error:

Class 'BARThompson\Planesaleing\Config' not found 

I am getting confused with namespaces. I havent used them anywhere else in my app, but as I followed a tutorial which used them (http://fideloper.com/create-facade-laravel-4) I have used them in my implementation without fulling understanding them.

Can anyone explain where I am going wrong?

ResizerFacade.php:

<?php

namespace BARThompson\Planesaleing\Facades;

use Illuminate\Support\Facades\Facade;

class Resizer extends Facade {

    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor() { return 'resizer'; }

}

ResizerServiceProvicer.php:

<?php

namespace BARThompson\Planesaleing;

use Illuminate\Support\ServiceProvider;

class ResizerServiceProvider extends ServiceProvider {

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        // Register 'resizer' instance container to our UnderlyingClass object
        $this->app['resizer'] = $this->app->share(function($app)
        {
            return new BARThompson\Planesaleing\Resizer;
        });
    }
}
Ben Thompson
  • 4,743
  • 7
  • 35
  • 52
  • Im sorry but are you trying to use this laravel 3 Resizer , i mean you want to make it work for laravel 4? ,because there are better options and easier to use. – Mostafa Elgaafary Aug 23 '13 at 18:02
  • Yes - I was trying to convert a laravel 3 bundle into a laravel 4 class and facade. If you have an easier way of implementing it - Im all ears. As as aside, I would also like to be able to write my own classes and access them by using the static syntax that laravel makes available using Facades (MyClass::MyFunciton) - so this isnt a completey wasted effort even if I abandon it! – Ben Thompson Aug 23 '13 at 21:25
  • Mostafa - what else would you recommend for a resizing package in laravel 4? – Ben Thompson Aug 24 '13 at 09:43
  • Sorry for the late reply , http://intervention.olivervogel.net/image/getting_started/laravel , I'm currently using this one , its easy and quite good.. – Mostafa Elgaafary Aug 24 '13 at 10:24

0 Answers0