路径别名无效:Yii2 中的@mdm/admin/messages?

Invalid path alias: @mdm/admin/messages in Yii2?

这是我的 common\config\main.php 文件,我在其中添加了两个模块。

'modules'    => [
    'admin' => [
        'class'  => 'mdm\admin\Module',
        'layout' => '//rbac/main-rbac',

    ],
    'audit' => [
        'class'       => 'bedezign\yii2\audit\Audit',
        'layout'      => '//audit/main-audit',
        'accessUsers' => [1, 2], //static id to test
    ],

这在我的本地 wamp 服务器上工作正常,但在通过 docker 安装后,它们都在我的 Ubuntu 服务器上抛出错误。

这里是错误:

Invalid path alias: @bedezign/yii2/audit/web/assets on click the audit module
Invalid path alias: @mdm/admin/messages on click the rbac module

这是我的 vendor/yiisoft/extension.php

<?php

$vendorDir = dirname(__DIR__);

return array (
  'yiisoft/yii2-swiftmailer' => 
  array (
    'name' => 'yiisoft/yii2-swiftmailer',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/swiftmailer' => $vendorDir . '/yiisoft/yii2-swiftmailer/src',
    ),
  ),
  '2amigos/yii2-chartjs-widget' => 
  array (
    'name' => '2amigos/yii2-chartjs-widget',
    'version' => '2.1.2.0',
    'alias' => 
    array (
      '@dosamigos/chartjs' => $vendorDir . '/2amigos/yii2-chartjs-widget/src',
    ),
  ),
  'bedezign/yii2-audit' => 
  array (
    'name' => 'bedezign/yii2-audit',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@bedezign/yii2/audit' => $vendorDir . '/bedezign/yii2-audit/src',
    ),
    'bootstrap' => 'bedezign\yii2\audit\Bootstrap',
  ),
  'kartik-v/yii2-krajee-base' => 
  array (
    'name' => 'kartik-v/yii2-krajee-base',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/base' => $vendorDir . '/kartik-v/yii2-krajee-base/src',
    ),
  ),
  'kartik-v/yii2-widget-select2' => 
  array (
    'name' => 'kartik-v/yii2-widget-select2',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/select2' => $vendorDir . '/kartik-v/yii2-widget-select2/src',
    ),
  ),
  'yii2mod/yii2-enum' => 
  array (
    'name' => 'yii2mod/yii2-enum',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/enum' => $vendorDir . '/yii2mod/yii2-enum',
    ),
  ),
  'yii2mod/yii2-editable' => 
  array (
    'name' => 'yii2mod/yii2-editable',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/editable' => $vendorDir . '/yii2mod/yii2-editable',
    ),
  ),
  'yii2mod/yii2-moderation' => 
  array (
    'name' => 'yii2mod/yii2-moderation',
    'version' => '1.2.0.0',
    'alias' => 
    array (
      '@yii2mod/moderation' => $vendorDir . '/yii2mod/yii2-moderation',
    ),
  ),
  'yii2mod/yii2-behaviors' => 
  array (
    'name' => 'yii2mod/yii2-behaviors',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/behaviors' => $vendorDir . '/yii2mod/yii2-behaviors',
    ),
  ),
  'paulzi/yii2-sortable' => 
  array (
    'name' => 'paulzi/yii2-sortable',
    'version' => '1.0.2.0',
    'alias' => 
    array (
      '@paulzi/sortable' => $vendorDir . '/paulzi/yii2-sortable',
    ),
  ),
  'paulzi/yii2-adjacency-list' => 
  array (
    'name' => 'paulzi/yii2-adjacency-list',
    'version' => '2.2.0.0',
    'alias' => 
    array (
      '@paulzi/adjacencyList' => $vendorDir . '/paulzi/yii2-adjacency-list',
    ),
  ),
  'asofter/yii2-imperavi-redactor' => 
  array (
    'name' => 'asofter/yii2-imperavi-redactor',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/imperavi' => $vendorDir . '/asofter/yii2-imperavi-redactor/yii/imperavi',
    ),
  ),
  'yii2mod/yii2-comments' => 
  array (
    'name' => 'yii2mod/yii2-comments',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/comments' => $vendorDir . '/yii2mod/yii2-comments',
    ),
  ),
  'mdmsoft/yii2-admin' => 
  array (
    'name' => 'mdmsoft/yii2-admin',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@mdm/admin' => $vendorDir . '/mdmsoft/yii2-admin',
    ),
  ),
  'linslin/yii2-curl' => 
  array (
    'name' => 'linslin/yii2-curl',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@linslin/yii2/curl' => $vendorDir . '/linslin/yii2-curl',
    ),
  ),
  'yiisoft/yii2-faker' => 
  array (
    'name' => 'yiisoft/yii2-faker',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/faker' => $vendorDir . '/yiisoft/yii2-faker/src',
    ),
  ),
  'darkdrim/yii2-simplehtmldom' => 
  array (
    'name' => 'darkdrim/yii2-simplehtmldom',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@darkdrim/simplehtmldom' => $vendorDir . '/darkdrim/yii2-simplehtmldom',
    ),
  ),
  'insolita/yii2-migration-generator' => 
  array (
    'name' => 'insolita/yii2-migration-generator',
    'version' => '3.1.0.0',
    'alias' => 
    array (
      '@insolita/migrik' => $vendorDir . '/insolita/yii2-migration-generator',
    ),
    'bootstrap' => 'insolita\migrik\Bootstrap',
  ),
  'kartik-v/yii2-widget-fileinput' => 
  array (
    'name' => 'kartik-v/yii2-widget-fileinput',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/file' => $vendorDir . '/kartik-v/yii2-widget-fileinput/src',
    ),
  ),
  'kartik-v/yii2-widget-datepicker' => 
  array (
    'name' => 'kartik-v/yii2-widget-datepicker',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@kartik/date' => $vendorDir . '/kartik-v/yii2-widget-datepicker/src',
    ),
  ),
  'yiisoft/yii2-httpclient' => 
  array (
    'name' => 'yiisoft/yii2-httpclient',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/httpclient' => $vendorDir . '/yiisoft/yii2-httpclient/src',
    ),
  ),
  'himiklab/yii2-recaptcha-widget' => 
  array (
    'name' => 'himiklab/yii2-recaptcha-widget',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@himiklab/yii2/recaptcha' => $vendorDir . '/himiklab/yii2-recaptcha-widget/src',
      '@himiklab/yii2/recaptcha/tests' => $vendorDir . '/himiklab/yii2-recaptcha-widget/tests',
    ),
  ),
  'yiisoft/yii2-imagine' => 
  array (
    'name' => 'yiisoft/yii2-imagine',
    'version' => '2.1.1.0',
    'alias' => 
    array (
      '@yii/imagine' => $vendorDir . '/yiisoft/yii2-imagine/src',
    ),
  ),
  'yii2tech/file-storage' => 
  array (
    'name' => 'yii2tech/file-storage',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2tech/filestorage' => $vendorDir . '/yii2tech/file-storage/src',
    ),
  ),
  'yii2tech/ar-file' => 
  array (
    'name' => 'yii2tech/ar-file',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2tech/ar/file' => $vendorDir . '/yii2tech/ar-file',
    ),
  ),
  'yii2mod/yii2-markdown' => 
  array (
    'name' => 'yii2mod/yii2-markdown',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/markdown' => $vendorDir . '/yii2mod/yii2-markdown',
    ),
  ),
  'rmrevin/yii2-fontawesome' => 
  array (
    'name' => 'rmrevin/yii2-fontawesome',
    'version' => '3.9999999.9999999.9999999-dev',
    'alias' => 
    array (
      '@rmrevin/yii/fontawesome' => $vendorDir . '/rmrevin/yii2-fontawesome',
    ),
  ),
  'yii2mod/yii2-cms' => 
  array (
    'name' => 'yii2mod/yii2-cms',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii2mod/cms' => $vendorDir . '/yii2mod/yii2-cms',
    ),
    'bootstrap' => 'yii2mod\cms\Bootstrap',
  ),
  'yiisoft/yii2-queue' => 
  array (
    'name' => 'yiisoft/yii2-queue',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/queue' => $vendorDir . '/yiisoft/yii2-queue/src',
      '@yii/queue/amqp' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/amqp',
      '@yii/queue/amqp_interop' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/amqp_interop',
      '@yii/queue/beanstalk' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/beanstalk',
      '@yii/queue/db' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/db',
      '@yii/queue/file' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/file',
      '@yii/queue/gearman' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/gearman',
      '@yii/queue/redis' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/redis',
      '@yii/queue/sync' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/sync',
      '@yii/queue/sqs' => $vendorDir . '/yiisoft/yii2-queue/src/drivers/sqs',
    ),
  ),
  'yiisoft/yii2-bootstrap' => 
  array (
    'name' => 'yiisoft/yii2-bootstrap',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/bootstrap' => $vendorDir . '/yiisoft/yii2-bootstrap/src',
    ),
  ),
  'yiisoft/yii2-redis' => 
  array (
    'name' => 'yiisoft/yii2-redis',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/redis' => $vendorDir . '/yiisoft/yii2-redis/src',
    ),
  ),
  'yiisoft/yii2-debug' => 
  array (
    'name' => 'yiisoft/yii2-debug',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/debug' => $vendorDir . '/yiisoft/yii2-debug/src',
    ),
  ),
  'yiisoft/yii2-gii' => 
  array (
    'name' => 'yiisoft/yii2-gii',
    'version' => '9999999-dev',
    'alias' => 
    array (
      '@yii/gii' => $vendorDir . '/yiisoft/yii2-gii/src',
    ),
  ),
  'froala/yii2-froala-editor' => 
  array (
    'name' => 'froala/yii2-froala-editor',
    'version' => '2.9.3.0',
    'alias' => 
    array (
      '@froala/froalaeditor' => $vendorDir . '/froala/yii2-froala-editor/src',
    ),
  ),
);

这是我的 htacces 文件

Options -Indexes

<IfModule mod_rewrite.c> 
  RewriteEngine on

  RewriteCond %{REQUEST_URI} !^public
  RewriteRule ^(.*)$ backend/web/ [L] 
</IfModule>

# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Allow from all
</Files>

# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]

试试这个别名

@bedezign/yii2-audit/web/assets
@mdmsoft/yii2-admin/messages

文档说 https://www.yiiframework.com/doc/guide/2.0/en/concept-aliases#extension-aliases 别名是作曲家包的名称。

Basically the composer update was not generated the extension.php properly. There was the alias issue which worked after delet the vendor folder on server and update the composer again.