1

This is my code in my module observer

namespace Customtest\Customlogin\Observer;
use \Magento\Framework\Event\Observer;
use \Magento\Framework\Event\ObserverInterface;
class CustomerLogin implements ObserverInterface
{
 protected $_request;
 public function __construct(
 \Magento\Framework\App\RequestInterface $request
 ) {
 $this->_request = $request;
 }
 public function execute(Observer $observer) {
 $post = $this->_request->getPost('login');
 var_dump($post) ;
 }
}

This code is work in localhost but when I upload to live server, Browser

show "http error 500"

Fatal error: Uncaught TypeError: Argument 1 passed to Customtest\Customlogin\Observer\CustomerLogin::__construct() must implement interface Magento\Framework\App\RequestInterface, instance of Magento\Framework\App\ResponseFactory given, called in /opt/stack/magento2/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111 and defined in /opt/stack/magento2/apps/magento/htdocs/app/code/Customtest\Customlogin/Observer/CustomerLogin.php:15 Stack trace: #0 /opt/stack/magento2/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111): Customtest\Customlogin\Observer\CustomerLogin->__construct(Object(Magento\Framework\App\ResponseFactory), Object(Magento\Framework\Url)) #1 /opt/stack/magento2/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Customtest\Hello...', Array) #2 /opt/stack/magento2/apps/magento/htdocs/vendor/magento/framework/ObjectManager/Obj in /opt/stack/magento2/apps/magento/htdocs/app/code/Customtest\Customlogin/Observer/CustomerLogin.php on line 15

Manoj Deswal
5,80325 gold badges29 silver badges50 bronze badges
asked Oct 25, 2017 at 9:24
1
  • I have updated answer. Commented Oct 25, 2017 at 10:34

1 Answer 1

1

I fixed it using

php bin/magento setup:upgrade
php bin/magento setup:di:compile
Manoj Deswal
5,80325 gold badges29 silver badges50 bronze badges
answered Oct 27, 2017 at 8:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.