Nas*_*imi 6 php alias drupal drush 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
Run Code Online (Sandbox Code Playgroud)
输出:
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
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用drush别名时,它不起作用。这是我的别名文件:
$aliases['local'] = array(
'uri' => 'localhost:81/executive-coatings',
'root' => 'C:/wamp64/www/executive-coatings',
'path-aliases' => array(
'%dump-dir' => '/tmp',
),
);
Run Code Online (Sandbox Code Playgroud)
连续 drush @local status收益[preflight] The alias @local could not be found.
我想我将别名文件放在错误的目录中,您能提供正确的路径吗?
Alias file location is not your only issue here, because you are running Drush 9.x. Here the major changes between Drush 8.x and Drush 9.x regarding aliases :
Site aliases are no longer PHP files but YAML files. Hopefully Drush 9.x comes with a command to convert your old drush 8 aliases :
drush site:alias-convert
Run Code Online (Sandbox Code Playgroud)The user alias locations used in Drush 8 (~/.drush/sites, /etc/drush/sites) are by default no longer parsed, but you can register any location where alias files may be placed in your ~/.drush/drush.yml configuration file. Setting the old Drush 8 paths can be done automatically by running :
drush core:init
Run Code Online (Sandbox Code Playgroud)
It writes the following to ~/.drush/drush.yml :
drush:
paths:
alias-path:
- '${env.home}/.drush/sites'
- /etc/drush/sites
Run Code Online (Sandbox Code Playgroud)
For example in your case, defining a local environment for the website executive-coatings aliased ecc may be done in the file (provided this location is registered as mentioned above) ~/.drush/sites/ecc.site.yml.
You can also define environment aliases (eg. @dev, @preprod, etc.) for a given website at the following location (under the project root of that website, using self in the file naming) :
<DRUPAL_ROOT>/drush/sites/self.site.yml
Run Code Online (Sandbox Code Playgroud)Useful links :
- https://github.com/drush-ops/drush/blob/master/examples/example.site.yml
- https://github.com/consolidation/site-alias