I'm trying to use https://github.com/sebdesign/laravel-state-machine in my laravel application. But the package is not installed correctly. My controller doesn't recognise it. First, I added the following to my composer.json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/sebdesign/state-machine"
}
]
Then I run
composer require sebdesign/laravel-state-machine:1.0
Then I added the following in my config/app.php
'providers' => [
Sebdesign\SM\ServiceProvider::class,
],
'aliases' => [
'StateMachine' => Sebdesign\SM\Facade::class,
],
After that I Publish the config file in config/state-machine.php using
php artisan vendor:publish --provider="Sebdesign\SM\ServiceProvider"
And that was it. Now I'm trying to use it in my controllers as:
// Using the facade
$stateMachine = StateMachine::get($article, 'simple');
But StateMachine is not recognised. I'm getting
Undefined type 'App\Api\V1\Controllers\Resource\StateMachine'
Am I missing something here? Should i add a use statement for something in the beginning of my controller?
Edit: Laravel 5.1 Thanks