0
votes

I have a custom Laravel module I wrote that i'm including it in my app.php like so:

    'providers' => array(
        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        'My\Custom\Provider'
    );

Everytime I run a composer update its stalls saying that my class in unavailable:

Error Output: PHP Fatal error:  Class My\Custom\Provider  not found in ProviderRepository.php on line 157

There must be a way to have my provider in the app config, and still be able to run composer update, otherwise its really difficult to auto-deploy my code?

edit What I find myself doing now is commenting the provider from app.php, running composer update, then re-enabling the provider and everything runs fine.

edit Here is my bootstrap/start.php environments

$env = $app->detectEnvironment(array(
    // Dev environments
    'dev' => array('dev.xxx.com'),

    // Live server catch
    'live'  => array('live.xxx.com'),

    // EU Server catch
    'eu.west.1.live' => array('eu-west-1.xxx.com'),

    // US server catch
    'us.west.1.live' => array('us-west-1.xxx.com'),

    // Local test environments
    'chris' => array('outrunthewolf-MacBook-Air', 'e7180623aa2e', 'precise64'),

    // Local catch
    'dev' => array('*')
));

And my autoload from composer

    "autoload": {
    "classmap": [
        "app/commands",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests"
    ],
    "psr-4": {
        "": "app/controllers/",
        "": "app/libraries/",
        "Model\\": "app/models/"
    }
},
1
Are you absolutely 100% sure you don't have a typo in the provider name and that the namespace is correct (maybe even a missing CamelCase-uppercase letter)?Quasdunk
Yes. Just double checked.outrunthewolf
Ok, do you have multiple environments set up? Make sure that your provider is present in all of them. I remember a weird little bug in L4.2 where my environment specific files were not merged correctly with the master file (only concerning nested arrays like the providers), so I copy-pasted all providers and facades to each environment specific file. I don't know if the problem still exists, but maybe you could give it a shot.Quasdunk
And if it's a dev-dependency and you don't want it in your production environment, try running composer install --no-dev --no-scripts and php artisan optimize --env="production" and php artisan migrate --force --env="production" on your production end.Quasdunk
Added the provider to all the app configs, but that didn't solve anything. I do want it in my production environment though.outrunthewolf

1 Answers

0
votes

I would like to suggest some ways to solve this. 1. Please make sure there is no typo in the provider name and that the namespace is correct as suggested by "Quasdunk" in comments. 2. If composer is install on your machine then please execute below command:

composer dump-autoload  

It will auto load your all classes. May be it will helps you.