mpociot / laravel-test-factory-helper

Generate Laravel test factories from your existing models
936 stars 87 forks source link

Installation fails with an error #1

Closed nunomira closed 8 years ago

nunomira commented 8 years ago

I have tried to install this package (on a fresh Laravel 5.2.27 installation) using composer require, but I get an error:

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider' not found

Script php artisan optimize handling the post-update-cmd event returned with an error

Installation failed, reverting ./composer.json to its original content.

[RuntimeException]
Error Output:

the same happens when I run php artisan test-factory-helper:generate

[Symfony\Component\Debug\Exception\FatalErrorException]

Class 'Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider' not found
ghost commented 8 years ago

Try adding the service provider to app.php after installing the package. I think Laravel under the hood runs clear-compiled.

nunomira commented 8 years ago

Hi, thanks. I have added it: Mpociot\LaravelTestFactoryHelper\TestFactoryHelperServiceProvider::class,

If I remove it, a different error is received:

[Symfony\Component\Console\Exception\CommandNotFoundException]

There are no commands defined in the "test-factory-helper" namespace.
ghost commented 8 years ago

Of course the command won't work if you don't include the provider.

Try this if you haven't already.

Comment out or remove the provider from the app.php file Composer update to pull down the package Add the provider to app.php Run composer dumpautoload -o just to be sure.

nunomira commented 8 years ago

No luck... All the same. I have even tried to do it from within homestead (homestead ssh, just to eliminate a windows problem) but the result is the same.

ghost commented 8 years ago

Maybe you still have it somewhere else?

I can confirm the package works great. I installed it on a few projects already.

Try deleting manually the vendor folder and the composer.lock file and run a clean composer install.

nunomira commented 8 years ago

Don't know what happened to my last answer... but it wasn't submitted after all.

I tried that as well - thanks - no luck. I even tried a new project - all the same. But it seems like I'm the only one having this problem. Really frustrating! I was really curious about this :)

nunomira commented 8 years ago

This is surreal... I tried it on an existing project and it installed without issues!

nunomira commented 8 years ago

And now on another new project it installed as well.

lukasmalkmus commented 8 years ago

@nunomira I'm having the exact same issue! Installed it yesterday at home and it worked. Pushed my changes, pulled them today on another machine: Won't work. Tried everything, can't tell why it fails.

@ionut-tanasa Can you show me your composer.json? I made some adjustments to mine, maybe that's the problem.

mpociot commented 8 years ago

@LukasMa have you tried running composer update after pulling the changes? These issues are not related to the package itself, but seem to be an installation issue.

beartas commented 8 years ago

Autoloader is trying to load this file

...../vendor/mpociot/laravel-test-factory-helper/src/Mpociot/LaravelTestFactoryHelper/TestFactoryHelperServiceProvider.php

but the real location is

.../vendor/mpociot/laravel-test-factory-helper/src/TestFactoryHelperServiceProvider.php

I've just stepped through the code and the ClassLoader is failing to locate the file, line 381.

Update Mpociot\LaravelTestFactoryHelper\composer.json from

"autoload": {
        "psr-0": {
            "Mpociot\\LaravelTestFactoryHelper": "src/"
        }
    }

to

"autoload": {
        "psr-0": {
            "": "src/"
        }
    }

and

php artisan clear-compiled

works fine.

mpociot commented 8 years ago

Fixed with the latest release