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

Move test file to autoload-dev to fix composer update #397

Merged
merged 1 commit into from
Nov 10, 2015
Merged

Move test file to autoload-dev to fix composer update #397

merged 1 commit into from
Nov 10, 2015

Conversation

unnawut
Copy link
Contributor

@unnawut unnawut commented Oct 19, 2015

Fix for #391, #394, #396

@unnawut
Copy link
Contributor Author

unnawut commented Oct 19, 2015

Meanwhile waiting for PR to be accepted. Here's a workaround by adding "repositories" and changing zizaco/entrust to use dev-middlewaretest-fix in composer.json file.

{
    ...
    "repositories": [
        {
            "url": "https://github.com/tuwannu/entrust.git",
            "type": "git"
        }
    ],
    "require": {
        ...
        "zizaco/entrust": "dev-middlewaretest-fix",
        ...
    },
    ...
}

andrewelkins added a commit that referenced this pull request Nov 10, 2015
Move test file to autoload-dev to fix composer update. Thanks @tuwannu
@andrewelkins andrewelkins merged commit 3c56c8e into Zizaco:master Nov 10, 2015
@miyamoto-san
Copy link

Hi, I am not sure I've understood everything here! But I've added the repositories array as well as the require middlewaretest-fix (to my composer.json) and done composer update, composer dump-autoloader but the problem persists! :/

@unnawut
Copy link
Contributor Author

unnawut commented Nov 30, 2015

This pull request has already been merged. There is no need to put a workaround on this. Simply require

"zizaco/entrust":"dev-master"

in your composer.json, without any additional changes I mentioned in this pull request, should work fine.

@miyamoto-san
Copy link

Ok let's see I am still getting the same error "ReflectionException in Container.php line 737:
Class App\Http\Zizaco\Entrust\Middleware\EntrustRole does not exist"

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.",
"intervention/image": "^2.3",
"zizaco/entrust": "dev-master"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.
",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r "copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}

composer update

php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Removing predis/predis (v1.0.3)
  • Updating zizaco/entrust (dev-middlewaretest-fix 8d88ff4 => dev-master 3b41a8e)
    The package has modified files:
    M src/Entrust/Middleware/EntrustRole.php
    Discard changes [y,n,v,d,s,?]? y
    Checking out 3b41a8e

Writing lock file
Generating autoload files
php artisan optimize

Route

Route::get('/admin/rabatt', ['uses' => 'AdminRabattCtrl@index', 'middleware' => ['role:admin|root']]);

@unnawut
Copy link
Contributor Author

unnawut commented Nov 30, 2015

Your composer.json file looks alright.

From the error message, it should not be trying to find App\Http\Zizaco\Entrust\Middleware\EntrustRole, but rather Zizaco\Entrust\Middleware\EntrustRole. Are you sure you are doing your code right?

@miyamoto-san
Copy link

Aliases
'Entrust' => Zizaco\Entrust\EntrustFacade::class,

providers
Zizaco\Entrust\EntrustServiceProvider::class,

protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'role' => Zizaco\Entrust\Middleware\EntrustRole::class,
    'permission' => Zizaco\Entrust\Middleware\EntrustPermission::class,
    'ability' => Zizaco\Entrust\Middleware\EntrustAbility::class,
];

@miyamoto-san
Copy link

I actually solved the problem and for future reference there needs to be a \ before the Zizaco i.e

protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
];

Rather than

protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'role' => Zizaco\Entrust\Middleware\EntrustRole::class,
'permission' => Zizaco\Entrust\Middleware\EntrustPermission::class,
'ability' => Zizaco\Entrust\Middleware\EntrustAbility::class,
];

That's just basic namespacing but if anyone else find themselves in this position it's probably because you just copy pasted the code from the git page like myself :)

@robertmindroi
Copy link

@Profeten +1

1 similar comment
@nhtua
Copy link

nhtua commented Feb 22, 2016

@Profeten +1

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

Successfully merging this pull request may close these issues.

None yet

5 participants