【Magento 2学习】

1.

Q:/usr/bin/env: ‘php ’: No such file or directory

A:输入:set ff=unix 再输入:wq 保存

Q:There are no commands defined in the "setup" namespace.

A:php bin/magento list

Q:Warning: Invalid argument supplied for foreach() in /var/www/html/vendor/ma gento/module-eav/Model/Config.php on line 341

A:Two ways to fix this issue.Fixed it by changing the line 96 in this file vendor/magento/module-config/Model/Config/Structure/Converter.php. Actual Code: if ($children->length && trim($child->nodeValue, " ") === '') { Corrected Code: if ($children->length && trim($child->nodeValue, " ") === '') { Check if your XML file has any tab spacing within it. If so, remove the tab spacing and replace them with normal single spaces.

2.

删除通过docker-compose生成的数据卷:docker-compose down --volumes

创建管理员 php bin/magento admin:user:create --admin-user=admin --admin-password=admin123 --admin-firstname=Kayla --admin-lastname=Cheng

docker-compose安装: sudo -i
                   curl -L https://github.com/docker/compose/releases/download/1.6.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
            chmod +x /usr/local/bin/docker-compose exit docker-compose --version

常用命令:
php bin/magento setup:static-content:deploy -f 编译静态资源
php bin/magento indexer:reindex     刷新索引
php bin/magento setup:upgrade  更新数据
php bin/magento moudule:enable Test_Hello(module的名称)  启用此module
php bin/magento setup:db-schema:upgrade
php bin/magento setup:db-data:upgrade
php bin/magento deploy:mode:set production/developer/default
 1.遇到的问题

- Installing magento/framework (102.0.2): Downloading 

[ComposerDownloaderTransportException] 
The 'https://repo.magento.com/archives/magento/framework/magento-framework-102.0.2.0.zip' URL could not be accessed: HTTP/1.1 403 Forbidden

解决办法:$find / -name auth.json 

    $sudo vi /home/vagrant/.config/composer/auth.json

{
    "http-basic": {
        "repo.magento.com": {
            "username": "xxx正确的usernamexxx",
            "password": "xxx正确的passwordxxx"
        }
    }
}            

  

原文地址:https://www.cnblogs.com/paopaocheng/p/11249179.html