36

Today I received the same-type error: PHP Fatal error: Cannot declare class Class\Name\Here , because the name is already in use in /var/www/m2/magento2/app/code/path/to/the/class.php on line 100 where the line 100 is end of the file. Approximately after 4 hours of debugging I really find the reason: a misprint in the namespace declaration. Till the ...


27

pay attention: I've experienced that in developer mode deleting the pub/static will break the mechanism because you get rid of the .htaccess file that makes the magic in that folder. If you keep the pub/static/.htaccess file in developer mode you don't need to run any compilation command: Magento will create symlinks to files as soon as they are requested. ...


27

Go to Below File /vendor/vertex/module-tax/Model/FlexField/Processor/OrderCurrencyGetterProcessor.php At the end of the "use" clauses in add the following two lines: use Vertex\Tax\Model\FlexField\Processor\InvoiceFlexFieldProcessorInterface; use Vertex\Tax\Model\FlexField\Processor\TaxCalculationFlexFieldProcessorInterface; and run again Below ...


24

The command setup:di:compile command generates the contents of the var/di folder in Magento <2.2 and generated for Magento >= 2.2 According to Magento, this serves the following purpose: Application code generation (factories, proxies, and so on) Area configuration aggregation (that is, optimized dependency injection configurations per area) ...


23

I experienced this problem and put breakpoints on each instance of 'No tokens were provided' I could find using: grep -lr 'No tokens were provided' vendor/ which returned: vendor/zendframework/zend-code/src/Scanner/ConstantScanner.php vendor/zendframework/zend-code/src/Scanner/TokenArrayScanner.php vendor/zendframework/zend-code/src/Scanner/...


22

Read More: blog.mageprince.com Inject \Magento\Framework\Serialize\Serializer\Json class for serialize and unserialize values. protected $serialize; public function __construct( ... \Magento\Framework\Serialize\Serializer\Json $serialize, ... ) { $this->serialize = $serialize; } Now use $this->serialize $value = $this->serialize-&...


19

Here is how to fix it: edit vendor/magento/module-sales/etc/webapi.xml line 112: - <route url="/V1/invoices/:id/void" method="POST"> + <route url="/V1/invoices/:id/voidInvoice" method="POST"> edit vendor/magento/module-sales/Block/Adminhtml/Order/Invoice/View.php line 242: - return $this->getUrl('sales/*/void', ['invoice_id' => $this-&...


14

I run into the same problem. It seems only a speeling problem: https://github.com/magento/magento2/issues/24930#issuecomment-543949135 So it is better to change only the namespace spelling without adding the two use-lines: namespace Vertex\Tax\Model\FlexField\Processor; FlexField instead of Flexfield It could make a difference for external functions that ...


13

It's not mandatory to run setup:di:compile command everytime but if you have done any code change specially with factory methods ,proxy, add plugins or any code compilation then you must need to run this command. More Details magento setup:di:compile in order to generate necessary files. Both options ends up with generating classes in MAGENTO_ROOT/var/...


12

You can do this by follow this step : Go to : /var/www/html/YourMagento/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php Find this line : $modulePaths = $this->componentRegistrar->getPaths(ComponentRegistrar::MODULE); Replace this below line and add path of the module which you want to compile like this : $modulePaths = ['...


11

As per my understanding. The whole process of setup:di:compile is divided into the 7(100%) sub code generations process. Proxies(1/7) Repositories(2/7) Service(3/7) Application(4/7) Interceptors(5/7) Area Configuration(6/7) Interception(7/7) Each process shows its Compilation part(ex - 1/7) and its percentage(ex - 10%/100%). When single process end ,...


10

Here, if you want to know HOW to find those empty files, just run this command (assuming you have linux, and access to the shell) in your magento root directory, or whatever directory you are working in that might have empty files... find -type f -empty


10

Cleaning a cache type deletes all items from enabled Magento cache types only. In other words, this option does not affect other processes or applications because it cleans only the cache that Magento uses. Flushing a cache type purges the cache storage, which might affect other processes applications that are using the same storage. In short: Clean is a ...


9

You don't need to run it. You can simply delete the var/generation directory. You only really even need to do this when you create a new constructor or change or reorder the arguments being passed into one of your class constructors. I actually opt to just delete the entire var directory.


8

A more direct answer to this problem is: At the top of the file: {magento-base}/vendor/magento/data-migration-tool/tests/unit/testsuite/Migration/Step/UrlRewrite/Version11410to2000Test.php Replace: namespace Migration\Step; With: namespace Migration\Step\UrlRewrite;


7

This is because your parent constructor has redundant arguments or not correct . In your case, need to remove arguments: $storeManager and $metadataPool. app\code\Custom\Module\Model\ResourceModel\Posts\Grid\Collection.php parent::__construct( $entityFactory, $logger, $fetchStrategy, $eventManager, //$storeManager, &...


7

The error Incompatible argument type: Required type: string. Actual type: \SkyFox\Supplier\UI\DataProvider\Supplier\name; File is triggered because of the missing type in the __construct phpDoc annotation. So the __construct phpDoc annotation need to be as below: /** * DataProvider constructor. * @param string $name * @param string $primaryFieldName * @...


6

I found that in the LN module 2 different namespace declarations was used: Layerednavigation and LayeredNavigation. When code is compiled all di class arguments was stored in the array where the class name with namespace was used as key (string). The problem is in the autoloader: it can not find the files because array keys are case sensitive in the php and ...


6

Just follow : to debug blank white screen and CSS,JS page load design issue. open terminal run following command cd magento-root-folder php bin/magento setup:upgrade then don't compile just deploy php bin/magento setup:static-content:deploy and php bin/magento indexer:reindex Make sure “rewrite_module” on your production server. chown -R ...


6

Although question have already been answered and accepted as well, but i thought it would be nice to compile all points in single answer for better understanding and for other users who are searching for such understanding: So we will go part by part of question(s): Question Part A : Kindly Clear Difference Between php bin/magento cache:flush and cache:...


6

If like me you can't edit the file (because our CD will fail) follow these steps: In the root of your project, create a directory patches/composer Create a file called vendor-vertex-compilation-issue.diff In your composer.json add this to the list of "require" "cweagans/composer-patches": "1.6.7" Still in your composer.json add this to the extras "...


5

Try with below code, Remove var folder and run command of compile, class BuyingListIndex extends \Magento\Framework\View\Element\Template { public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Custom\Module\Model\ResourceModel\Posts\CollectionFactory $collectionFactory, \Custom\Module\Model\Posts $posts, ...


5

I don't think Magento 2 is yet compatible with php 7.1-alpha, but this is an alarm signal. I think you should report this on github. It could be an issue in the near future,


5

Seems you have an empty file which is parsed by the \Magento\Setup\Module\Di\Code\Reader\ClassesScanner, which uses the PHP token_get_all method. The exception is thrown, if the method does not return any value, which is the case on an empty file.


5

Yes you will need to run bin/magento setup:di:compile everytime when you added new classes with dependencies (constructor parameters) or changed dependencies of existing classes.(di.xml) Another main thing here is Code compilation. setup:di:compile command compiles your code everytime. its compile the code and check is there any error in that code or ...


5

if you want to get rid of any of the module from compilation, You just need to remove registration.php file from your module. Removing registration.php file from module, module will not consideration inside di:compile if you just disable module using command at that time compilation consider all of those files of module. Best way is remove registration....


5

As per magento 2.2 release note, Now you can not use direct serialize and unserialize PHP functions. To solve this issue Inject \Magento\Framework\Serialize\Serializer\Json class for serialize and unserialize values. public function __construct( ... \Magento\Framework\Serialize\Serializer\Json $serialize, ... ) { $this->serialize = $...


5

bin/magento setup:di:compile This command is used when you make change in di file or create new plugin or preference. bin/magento setup:upgrade This command is used when you make a new module and you want to used it in your magento project. bin/magento indexer:indexer When you make a change on frontend then you need to use this command.


4

Does that mean, each individual file in pub/static is generated when it is requested and you never need to call setup:static-content:deploy? This contradicts my experience. Or can I delete any files and they will be regenerated? Yes. But according to my experience this doesn't work most of the time. Might be a bug. Better solution is to delete pub/static ...


4

from my experience, you don't need to run any commands for code / static-file generation in developer mode. If the static files were not generated, there might be another issue. I see two reasons for that on first sight: developer mode is not working correctly. maybe the activation failed for some reason the rewrite for static files on the pub/static.php ...


Only top voted, non community-wiki answers of a minimum length are eligible