yii 安裝及配置

MeditationTm發表於2021-09-10

安裝

透過 Composer 安裝

透過如下命令:

composer create-project --prefer-dist yiisoft/yii2-app-basic 自己的應用名稱

安裝後透過如下命令訪問應用 :

http://localhost/應用名稱/web/

配置

Database

編輯 config/db.php :

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

目錄結構

  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/                contains the entry script and Web resources
本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章