I have a website in Magento 2.3.2. This morning the website was in production mode.

I added a custom module (I don't think is related to this problem)

run bin/magento setup:upgrade, bin/magento c:f, bin/magento c:c

Then I deleted generated/code/* and generated/metadata/*

and run bin/magento deploy:mode:set production

When the compilation is in progress I receive an error in step 5/7

In ClassReader.php line 35:

Class Magento\Sales\Model\Order\Email\Sender\OrderSender does not exist

First, I thought the problem could be the new module, so I deleted...

But the problem still remain. I cannot set the production mode.


First of all, check if the class exists or not. If it does not exist then run composer update command

Hope this will help.

  • The class exists on vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php Namespace is Magento\Sales\Model\Order\Email\Sender; Class name is OrderSender – Francesco Mineo Jul 30 '20 at 13:35
  • try to run composer update command – Nits Jul 30 '20 at 16:56

try to run run bin/magento setup:di:compile

When I add a module in production mode I always run this

bin/magento set:up && bin/magento setup:di:compile

bin/magento setup:static-content:deploy

php bin/magento indexer:reindex && bin/magento c:f

You can put it in maintenance mode to do this too. Unless there is an error with your code it should work fine.

Hope it helps :D

  • I receive the error Class Magento\Sales\Model\Order\Email\Sender\OrderSender does not exist when run setup:di:compile on step 5/7 But the class exists – Francesco Mineo Aug 3 '20 at 7:43
  • It might be calling in a place that it doesn't, but try to clear things up, rm -rf pub/static/*; rm -rf var/view_preprocessed/*; rm -rf generated/*; and compile everything again, might as well delete vendor and run composer upgrade so it starts fresh – Rui Silva Aug 3 '20 at 8:55
  • In past, I had to edit some file of a vendor (I know is not a good practice), what happen if I run composer upgrade? – Francesco Mineo Aug 3 '20 at 9:22
  • The files might revert back to the original that's why you should not edit them, but try first to remove static, generated and view and compile everything. If you removed the new module and it was the one giving the error it might got stuck in one of that folders – Rui Silva Aug 3 '20 at 9:38
  • Btw to the person who downvoted, this is what I usually do, for you to downvote you might have a reason to do that so it'll be more helpful if you downvoted and after comment why you did it and, if you know, tell a better way to do it – Rui Silva Aug 4 '20 at 9: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.