joshrps / laravel-shopify-API-wrapper

Interface designed for Shopify apps created with Laravel
MIT License
93 stars 48 forks source link

Class not found error when initializing app #11

Closed Sam-R closed 9 years ago

Sam-R commented 9 years ago

Hello,

I'm having problems when trying to initialize the the Shopify API:

Class 'App\Http\Controllers\App' not found

in app/Http/Controllers/ShopifyController.php i have an index function:

    public function index()
    {
        $sh = App::make('ShopifyAPI');
    }

This controller is loading, and can run other code, but the App:make('ShopifyAPI') line is causing the error.

My config/app.php has the following in it:

        /*
         * Shopify service provider
         */
         'RocketCode\Shopify\ShopifyServiceProvider',

(Note: added quote marks which were not listed in your readme, but I believe they're required)

and composer has the following requirements:

    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "~5.0",
        "rocket-code/shopify": "^2.0"
    },

I've run composer update and the /vendor/rocket-code folder has been added.

Is there something I'm missing that is required to get this working?

joshrps commented 9 years ago

Quotation marks are required - I documented the actual element to add to the array, not the code you add.

That looks like a Laravel 5 namespaced-controller issue. I'm not all that familiar with L5, so I'm going to list a few things to try and hopefully one will work! Try them in order-

// 1
public function index()
{
    $sh = \App::make('ShopifyAPI');
}

// 2
public function index(\RocketCode\Shopify\API $sh)
{
    // $sh will already be instantiated
}

// 3
public function index()
{
    $sh = new \RocketCode\Shopify\API;
}
Sam-R commented 9 years ago

I'm just starting out with Laravel myself, there's a lot to take in.

In actual fact, it appears all three work as solutions (at least I'm not getting an error any more).

Thanks for your help!