提问人:footy 提问时间:2/10/2023 更新时间:2/10/2023 访问量:193
phpcode 嗅探器无法在 Magento 模块中运行
phpcode sniffer unable to run in magento module
问:
我正在尝试在我的 magento 模块项目中安装 phpcodesniffer。以下是我的composer.json
{
"name": "test/myModule",
"description": "testin",
"type": "magento2-module",
"version": "1.0.0",
"require": {
"php": "^8.1"
},
"require-dev": {
"squizlabs/php_codesniffer": "3.*",
"magento/magento-coding-standard": "^31.0"
},
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Test\\Module\\": ""
}
}
}
现在我可以在我的文件夹中成功运行 composer update/install。但是,当我运行该命令时,我收到如下错误vendor/bin/phpcs --standard=Magento2 ./
PHP Fatal error: Uncaught Error: Class "Magento\Framework\Component\ComponentRegistrar" not found in /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/registration.php:2
Stack trace:
#0 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/composer/autoload_real.php(55): require()
#1 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/composer/autoload_real.php(38): composerRequireabd7530303d7978f314768d362cfeb3f()
#2 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/autoload.php(25): ComposerAutoloaderInitabd7530303d7978f314768d362cfeb3f::getLoader()
#3 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/squizlabs/php_codesniffer/autoload.php(79): include('...')
#4 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/squizlabs/php_codesniffer/bin/phpcs(17): PHP_CodeSniffer\Autoload::load()
#5 /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/vendor/bin/phpcs(120): include('...')
#6 {main}
thrown in /home/cloudpanel/htdocs/magento2.mgt/app/code/Test/Module/registration.php on line 2
如何在这里运行php代码嗅探器?
答: 暂无答案
评论
not found in … Test/Module/registration.php
Test/Module/registration.php
"files": [ "registration.php" ],