Laravel-permission: When registering Spatie\Permission\PermissionServiceProvider::class PHP Artisan no longer works

Created on 26 Dec 2015  Â·  14Comments  Â·  Source: spatie/laravel-permission

When I have added Spatie\Permission\PermissionServiceProvider::class to my config/app.php file, PHP Artisan no longer works so I am unable to continue with the installation steps.

This is occurring in Laravel 5.2.

Most helpful comment

you do the following steps:

  1. Comment current "Spatie\Permission\PermissionServiceProvider::class," in App\config.php
  2. Run command : "composer update"
    Check again

All 14 comments

Can you post the relevant lines in your config/app.php file. Also, which error are you getting when running php artisan?

Hi,

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,
    Spatie\Permission\PermissionServiceProvider::class,

],

I am not receiving any errors when running php artisan, just nothing is output from the command line.

Is there anything logged in the storage/logs directory?

There was nothing in the log file about it, cleared the logs and it now
appears to work

On Sat, Dec 26, 2015 at 2:13 PM, lowerends [email protected] wrote:

Is there anything logged in the storage/logs directory?

—
Reply to this email directly or view it on GitHub
https://github.com/spatie/laravel-permission/issues/29#issuecomment-167327264
.

I've just done a clean install of Laravel and I receive the following message
[2015-12-26 15:01:56] local.ALERT: Could not register permissions

Are you trying to migrate laravel-permissions ? (i.e : php artisan migrate)

Yes , this occurs during the migrate stage, all database tables exist, I can create roles, but I can't assign or create permissions

Delete roles, permissions, roles-has-permissions, users-has-permissions, roles-has-permissions records from migration table, and drop them from DB, finaly re-execute the command: php artisan migrate.
This error occurs when you're trying to migrate tables already exist in DB.

I have performed a clean installation and I receive the same error message as previously - Could not register permissions

Below is the contents of the Migrations Table
2014_10_12_000000_create_users_table
2014_10_12_100000_create_password_resets_table
2015_12_30_141351_create_permission_tables

Following the advice above, I have deleted the relevant tables and remove the create_permissions_tables row from migrations.

I have also cleared the Laravel Log File. Re-executed php artisan migrate and the following was written to the cleared log file

[2015-12-30 14:21:56] local.ALERT: Could not register permissions

@louisdboyd :+1: , i have the same issue

Could you change the line

Log::alert('Could not register permissions');

to:

Log::alert('Could not register permissions'. $e->getMessage() . $e->getTraceAsString());

and run artisan again?

Let me know what gets written to the log.

[2016-01-01 17:42:37] local.ERROR: ParseError: syntax error, unexpected 'return' (T_RETURN) in /home/vagrant/timecontrol/vendor/spatie/laravel-permission/src/PermissionRegistrar.php:58
Stack trace:
#0 /home/vagrant/timecontrol/vendor/composer/ClassLoader.php(301): Composer\Autoload\includeFile('/home/vagrant/t...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Spatie\\Permissi...')
#2 [internal function]: spl_autoload_call('Spatie\\Permissi...')
#3 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1214): ReflectionParameter->getClass()
#4 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1195): Illuminate\Container\Container->addDependencyForCallParameter(Object(ReflectionParameter), Array, Array)
#5 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1181): Illuminate\Container\Container->getMethodDependencies(Array, Array)
#6 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1800): Illuminate\Container\Container->call(Array)
#7 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1792): Illuminate\Foundation\Application->bootProvider(Object(Spatie\Permission\PermissionServiceProvider))
#8 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(Spatie\Permission\PermissionServiceProvider), 15)
#9 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1793): array_walk(Array, Object(Closure))
#10 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2131): Illuminate\Foundation\Application->boot()
#11 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1579): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#12 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2295): Illuminate\Foundation\Application->bootstrapWith(Array)
#13 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2248): Illuminate\Foundation\Http\Kernel->bootstrap()
#14 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2232): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#15 /home/vagrant/timecontrol/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#16 {main}

Next ReflectionException: Class Spatie\Permission\PermissionRegistrar does not exist in /home/vagrant/timecontrol/bootstrap/cache/compiled.php:1214
Stack trace:
#0 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1214): ReflectionParameter->getClass()
#1 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1195): Illuminate\Container\Container->addDependencyForCallParameter(Object(ReflectionParameter), Array, Array)
#2 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1181): Illuminate\Container\Container->getMethodDependencies(Array, Array)
#3 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1800): Illuminate\Container\Container->call(Array)
#4 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1792): Illuminate\Foundation\Application->bootProvider(Object(Spatie\Permission\PermissionServiceProvider))
#5 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(Spatie\Permission\PermissionServiceProvider), 15)
#6 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1793): array_walk(Array, Object(Closure))
#7 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2131): Illuminate\Foundation\Application->boot()
#8 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(1579): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#9 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2295): Illuminate\Foundation\Application->bootstrapWith(Array)
#10 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2248): Illuminate\Foundation\Http\Kernel->bootstrap()
#11 /home/vagrant/timecontrol/bootstrap/cache/compiled.php(2232): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#12 /home/vagrant/timecontrol/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#13 {main}

@ghermans I think you made an error altering the log statement. Does that logline end with a ;?

you do the following steps:

  1. Comment current "Spatie\Permission\PermissionServiceProvider::class," in App\config.php
  2. Run command : "composer update"
    Check again
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tripex picture tripex  Â·  3Comments

devingray picture devingray  Â·  3Comments

hosseinnedaei picture hosseinnedaei  Â·  3Comments

NattananWs picture NattananWs  Â·  3Comments

enghelewa picture enghelewa  Â·  4Comments