I have designed Yii2 powered blog by creating models, views and controllers but when I integrate user registration as explained in this tutorial https://code.tutsplus.com/tutorials/how-to-program-with-yii2-integrating-user-registration--cms-22974 I get:
Class dektrium\user\Module does not exist
I fail to solve this error anyone who can direct me, please.
I think you need to include the required module via composer:
"dektrium/yii2-user": "*"
Then run the "composer update" command in your console.
Mabe you need to add to config:
'user' => [
'class' => 'dektrium\user\Module',
'admins' => ['MegaAdmin'],
],
If you have it in common/config/main.php try to replace to backend/config/main.php
Related
I'm using Laravel 6 and php 7 along with ReactJS. I'm following Build a Basic CRUD App with Laravel and React tutorial to learn how to make a CRUD app. In the tutorial, it says that I need to enable CORS so the API can be accessed from the front-end application. After I install the barryvdh cors by running:
composer require barryvdh/laravel-cors
and add it to my Kernel.php:
protected $middlewareGroups = [
'web' => [
...
\Barryvdh\Cors\HandleCors::class,
],
'api' => [
...
\Barryvdh\Cors\HandleCors::class,
],
];
the class is still undefined in Laravel and I get the error shown here
Here is a screenshot of my code.
Does anyone know how to solve this issue?
It looks like you're using an out of date tutorial. If you Google for barryvdh/laravel-cors, you'll see that the repository has been renamed to fruitcake/laravel-cors.
composer require fruitcake/laravel-cors
I suspect that the dependency therefore didn't install, or if it did, that you're referencing the incorrect namespace. It should be:
\Fruitcake\Cors\HandleCors::class
I've installed MediaWiki and am trying to achieve single sign-on, so that when my users sign into their accounts on my Yii2 system, they can also be signed in to the wiki.
So I want to 'Yii-fy' the wiki so I can fiddle about with the auth code.
With this in mind, I've followed the Yii docs and entered the following in the entry page of the wiki, which is in the 'web/wiki' directory:
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
$yiiConfig = require(__DIR__ . '/../../config/web.php');
new yii\web\Application($yiiConfig); // Do NOT call run() here
The paths are fine for those files, but then I'm getting:
Previous exception:
exception 'ReflectionException' with message 'Class dektrium\\user\\Module
does not exist'
My web.php has 'user' as follows:
'user' => [
'class' => 'dektrium\user\Module',
'enableRegistration' => false,
],
How can I fix this?
Your autoloader must know how to find this class. If you're using composer, add the following in composer.json:
{
"autoload": {
"psr-4": {
"dektrium\\": "[path to dektrium folder]",
}
},
}
So, run the composer update to also update the autoloader and get the class registered.
If you are not using composer, you will have to manually register the class in your autoloader.
I use dektrium/yii2-user (on one project) and yiisoft/yii2-authclient (on another one) to login via Google account.
Some time ago it was everything ok, but i guess after last composer update something was changed and now i get an error: "Class yii\authclient\clients\GoogleOAuth does not exist" when try to open login page.
Does anybody has the same issue or know what's wrong?
Thank you
yii2-authclient has been modified in the latest version which is not backward compatible.
Read about the upgrade process here.
Two solutions:
Modify composer.json to fetch 2.0.6 version (replace * with 2.0.6) - no other changes are needed but no more updates for this extension.
Upgrade your code following the guide in the link above so you can be up-to-date.
In the config file
Replace from
'google' => [
'class' => 'yii\authclient\clients\GoogleOAuth',
..
],
Replace to
'google' => [
'class' => 'yii\authclient\clients\Google',
...
],
Use yii\authclient\clients\Google instead of yii\authclient\clients\GoogleOAuth in your config file.
I'm trying to integrate the Omnipay Paypal package with my Laravel 4.1 application. I've installed the laravel-omnipay package, as suggested by Omnipay, and followed the instructions on how to set it up.
I've added the laravel-omnipay package to both the providers array and the aliases array in the app.php file of Laravel. The config file has also been created.
My composer.json has the following requirements:
"ignited/laravel-omnipay": "1.*",
"omnipay/paypal": "~2.0"
and the config file of ignited/laravel-omnipay looks like this:
<?php
return array(
// The default gateway to use
'default' => 'paypal',
// Add in each gateway here
'gateways' => array(
'paypal' => array(
'driver' => 'Paypal_Express',
'options' => array(
'solutionType' => '',
'landingPage' => '',
'headerImageUrl' => ''
)
)
)
);
But when I call $gateway = Omnipay::gateway('paypal'); I'm getting the error
Class '\Omnipay\Paypal\ExpressGateway' not found"
Is there something I'm forgetting? :I
I'm not familiar with ignited/laravel-omnipay specifically, so this may or may not be the problem, but you might try fixing the capitalisation on this line:
'driver' => 'PayPal_Express',
(note that PayPal has two capital P's).
Generally class names are not case sensitive in PHP, but if you are using a case-sensitive filesystem, then the composer autoloader will not be able to find the right class.
Try composer dumpautoload to load new classes.
UPDATE:
Think in a term of service that is provided to your application by that new package. Find where is that service linked to application. It is usually done through ServiceProviders class. If there is no bug, it should be easy, following simple business rule to see how is provider related to main app.
So, you have one entity (provider) that should communicate with another.
That communication is done through simple rules. This is the best way to learn Laravel. It helps to think in a term of business rules, rather then to stare at code which is often very abstract.
Ok so I have setup an advanced application in Yii2 and it is all working but now I want to install my own bootstrap which has 48 cols and a gutter width of 20px.
The only way I currently see is to actually maintain my own repo of it in GitHub or something.
What is the best way with composer controlling everything I do to achieve this?
Currently the best way I can see is to add this to your config:
'assetManager' => [
'bundles' => [
'yii\bootstrap\BootstrapAsset' => [
'sourcePath' => null,
'css' => ['css/bootstrap.css']
],
],
],
I am completely open to better suggestions.