我尝试了一些方法来为本地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.
我想我将别名文件放在错误的目录中,您能提供正确的路径吗?
答案 0 :(得分:4)
别名文件位置不是唯一的问题,因为您正在运行Drush9.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
)中使用的用户别名位置,但是您可以注册可以在{{ 1}}配置文件。可以通过运行以下命令自动设置旧的Drush 8路径:
~/.drush/drush.yml
它将以下内容写入drush core:init
:
~/.drush/drush.yml
例如,在您的案例中,可以为文件 executive-coatings 别名为 ecc 的网站定义 local 环境(可提供)该位置已如上所述进行注册)drush:
paths:
alias-path:
- '${env.home}/.drush/sites'
- /etc/drush/sites
。
您还可以在以下位置(该网站的项目根目录下)为给定网站定义 environment 别名(例如@ dev,@ preprod等),使用< em> self 在文件命名中):
~/.drush/sites/ecc.site.yml
有用的链接:
-https://github.com/drush-ops/drush/blob/master/examples/example.site.yml
-https://github.com/consolidation/site-alias