Yii2 Error: Class dektrium\rbac\Module does not exist - php

I have just updated my composer and after that when i run my Yii2 application i got this error "Class dektrium\rbac\Module does not exist" i am using rbac in my application.
I checked desctrium\rabc directory there is no file with Module class. However i can see two new files RbacWebModule, RbacConsoleModule in that directoy.
I have a backup of my application on other server. so do i have to put my backup there to correct this error or is there any other solution. i can see in my vendor folder all other folders also get updated with composer update. So how to get rid of this error.
Thanks in advance.

This class has been renamed over a month ago. Since it's still beta I recommend to check for any major changes with every upgrade. Always follow the instruction.
Add rbac module to web application config file as follows:
...
'modules' => [
...
'rbac' => 'dektrium\rbac\RbacWebModule',
...
],
...

Related

Yii2 Composer and Bower issue

I am facing a problem during Yii2 installation.
I have repository on Bitbucket. Its obvious that after git clone/fetch/pull i need to install dependencies. Everything that i am trying to do is always inside newly created php 7.2.0 Docker image machine (Bitbucket Pipelines). So here is the list of commands that i have:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar create-project
My composer.json file is equals to one from official repository.
The problem is that web/assets directory is lacking of files. It has autogenerated directories and only yii, yii activeForm, captcha, gridView and validation JS files.
As i know composer-asset-plugin not used any more. At least no mention in installation guide. But even if i add php composer.phar global require "fxp/composer-asset-plugin:^1.4.2" it won't fix the issue. It looks like bower assets can't be compiled or something like that. Maybe i am wrong. I have no idea why its not working. No results during search too.
Any ideas? Thanks!
Issue come when we are using composer 2. Otherwise we can use fxp/composer-asset-plugin. MihaOo answered for basic app. For people who are using advanced app can use following configuration.
Update common/config/main.php with following config.
'aliases' => [
'#bower' => '#vendor/bower-asset',
'#npm' => '#vendor/npm-asset',
],
Original config file from yii2 advanced app - configuration file
More information about this - Yii2 Forum
Complete solution in Asset packagelist -Asset packagelist
For people who facing this issue. I've checked everything once more, it should work but it doesn't. All essential directories have correct rights. Everything is working perfectly except this bower issue. I doublecheck on local PC. Can't reproduce.
However after about 10 takes to fix, it starts working correctly. Maybe it is yii\web\AssetManager issue or something, i still don't know, time will show.
UPD 22.10.2018
You just need to add this code to you cofig file and it will fix this issue.
'aliases' => [
'#bower' => '#vendor/bower-asset',
'#npm' => '#vendor/npm-asset'
]
It was also added to application templates

Laravel Glide installation - where do I put the config information?

I am interested in installing Glide in Laravel for an image server I need to build.
There are 3 main steps in the installation:
Run a Composer command
composer require league/glide-laravel
This step is called 'Configuration', it shows the following PHP code
Configuration:
use League\Glide\ServerFactory;
use League\Glide\Responses\LaravelResponseFactory;
$server = ServerFactory::create([
'response' => new LaravelResponseFactory(app('request'))
]);
... and step 3, which is a working example.
My question is, where does the step 2.
configuration code go?
I can't see anywhere obvious in the 'config' folder. Disclaimer: I'm a newbie to Laravel with only two sites built so far.
thank you.
The configuration code belongs in the default image controller. It is confusing in the documentation but I placed the code in the controller and it works.

Laravel 4 Setup: Driver [file] not supported

I'm trying to set up an existing site that was built using Laravel 4 on my server. I've gotten stuck at an error: Driver [file] not supported. It's throwing the error from Illuminate/Support/Manager.php.
I've tried using boilerplate Laravel files for the Manager.php file, as well as the SessionManager.php file, but it still won't work. I've also tried to figure out if file is registered as a driver, but when I try to insert the code for it, I get lost because of undeclared functions.
When I try to change the default session driver in app/config/session to anything else, it just throws other errors at me. Yet this is the same way the site was originally set up on its own server, so I don't understand why it isn't working. Can anyone help me out?
I was stuck in same problem, solved it. After changing any configuration config cache must be cleared using php artisan config:cache. Hope it helps.
What is your php version?
Try to clean the session dir
app/storage/sessions
then try to clean autoload file
cd [YOUR LARAVEL ROOT DIR]
composer dump-autoload
and update composer package to be sure vendor folder is ok
cd [YOUR LARAVEL ROOT DIR]
composer update

ZF2 Google Maps Module - Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for GMaps\Service\GoogleMap

I'm trying to use this module, https://github.com/gowsram/zf2-google-maps- , but I'm running into a problem.
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for GMaps\Service\GoogleMap
I have followed the instruction in the github readme, and have cloned the project into my vendors directory.
From what I understand, the line which calls the ServiceLocator,
$map = $this->getServiceLocator()->get('GMaps\Service\GoogleMap');
isn't pointing to the right place. Unfortunately my knowledge of how the service locator works isn't deep enough to figure out how to fix the problem, despite attempts to remedy this by diving into the docs. It's all a little over my head.
Thanks for any input you may be able to provide!
Have you edited your application.config.php file so that the modules array contains GMaps? From the look of the error, the module isn't running since the service is not registered with the ServiceManager.
That step appeared to be skipped over in the installation instructions but you should add it to your application config so it runs the module's Module.php code.
application.config.php
return array(
'modules' => array(
'Application',
'GMaps',
),
/...
);

Laravel 4 wont autoload provider

So I have created a new provider and facade and added them to my app configuration. Problem Is that I get an error:
Class 'Cergis\View\Helper\SentryViewProvider' not found
The class is using a PSR-0 naming scheme and I have verified that it's correct by adding
"psr-0": {
"Cergis\\": [
"vendor/cergis/logger/src/",
"vendor/cergis/sentry-view/src/"
]
}
If I do this and run composer dump-autoload then it works without issue. But for some reason it's unable to do so without me manually telling it where to find the classes in the vendor folder. I have tried removing everything and starting fresh, running composer dump-autoload before adding it to app.providers.
Try looking at /vendor/composer/autoload_classmap.php and check if Cergis\View\Helper\SentryViewProvider is there, if not then add these line at the start of the array:
'SentryViewProvider' => $baseDir . 'View\Helper\SentryViewProvider.php,'
Feel free to edit the value to match the path
Have you ran composer dump since creating them?

Categories