I'm developing a Role-Permission package in Laravel and I want to use this package;
Problem is I can not use some functions in the main project when I install this package in my own package. example "HasRoles"
My packages composer.json file
"require": {
"spatie/laravel-permission": "dev-master"
},
"autoload": {
"psr-4": {
"Modul\\Permission\\": "src"
}
},
"extra": {
"laravel": {
"providers": [
"Spatie\\Permission\\PermissionServiceProvider"
]
}
}
main project composer file
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.8.*",
"laravel/tinker": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Modul\\Permission\\": "packages/modul/permission/src"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
}
}
and my User model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use Notifiable;
use HasRoles;
when I serve its show this error message...
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) Trait 'Spatie\Permission\Traits\HasRoles' not found
What am I doing wrong here?
composer.json
manually then you need to docomposer update
for Composer to install it into your vendor folder. – d3jnvendor/autoload.php
? – d3jncomposer dump-autoload
manually. just to be sure – N69Scomposer update yourpackage/name
(orcomposer update
in general) for your project to bring in new changes and new dependency into it. – d3jn