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