kodeine / laravel-acl

Light-weight role-based permissions system for Laravel 6+ built in Auth system.
MIT License
786 stars 216 forks source link

Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive() #66

Closed jshah4517 closed 9 years ago

jshah4517 commented 9 years ago

This error appeared after doing composer update today, currently running Laravel 5.0.33.

I managed to find the block of code at fault, lines 64 to 81 in AclServiceProvider.php, as copied below. Commenting it out temporarily fixed the problem but I'm unsure about a permanent solution (not even sure why this has suddenly appeared).

        // role
        Blade::directive('role', function($expression) {
            return "<?php if (Auth::check() && Auth::user()->is{$expression}): ?>";
        });

        Blade::directive('endrole', function() {
            return "<?php endif; ?>";
        });

        // permission
        Blade::directive('permission', function($expression) {
            return "<?php if (Auth::check() && Auth::user()->can{$expression}): ?>";
        });

        Blade::directive('endpermission', function() {
            return "<?php endif; ?>";
        });
kodeine commented 9 years ago

@jshah4517 that's in master branch, you need to be using ~1.0 branch

jshah4517 commented 9 years ago

Thanks! That fixed it.

leyvicaz commented 9 years ago

the same again problem :(

leyvicaz commented 9 years ago

the problem return in the new version

kodeine commented 9 years ago

@leyvicaz Your compose.json should have "kodeine/laravel-acl": "~1.0@dev", not the dev-master branch.

leyvicaz commented 9 years ago

ok, thanks :+1:

Harrrrry commented 8 years ago

Same error is for me when i update the composer. I don't know the reason behind the error.

Error php artisan clear-compiled PHP Fatal error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive() in /var/www/html/innomaid/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213

[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive()

Script php artisan clear-compiled handling the post-update-cmd event returned with an error

[RuntimeException]
Error Output: PHP Fatal error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::directive() in /var/www/html/innomaid/ve
ndor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 213

This is my composer

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "laravel/framework": "5.0.", "illuminate/html": "5.", "barryvdh/laravel-dompdf": "0.6.", "tymon/jwt-auth": "0.5.", "gloudemans/shoppingcart": "~1.3", "intervention/image": "^2.3" }, "require-dev": { "phpunit/phpunit": "~4.0", "phpspec/phpspec": "~2.1", "zizaco/entrust": "dev-laravel-5" }, "autoload": { "classmap": [ "database" ], "psr-4": { "App\": "app/" } }, "autoload-dev": { "classmap": [ "tests/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php -r \"copy('.env.example', '.env');\"", "php artisan key:generate" ] }, "config": { "preferred-install": "dist" } }

jshah4517 commented 8 years ago

Your composer file doesn't appear to contain kodeine, are you sure you are using this package? The problem might be elsewhere.

Harrrrry commented 8 years ago

Sorry, i am not using this package but my problem is quit similar so i just post the question, please help me

jshah4517 commented 8 years ago

This issue is specifically for this package, you should post your problem on a laravel forum or their IRC.

Harrrrry commented 8 years ago

Ohk, Thanks

kodeine commented 8 years ago

@jshah4517 @Harrrrry

Please make sure you are using version 1.0

Harrrrry commented 8 years ago

@kodeine 1.0 for what, please specify.

Harrrrry commented 8 years ago

update "zizaco/entrust": "dev-laravel-5" to "zizaco/entrust": "1.4.1"

Solve my problem.

raulghm commented 8 years ago

The same of @Harrrrry my problem was "zizaco/entrust ^^!

jonaths commented 7 years ago

I have the same issue. This is my composer:

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.6.4", "barryvdh/laravel-cors": "^0.9.2", "barryvdh/laravel-dompdf": "^0.8.0", "bitwasp/bitcoin": "v0.0.33.1", "dingo/api": "1.0.@dev", "guzzlehttp/guzzle": "~6.0", "laravel/framework": "5.4.", "laravel/tinker": "~1.0", "nesbot/carbon": "^1.22", "simplesoftwareio/simple-qrcode": "~1", "tymon/jwt-auth": "0.5.", "zizaco/entrust": "5.2.x-dev" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.", "phpunit/phpunit": "~5.7" }, "autoload": { "classmap": [ "database" ], "psr-4": { "App\": "app/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "scripts": { "post-root-package-install": [ "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "php artisan key:generate" ], "post-install-cmd": [ "Illuminate\Foundation\ComposerScripts::postInstall", "php artisan optimize" ], "post-update-cmd": [ "Illuminate\Foundation\ComposerScripts::postUpdate", "php artisan optimize" ] }, "config": { "preferred-install": "dist", "sort-packages": true } }

I tried changing the zizaco/entrust version as stated above and I have the same result.

Any idea please? Thanks.