controllermap in yii2 return 404 - yii

I walk around yii2 manual by copy this code in manual
'controllerMap' => [
'account' => 'yii\app\controllers\UserController',
'article' => [
'class' => 'yii\app\controllers\PostController',
'enableCsrfValidation' => false,
],
],
paste in netbean
just access it
already have UserController

Your namespace is wrong! If you look at documentation, the correct code is like this:
[
'controllerMap' => [
'account' => 'app\controllers\UserController',
'article' => [
'class' => 'app\controllers\PostController',
'enableCsrfValidation' => false,
],
],
]
But you have an extra yii in the beginning of the namespace, so yii\app\controllers\UserController must be app\controllers\UserController.
Also i think you have some problems in url rewriting. If I'm true, you can find an instrument for fixing it in http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#using-pretty-urls and yii2 url rewrite config.

Related

Cache mock exception after update Laravel 6.0

I have unit tests with Cache mocks. It worked well before update laravel to 6.0
After update I ran my tests and got an exception
Mockery\Exception\BadMethodCallException: Received
Mockery_2_Illuminate_Cache_CacheManager::driver(), but no expectations
were specified
Cache::shouldReceive('get')
->once()
->with('table_3_'.config('constants.league.premier').'_'.config('constants.sex.female'))
->andReturn(json_encode([
[
'id' => $team1->id,
'place' => 1
],
[
'id' => $team2->id,
'place' => 8
],
[
'id' => $team3->id,
'place' => 11
],
]));
$this->artisan('passport:transfer');
I have found the answer here - Laravel Feature Testing. Cache mocking not working! CacheManager::driver(), but no expectations were specified
but I don't understand why before update the test was ok

How to add aliases in yii2?

I have extracted mdmsoft extension in my backend/extensions/mdm folder. Added aliases in backend config main.php
'aliases' => [
'#mdm/admin' => '#backend/extensions/mdm'
]
Added module as
[
'modules' => [
'admin' => [
'class' => 'mdm\admin\Module'
]
]
],
It returns me error.Failed to instantiate component or class "mdm\admin\Module".
How I can manage the config file that MDM works from my backend folder
Maybe you have to add line below:
Yii::setAlias('#mdm', dirname(dirname(__DIR__)) . '/backend/extensions/mdm');
into common/config/bootstrap.php ?

How to include external files in a SocialEngine module

I have created a SocialEngine module named MyAwesomeModule that adds a signup step to existing SocialEngine signup process. It is in application/modules/Myawesomemodule. Besides the files in this directory, it also depends on other files e.g. several created specifically for this module and placed in application/modules/User. The problem that I have is that when I build a package for this module in http://example.com/install/sdk/build, it only includes the files residing within the module directory itself. Other files that are required for this module to work and need to be copied to external directories (application/modules/User) are not included in the package.
I tried adding the list of external files inside package info file i.e.application/packages/module-myawesomemodule-4.0.0.json before building the package as follows:
"application\/modules\/User": {
"type": "directory",
"path": "application\/modules\/User",
"structure": [
{
"path": "Plugin\/Signup\/Phone.php",
"dir": false,
"file": true,
"perms": "0644",
"size": 0,
"sha1": null
},
{
"path": "Form\/Signup\/Phone.php",
"dir": false,
"file": true,
"perms": "0644",
"size": 0,
"sha1": null
},
{
"path": "controllers\/PhoneController.php",
"dir": false,
"file": true,
"perms": "0644",
"size": 0,
"sha1": null
}
]
}
But, the external files named in the above snippet are not copied to the package when building. Also, it seems that the external files I named in the JSON file are gone in the destination package after installation.
How can I solve this problem?
This is much easier than I thought, thanks to this SocialEngine Community post.
All is required to add every file you want to your package is to include it in your manifest.php file for the module. As such:
return array(
'package' =>
array(
'type' => 'module',
'name' => 'advancedsmsplugin',
'version' => '4.0.0',
'sku' => 'com.company.sms',
'path' => 'application/modules/Advancedsmsplugin',
'title' => 'Advanced SMS Plugin',
'description' => 'Advanced SMS Plugin',
'author' => 'Company Ltd.',
'callback' =>
array(
'class' => 'Engine_Package_Installer_Module',
),
'actions' =>
array(
0 => 'install',
1 => 'upgrade',
2 => 'refresh',
3 => 'enable',
4 => 'disable',
),
'directories' =>
array(
0 => 'application/modules/Advancedsmsplugin',
),
'files' =>
array(
0 => 'application/languages/en/advancedsmsplugin.csv',
1 => 'application/modules/User/Form/Signup/Phone.php',
2 => 'application/modules/User/Plugin/Signup/Phone.php',
3 => 'application/testpackage.html'
),
),
);
?>

Laravel 5.0 Sweet Alert Class 'UxWeb\SweetAlert\SweetAlertServiceProvider' not found

please i have done these :
"require": {
"uxweb/sweet-alert": "~1.1",
}
'providers' => [
'UxWeb\SweetAlert\SweetAlertServiceProvider::class'
]
'aliases' => [
'Alert' => UxWeb\SweetAlert\SweetAlert::class
]
but i keep getting the error.
I was working under proxy therefore my internet connection was not working in the command line hence,
composer update
Was not working

Yii2 disable asset of a vendor module

I have installed yii2-admin module, located in /vendor/mdmsoft/yii2-admin but I don't want it to load its own asset bundle. It there any way to disable this module asset bundle?
Yes, it's possible and even mentioned in official docs here. One way to do it is through application config:
return [
// ...
'components' => [
'assetManager' => [
'bundles' => [
'mdm\admin\AdminAsset' => false,
],
],
],
];
Another way - during runtime through component:
\Yii::$app->assetManager->bundles['mdm\admin\AdminAsset'] = false;