Dusk and Production (with Dusk disabled)

Posted: 2018-02-05 19:04:21
In DatabaseServiceProvider.php line 78:

  Class 'Faker\Factory' not found

I had a ton if issues getting dusk on production, especially since production would run

composer install --no-dev --prefer-dist --no-interaction

To get around this issue I had to do a few things

One, if you are stuck and can not even run php artisan on the server:

rm bootstrap/cache/services.php
rm bootstrap/cache/packages.php

Two, turn off auto discovery for Dusk and just add it to the app/Providers/AppServiceProvider.php

    public function register()
    {
        if ($this->app->environment('local', 'testing')) {
            $this->app->register(DuskServiceProvider::class);
        }
    }

and in composer.json

    "extra": {
        "laravel": {
            "dont-discover": [
                "laravel/dusk"
            ]
        }
    },

Now if you still get a Faker error as I was let's move that up in our composer file:

        "fzaninotto/faker": "^1.7"
    },
    "require-dev": {
        "mockery/mockery": "0.9.*",

Okay so now you are ready.

As far as Travis goes I run this on the before_deploy

before_deploy:
- rm .env
- export APP_ENV=production
- php artisan clear-compiled
- composer install --no-dev --prefer-dist --no-interaction

And prevents the error while at the same time cleanup up my code before CodeDeploy bundles it up for deployment.