After running compilation code

php bin/magento setup:di:compile

I'am getting the following error

Fatal error: Cannot use 'Void' as class name as it is reserved in /va r/www/html/m2/vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Voi d.php on line 9

My php version is 7.0.20-2

also while placing an order I'm getting following error

An error occurred on the server. Please try to place the order again

Can any one help me to resolve this ?



Here is how to fix it:

  1. 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">
  2. Edit vendor/magento/module-sales/Block/Adminhtml/Order/Invoice/View.php line 242:

    - return $this->getUrl('sales/*/void', ['invoice_id' => $this->getInvoice()->getId()]);
    + return $this->getUrl('sales/*/voidInvoice', ['invoice_id' => $this->getInvoice()->getId()]);
  3. Edit vendor/magento/module-sales/Block/Adminhtml/Order/Creditmemo/View.php line 183:

    - return $this->getUrl('sales/*/void', ['creditmemo_id' => $this->getCreditmemo()->getId()]);
    + return $this->getUrl('sales/*/voidCreditmemo', ['creditmemo_id' => $this->getCreditmemo()->getId()]);
  4. Edit vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Void.php line 9:

    - class Void extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
    + class VoidInvoice extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
  5. Edit vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Void.php line 10:

    - class Void extends \Magento\Backend\App\Action
    + class VoidCreditmemo extends \Magento\Backend\App\Action
  6. Rename




  7. Rename




taken from https://mage2.pro/t/topic/2433/2

Note: It is always recommended to copy files from vendor folder to app/code area and then work on them to prevent issues while upgrading Magento.

  • how can i create or re-write these file inside app/code can you give an example i'm little bit confused about re-writing code in vendor files. i need to rewrite this file in code folder "vendor/magento/module-sales/etc/webapi.xml"
    – amith lal
    Jul 5 '17 at 7:12
  • Copy webapi.xml file from vendor/magento/module-sales/etc folder and put it under app/code/Magento_Sales/etc folder. Jul 5 '17 at 7:52
  • @ Mohit Kumar Arora so we are using "Magento_Sales " insted of "module-sales" is it?
    – amith lal
    Jul 5 '17 at 8:38
  • Yes, you are right. Jul 5 '17 at 10:43
  • @ Mohit Kumar Arora do i need to make a new module for this?
    – amith lal
    Jul 7 '17 at 5:15

I think its usefull for you

I had same problem before, that time I used php version 7.1.X, I reduced Php version 7.1.X to php 7.0.8 its works fine for me

Magento 2.1. System requirement http://devdocs.magento.com/guides/v2.1/install-gde/system-requirements-tech.html

  • but my php version is 7.0.2
    – amith lal
    Jul 5 '17 at 7:40
  • @Amith You mentioned php -7.0.20. Jul 5 '17 at 8:07
  • @ Rajkumar .E ya i have alredy mentioned it but you say about php version 7.1.X,
    – amith lal
    Jul 5 '17 at 8:39
  • @Amith Yes, when I got error using php 7.1.X, not php7.0.X. But I got same error before. Jul 5 '17 at 8:44
  • .Ev in my case i have checked php version using phpinfo function and i got this my version is not 7.1 then why i get this error
    – amith lal
    Jul 5 '17 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.