Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with installation #30

Closed
mo2l opened this issue Sep 20, 2016 · 27 comments
Closed

Problems with installation #30

mo2l opened this issue Sep 20, 2016 · 27 comments

Comments

@mo2l
Copy link

mo2l commented Sep 20, 2016

Hey,

I am trying to install laratrust and use it in a project.

What i have done is the following:

  1. added laratrust to the require part of my composer.son
    "require": { "php": ">=5.6.4", "laravel/framework": "5.3.*", "teepluss/theme": "dev-master", "santigarcor/laratrust": "3.0.*"
  2. I run composer update what managed to download laracast
  3. I added the provider and the alias part

Provider:

` /*
* Package Service Providers...
*/

    'Teepluss\Theme\ThemeServiceProvider',
    Laratrust\LaratrustServiceProvider::class,

`

Aliases:

'Lang' => Illuminate\Support\Facades\Lang::class, 'Laratrust' => Laratrust\LaratrustFacade::class, 'Log' => Illuminate\Support\Facades\Log::class,

  1. I wanted to run php artisan vendor:publish which happened not to generate a laratrust.php in my config directory
  2. When I tried to run php artisan laratrust:setup which wasn't execution with following error message:

[Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "laratrust" namespace.

I have redone the whole installing part twice to check that I didn't read over something. Any ideas how to solve this?

@santigarcor
Copy link
Owner

@mo2l I'll try to recreate the error.

@santigarcor
Copy link
Owner

@mo2l I wasn't able to reproduce the error. I followed all the steps you mentioned above but the vendor:publish and laratrust:setup commands ran without problems.

Are you sure that you have the service provider in your config/app.php file?

@mo2l
Copy link
Author

mo2l commented Sep 20, 2016

@santigarcor thanks for your response. this is my config/app.php file

`<?php

return [

/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/

'name' => 'Laravel',

/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/

'env' => env('APP_ENV', 'production'),

/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/

'debug' => env('APP_DEBUG', true),

/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/

'url' => env('APP_URL', 'http://localhost'),

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/

'timezone' => 'UTC',

/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/

'locale' => 'en',

/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/

'fallback_locale' => 'en',

/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/

'key' => env('APP_KEY'),

'cipher' => 'AES-256-CBC',

/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/

'log' => env('APP_LOG', 'single'),

'log_level' => env('APP_LOG_LEVEL', 'debug'),

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/

'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\Notifications\NotificationServiceProvider::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,

    /*
     * Package Service Providers...
     */

    'Teepluss\Theme\ThemeServiceProvider',
    Laratrust\LaratrustServiceProvider::class,


    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

],

/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => [

    'App' => Illuminate\Support\Facades\App::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    'Auth' => Illuminate\Support\Facades\Auth::class,
    'Blade' => Illuminate\Support\Facades\Blade::class,
    'Cache' => Illuminate\Support\Facades\Cache::class,
    'Config' => Illuminate\Support\Facades\Config::class,
    'Cookie' => Illuminate\Support\Facades\Cookie::class,
    'Crypt' => Illuminate\Support\Facades\Crypt::class,
    'DB' => Illuminate\Support\Facades\DB::class,
    'Eloquent' => Illuminate\Database\Eloquent\Model::class,
    'Event' => Illuminate\Support\Facades\Event::class,
    'File' => Illuminate\Support\Facades\File::class,
    'Gate' => Illuminate\Support\Facades\Gate::class,
    'Hash' => Illuminate\Support\Facades\Hash::class,
    'Lang' => Illuminate\Support\Facades\Lang::class,
    'Laratrust' => Laratrust\LaratrustFacade::class,
    'Log' => Illuminate\Support\Facades\Log::class,
    'Mail' => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password' => Illuminate\Support\Facades\Password::class,
    'Queue' => Illuminate\Support\Facades\Queue::class,
    'Redirect' => Illuminate\Support\Facades\Redirect::class,
    'Redis' => Illuminate\Support\Facades\Redis::class,
    'Request' => Illuminate\Support\Facades\Request::class,
    'Response' => Illuminate\Support\Facades\Response::class,
    'Route' => Illuminate\Support\Facades\Route::class,
    'Schema' => Illuminate\Support\Facades\Schema::class,
    'Session' => Illuminate\Support\Facades\Session::class,
    'Storage' => Illuminate\Support\Facades\Storage::class,
    'Theme' => 'Teepluss\Theme\Facades\Theme',
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View' => Illuminate\Support\Facades\View::class,

],

];`

as far I am not completely blind i should have added the service provider unter the providers part and also have added the alias. If I have made a error there please feel free to tell me. I would b happy to know.

Edit:

This is the output of vendor:publish:

Copied Directory [/vendor/laravel/framework/src/Illuminate/Notifications/resources/views] To [/resources/views/vendor/notifications] Copied Directory [/vendor/laravel/framework/src/Illuminate/Pagination/resources/views] To [/resources/views/vendor/pagination] Publishing complete for tag []!

And for laratrust:setup I get:

[Symfony\Component\Console\Exception\CommandNotFoundException] There are no commands defined in the "laratrust" namespace.

Furthermore just trying the artisan command there is no namespace laratrust listed.

@santigarcor
Copy link
Owner

@mo2l I think i have an idea. Try putting both service providers after Application Service Provider section and it should look like this:

    ...
    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

     /*
     * Package Service Providers...
     */

    'Teepluss\Theme\ThemeServiceProvider',
    Laratrust\LaratrustServiceProvider::class,

@mo2l
Copy link
Author

mo2l commented Sep 21, 2016

@santigarcor tried it still same problem

just have tried following the instructions with a new project. there it worked so i will probably start from scratch. thank you for your help :)

@sasokovacic
Copy link

sasokovacic commented Jul 17, 2017

php artisan laratrust:setup
is not working for me either....
I don't want to install new project and move everything from the old one...
There should be some simple fix for this problem... Anybody solved it?

It seems that there is no laratrust command available when you run
$ php artisan | grep laratrust so there must be installation problem or something...
I did all the steps from the docs to install this this package...

@santigarcor
Copy link
Owner

@sasokovacic please provide the detail of your setup, laravel version, laratraust version. I tried to reproduce it once but i couldn't do it.

@sasokovacic
Copy link

I have laratrust 4.0 and laravel 5.4....
I followed the installation guide here http://laratrust.readthedocs.io/en/4.0/installation.html.

$ composer require "santigarcor/laratrust:4.0.*"

then added Laratrust\LaratrustServiceProvider::class and 'Laratrust' => Laratrust\LaratrustFacade::class, to config/app.php both at the bottom of the prviders and aliases arrays..
then I ran

$ php artisan vendor:publish --tag="laratrust"

and added
'role' => \Laratrust\Middleware\LaratrustRole::class,
'permission' => \Laratrust\Middleware\LaratrustPermission::class,
'ability' => \Laratrust\Middleware\LaratrustAbility::class,
to the app/Http/Kernel.php routeMiddleware array...

Did I missed something?

@santigarcor
Copy link
Owner

I don't think so.

Try running composer dump-autoload. Or you can delete all the vendors directory and run composer update o or composer install and check if it works.

@sasokovacic
Copy link

I tried everything... nothing changed...
when I run $ php artisan | grep laratrust
I get empty line...
I also changed php version from 7.1. to 7.0 (I'm using laradock), removed vendor and reinstall everything in case there is some wierd problem or something... still having problem...

@sasokovacic
Copy link

sasokovacic commented Jul 18, 2017

somebody already mentioned laratrust:setup error but here it is again

[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "laratrust" namespace.

I can see the commands in the vendor/santigarcor/laratrust/src/commands folder...
This is it's content:

AddLaratrustUserTraitUseCommand.php
MakePermissionCommand.php
MakeRoleCommand.php
MakeSeederCommand.php
MakeTeamCommand.php
MigrationCommand.php
SetupCommand.php
SetupTeamsCommand.php
stubs/
UpgradeCommand.php

@sasokovacic
Copy link

do I open new issue or should we continue on this one?
I realy need to solve this today or else I'll have to find another acl package...

@KKSzymanowski
Copy link
Collaborator

Let's continue here. Do you know if the Laratrust service provider is loaded at all? Try printing something in boot and register methods if you haven't checked yet.

@sasokovacic
Copy link

it's not loaded...
I checked again the config/app.php...
service provider is there and also alias...

@KKSzymanowski
Copy link
Collaborator

You said you ran

$ php artisan vendor:publish --tag="laratrust"

Did it publish the assets successfully?
Any chance you're using OPcache in PHP CLI?

@KKSzymanowski
Copy link
Collaborator

I cannot reproduce this. I did:

laravel new test
cd test
composer require santigarcor/laratrust

Then I added the service provider in config/app.php at the end of the providers array and all Laratrust commands are visible

...
 key
  key:generate           Set the application key
 laratrust
  laratrust:add-trait    Add LaratrustUserTrait to App\User class
  laratrust:migration    Creates a migration following the Laratrust specifications.
  laratrust:permission   Create Permission model if it does not exist
  laratrust:role         Create Role model if it does not exist
  laratrust:seeder       Creates the seeder following the Laratrust specifications.
  laratrust:setup        Setup migration and models for Laratrust
  laratrust:setup-teams  Setup the teams feature in case it is not used
  laratrust:team         Create Team model if it does not exist
  laratrust:upgrade      Creates a migration to upgrade laratrust from version 3.2 to 4.0.
 make
  make:auth              Scaffold basic login and registration views and routes
  make:command           Create a new Artisan command
...

Did you do something besides what I just listed?

@sasokovacic
Copy link

no.. I did it exactly like you... I did publish config and it says

laradock@9271f6d771ef:/var/www$ php artisan vendor:publish --force --tag="laratrust"
Publishing complete.

Also tried

laradock@9271f6d771ef:/var/www$ php artisan vendor:publish --provider="Laratrust\LaratrustServiceProvider" --force
Publishing complete.

If you force publishing it should log publishing directory e.g.

laradock@9271f6d771ef:/var/www$ php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider" --force
Copied File [/vendor/barryvdh/laravel-cors/config/cors.php] To [/config/cors.php]
Publishing complete.

This is not the case with your package....
So nothing is copied into the config folder

@KKSzymanowski
Copy link
Collaborator

Are you using Laratrust 4.0.1 and Laravel 5.4.28?

@KKSzymanowski
Copy link
Collaborator

For me it would be the easiest if you could publish a minimal Laravel project where you can see this error.

@sasokovacic
Copy link

yes.. 4.0.1 and 5.4.28..

ok I will install new laravel instance and try

@sasokovacic
Copy link

it's working in new instance of laravel.. I guess I'll have to move all the code... It's a little bit annoying but don't want to spend additional time for debugging... need to finish the project... thanks for your help... I hope I don't return to this issue when I move and install everything...

@sasokovacic
Copy link

sasokovacic commented Jul 18, 2017

ok... really didn't want to move everything so I tried one more time and figured it out now... here is the solution in case anybody else is having the same problem..
I printed out \Config::get('app.providers') and laratrust provider wasn't listed there.. so I ran

$ php artisan config:clear

and it's working now...

@KKSzymanowski
Copy link
Collaborator

I'm glad you found the solution. I'll add the hint to the docs.

@sasokovacic
Copy link

great... thanks...

@mdazlaanzubair
Copy link

I fix this issue with this:
use Laratrust\Models\LaratrustRole;
instead of this:
use Laratrust\LaratrustRole;

hopefully this "\Models" this will help you.

@narru
Copy link

narru commented Sep 20, 2018

i have shift all the Model to the Models folder then changed in all the files like: App\Models\User
but i am getting error which is no message please help me.

@santigarcor
Copy link
Owner

@narru Try updating your config/laratrust.php file with the right namespaces for you new models. That would be the only thing related to Laratrust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants