DikkiX / Schoolproject

BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Remove Bootstrap 5, remove PHP ext. #1

Closed Cuji12 closed 1 year ago

Cuji12 commented 1 year ago
DikkiX commented 1 year ago

so now installing usario should be possible?

Cuji12 commented 1 year ago

It will be yes, just delete your composer.lock / vendor directory to ensure it all goes smoothly!

DikkiX commented 1 year ago

Sorry im new so im a bit confused, should i delete the whole vendor folder and composer.lock??? so yes, what should i do after? to make sure all packages come back

Cuji12 commented 1 year ago

Ah so just delete both your composer.lock and vendor directory and then run "composer install". That way you're running a fresh install of all your packages. If you really need the packages I removed, then just refer to the options I listed on my comment on the Yii2 forums - unfortunately those are your only options :)!

DikkiX commented 1 year ago

Alright thanks, after doing so, i get that this error on site Failed to instantiate component or class "yii\bootstrap5\BootstrapAsset".

Now means i need to change in every file that says bootstrap5 to the new one but a bit confused what its called. Do i have to change it to bootstrap2?

Cuji12 commented 1 year ago

Yeah so if you're wanting to use the 2amigos/yii2-usuario package your only option is to use Bootstrap 2 so you would need to convert your codebase from Bootstrap 5 > 2. It's a fairly old package so it's unfortunately your only option.

Cuji12 commented 1 year ago

Yeah so if you're wanting to use the 2amigos/yii2-usuario package your only option is to use Bootstrap 2 so you would need to convert your codebase from Bootstrap 5 > 2. It's a fairly old package so it's unfortunately your only option.

Just to clarify, composer - which is the dependency manager you're using - can only ever install the same package once; you can't install multiple versions of the same package which is what you would be attempting to do by installing Bootstrap 2 and 5.

DikkiX commented 1 year ago

So now i need to change this all to 2?

image

So yes, won't that give me the same error?

image
Cuji12 commented 1 year ago

Well that looks like a hassle lol, yeah you would need to change your usage of bootstrap5 to the namespace of the older Bootstrap package. You can find a list of them all here: https://github.com/yiisoft/yii2-bootstrap/blob/master/docs/guide/usage-widgets.md. But you're effectively just changing bootstrap5 to bootstrap.

You're potentially using features that only exist in Bootstrap 5 on these pages too, so you'd need to consult Bootstrap docs to see what you do / don't have access to in-case you run into more errors. But it may be absolutely fine, fingers crossed.

Cuji12 commented 1 year ago

A quick note: I was mistaken, the version of Bootstrap the older package uses is Bootstrap 3. Nonetheless you can review the difference between the packages here (older version) https://github.com/yiisoft/yii2-bootstrap/blob/master/docs/guide/README.md and here (newer version) https://github.com/yiisoft/yii2-bootstrap5/blob/master/docs/guide/README.md.

DikkiX commented 1 year ago

Ok so i have things up and running and seeing that because of the bootstrap, the css are now "broken". With an deadline closeby and teammates that don't do anything, i wont have time to fix all this to make it back to the first one. so im reverting everything back to normal.

I wanted to have RBAC working and an working 2mfa and all that was included in Usuario extension. I think i would be faster done by searching for the RBAC problems and the way of fixing the 2mfa witout usuario!

Cuji12 commented 1 year ago

Ah I see so that's what you're using it for, if that's the case there's likely multiple extensions implementing exactly that, I'd recommend checking out this page to see if you can find a package for it: https://www.yiiframework.com/extensions?category=1&version=2.0

Cuji12 commented 1 year ago

I'm generally aware of an MFA package, never used it but there's a thread for someone who ran into issues about it here which may come in handy if you use it: https://forum.yiiframework.com/t/multi-factor-authentication-with-yii2-mfa-plugin/134156

DikkiX commented 1 year ago

yes, i checked that. As u can see my repository, u can see that i installed the whole rbac extension and migrations and still doesn't work how i want it to work, Roles are not working etc so i cant make users Admins so only they can log into backend etc. And also the mfa link u sent, i read that but wasn't working and is outdated, and the new one is to vague for us to understand.

Maybe u.understand the RBAC, and can see the problems i have in my code?

Cuji12 commented 1 year ago

Unfortunately I don't have time to go through the entire project but one thing I noticed is you're configuring RBAC in your main config of backend\config.

The way Yii works is we create an array of our configuration of what we want our application instance to access. We do this in the yii file. If you're in VSC just type "ctrl+p" and "yii" and you can find those files (they're in your dev / prod environment folders). Currently this config is pulling from your /common/config directory. So any changes you've made to /backend/config/main.php won't be present.

Just make sure you're adding config to the file(s) that you're loading into the $config variable present in your "yii" file(s).

DikkiX commented 1 year ago

Ok, thanks!!

One last question, when trying to use migration, i always get this error. u know how to fix it?

`PS C:\xampp\htdocs\Schoolproject> .\yii migrate --migrationPath=@mdm/admin/migrations Exception 'yii\base\InvalidConfigException' with message 'The configuration for the "user" component must contain a "class" element.'

in C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\di\ServiceLocator.php:209

Stack trace:

0 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\di\ServiceLocator.php(265): yii\di\ServiceLocator->set('user', Array)

1 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\base\Component.php(180): yii\di\ServiceLocator->setComponents(Array)

2 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\BaseYii.php(558): yii\base\Component->__set('components', Array)

3 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\base\BaseObject.php(107): yii\BaseYii::configure(Object(yii\console\Application), Array)

4 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\base\Application.php(204): yii\base\BaseObject->__construct(Array)

5 C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\console\Application.php(89): yii\base\Application->__construct(Array)

6 C:\xampp\htdocs\Schoolproject\yii(22): yii\console\Application->__construct(Array)

7 {main}`

Cuji12 commented 1 year ago

Yeah so it's just telling you there's a class definition missing in the config of your user under common/config/main.php - PR here should fix that one for you: https://github.com/DikkiX/Schoolproject/pull/2