php - Drush 9 别名文件应该位于 Drupal 8 中的哪个位置?
问题描述
我已经尝试了一些方法来为我的本地 Drupal 项目创建别名,我指的是:
https ://www.drupal.org/node/1401522
https://www.drupal.org/project/drush/issues/ 831272
https://www.drupal.org/project/drush/issues/786766
我可以通过运行以下命令进行连接:
drush --root=C:/wamp64/www/executive-coatings --uri=http://localhost:81/executive-coatings status
输出 :
Drupal version : 8.6.13
Site URI : http://localhost:81/executive-coatings
DB driver : mysql
DB hostname : localhost
DB port : 3306
DB username : root
DB name : dev_ecc_new
Database : Connected
Drupal bootstrap : Successful
Default theme : ecc_front
Admin theme : adminimal_theme
PHP binary : C:\wamp64\bin\php\php7.2.10\php.exe
PHP config : C:\wamp64\bin\php\php7.2.10\php.ini
PHP OS : WINNT
Drush script : C:\wamp64\www\executive-coatings\vendor\bin\drush.phar
Drush version : 9.6.2
Drush temp : C:\Users\k\AppData\Local\Temp
Drush configs : C:/Users/k/.drush/drush.yml
C:/wamp64/www/executive-coatings/vendor/drush/drush/drush.yml
Install profile : minimal
Drupal root : C:\wamp64\www\executive-coatings
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp
但是当我尝试使用 drush 别名时它不起作用。这是我的别名文件:
$aliases['local'] = array(
'uri' => 'localhost:81/executive-coatings',
'root' => 'C:/wamp64/www/executive-coatings',
'path-aliases' => array(
'%dump-dir' => '/tmp',
),
);
跑步 drush @local status
回报[preflight] The alias @local could not be found.
我想我把我的别名文件放在了错误的目录中,你能提供正确的路径吗?
解决方案
别名文件位置不是您唯一的问题,因为您正在运行 Drush 9.x。这里 Drush 8.x 和 Drush 9.x 之间关于别名的主要变化:
站点别名不再是 PHP 文件,而是 YAML 文件。希望 Drush 9.x 附带一个命令来转换您的旧 drush 8 别名:
drush site:alias-convert
默认情况下,Drush 8 (
~/.drush/sites
,/etc/drush/sites
) 中使用的用户别名位置不再被解析,但您可以在~/.drush/drush.yml
配置文件中注册可能放置别名文件的任何位置。可以通过运行自动设置旧的 Drush 8 路径:drush core:init
它将以下内容写入
~/.drush/drush.yml
:drush: paths: alias-path: - '${env.home}/.drush/sites' - /etc/drush/sites
例如,在您的情况下,可以在文件中为网站 execution -coatings别名ecc定义本地环境(前提是该位置已按上述方式注册)。
~/.drush/sites/ecc.site.yml
您还可以在以下位置(在该网站的项目根目录下,在文件命名中使用self )为给定网站定义环境别名(例如,@dev、@preprod 等):
<DRUPAL_ROOT>/drush/sites/self.site.yml
有用的链接:
- https://github.com/drush-ops/drush/blob/master/examples/example.site.yml
- https://github.com/consolidation/site-alias
推荐阅读
- python - 如何将一个模型与另一个模型连接两次?
- javascript - 保存密钥的最佳方法
- sql - 我收到“未为参数 1 指定值”和 2 错误,您能告诉我这里哪里出错了吗?
- python - 如果我输入错误的凭据一次,它不会再次验证凭据,我认为是因为它不再检查 acc_number 和 acc_pass 之后,
- ios - 如何使用 watchos6 实时读取/写入氧饱和度
- powershell - 在 Powershell 中,获取连接路径以使用 $null 和空字符串
- sql - 是否存在可用作自定义自动收报机的应用程序/Windows 小部件?
- c++ - Cout 不生成任何东西(多项式插值)
- spring-boot - JBoss 忽略在 MANIFEST.MF of war 应用程序中声明的 Main-Class 和 Start-Class 属性
- html - 想要将照片中的文字更多地移动到中心