Categories
Laravel

Laravel API POST methods request return a 419 status code when we browser by dev server.

If the browser cannot access the Laravel API post routes at localhost, it will always return an HTTP 419 error status, with the CSRF token mismatch exception. We need to changes in the Laravel app/Http/Middleware/VerifyCsrfToken.php file.

This code is located in the handle method of the parent class of VerifyCsrfToken.php, which is found at vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php.

Solution: Simply add the isReading() method to the file verifyCsrfToken.php to enable the POST method.

Categories
Laravel

Laravel – Failed to authenticate on SMTP server with username using 3 possible authenticators

If you still get following error (Failed to authenticate on SMTP server with username) when sending email please follow below steps.

Swift_TransportException

Failed to authenticate on SMTP server with username “yourid@gmail.com” using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code “535”, with message “535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials c17-20020a170902d49100b001624cd63bbbsm4334145plg.133 – gsmtp “. Authenticator PLAIN returned Expected response code 235 but got code “535”, with message “535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials c17-20020a170902d49100b001624cd63bbbsm4334145plg.133 – gsmtp “. Authenticator XOAUTH2 returned Expected response code 250 but got code “535”, with message “535-5.7.8 Username and Password not accepted. Learn more at 535 5.7.8 https://support.google.com/mail/?p=BadCredentials c17-20020a170902d49100b001624cd63bbbsm4334145plg.133 – gsmtp “.

Step 1:

Please login into your gmail account and click on “Manage your Google Account” button form right to your profile picture.

Manage your Google Account

Step 2:

Go to to Security tab form left menu and please turn on 2-Step Verification by using your Recovery Phone.

2-Step Verification

Step 3:

Click on App Password bar form Sign in to Google section.

App Password

Step 4:

Select the app and device you want to generate the app password for. And enter a platform name and click on GENERATE button to generate new password.

Generated password

Finally copy your new generated password and save it your self also use it to your other device or app where you want to send SMTP email.

Step 5:

Now change password on Laravel .env file MAIL_PASSWORD value with new generated password.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Hope it will help you.

Categories
React Native

React Native – EventEmitter removeListener Method has been deprecated

Warning: Receiving warning on the console.

removeListener Method has been deprecated

EventEmitter.removeListener(‘appStateDidChange’, …): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener.
EventEmitter.removeListener(‘appStateDidChange’, …): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener.
EventEmitter.removeListener(‘appStateDidChange’, …): Method has been deprecated. Please instead use remove() on the subscription returned by EventEmitter.addListener.

React Native Version 0.65+, removeListener is depreciated. You can use remove() isntead of removeListener

Example of React Native useEffect:

Another way to escape this warning

If you are sure that the deprecated use is happening in a dependency you cannot control, it is possible to silence these warnings. In your App.tsx or somewhere else add LogBox on that screen.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Hope it will help you.

Categories
Magento 2

Magento error – Unable to apply data patch for module Magento_Theme. In Gd2.php line 72

In PatchApplier.php line 170: Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file

In Gd2.php line 72: Wrong file

Finally Installation is complete 100% after done following changes:

Find validateURLScheme function in vendor\magento\framework\Image\Adapter\Gd2.php file. at line 96. Replace function with this: !file_exists($filename) Please find and change validateURLScheme function like below code.

Just add && !file_exists($filename)

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Hope it will help you.

Categories
Magento 2

Magento error – Could not validate a connection to Elasticsearch and Install using composer

Download Magento 2

Open SSH terminal on your server and run the following command to download and create new project. Previous post how to install Magento 2 on Windows XAMPP server.

Create The Database and Collect other information

Create new database and note Database name, database user name and database user password. Also site url, admin username, password, timezone and more. Run following command to install Magento 2.

Install/Setup Magento 2 by Command line

In SearchConfig.php line 81: Could not validate a connection to Elasticsearch. No alive nodes found in your cluster

If you got any error related with Elasticsearch then just disable some module related with Elasticsearch using run following command and again run install command.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Hope it will help you.

Categories
WordPress

How to fix invalid JSON response error in WordPress

Updating failed. The response is not a valid JSON response.

This error appears when edit and update your posts or pages on your WordPress website. You will see message saying “The response is not a valid JSON response” and updating that page would fail. In this article, I will show you how to fix the invalid JSON error in WordPress.

WordPress needs to communicate with the server while you are editing a post or page form WordPress admin and it getting responses from the web hosting server in the background. This response is in JSON format which is used to quickly transport data using JavaScript.

I getting this error when I move my wordpress website to another server.

Solution:

First please confirm your home and siteurl is ok on database wp_options table.

Please go to Settings => Permalinks page. From here, you need to review the WordPress permalink options. Please select “Post name” option form Permalink Settings and click on the Save Changes button to store your settings.

Permalink Settings

Also please confirm those code are available on the .htaccess file.

Now site is ready to edit post or page from WordPress admin.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Hope it will help you.

Categories
Magento 2

Magento 2 admin error: Product does not exists

After migrating Magento to version I am facing below issues while navigating to Product page.

Error: Class Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate does not exist

Also I am going to editing product in admin panel getting the below error

Error: Product does not exists

Product does not exists

In Magento 2 some version Magento created the LayoutUpdate file with the attributes custom_layout_update_file, When we revert back version, the attribute calling the file and cause the issue.

Solution:

Go to your Database and search in table eav_attribute table like below sql. If you will find two records and just remove them.

Find or Select query:

Delete query:

After delete two records from database run following command via cli

If you have redis, you will need to flush the cache from it.

redis-cli flushdb – Delete all the keys of the currently selected DB.
redis-cli flushall – Delete all the keys of all the existing databases, not just the currently selected one.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please SHARE this post.

Categories
Magento 2

Exception: Invalid template file: require_js.phtml in module: ‘Magento_Backend’ block’s name: ‘require.js’

To fix blank admin page on Magento 2.3 in Windows-10. This is the error what you will encounter when installing Magento 2.3 in Windows 10!

This error for the invalid template file is the difference between the use of “/” and “\” in the path. Windows uses “/” while Magento uses “\”.

The exception appear like this:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: ‘E:/xampp/htdocs/extendfeature/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml’ in module: ‘Magento_Backend’ block’s name: ‘require.js’

Open file vendor\magento\framework\View\Element\Template\File\Validator.php line no 138. Of find isPathInDirectories function in line 133

And change line 138 from

To

After make change find isPathInDirectories function like below code.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please LIKE and SHARE

Categories
Magento 2

Magento 2 Installation at 51% Error: (Wrong file in Gd2.php:64) Module ‘Magento_Theme’

I am having an issue during installing Magento 2 in localhost window10. I have updated my file like below and I can install in localhost. I am trying to solve by change on my php.ini

Also No UAC activate on WINDOWS 10 and Antivirus disabled. I have fetch the same error.

[ERROR]

InvalidArgumentException: Wrong file in E:\xampp\htdocs\extendfeature\vendor\magento\framework\Image\Adapter\Gd2.php:64 Stack trace: #0 E:\xampp\htdocs\extendfeature\vendor\magento\framework\Image.php(55): Magento\Framework\Image\Adapter\Gd2->open(‘E:/xampp/htdocs…’) #1 E:\xampp\htdocs\extendfeature\vendor\magento\framework\Image.php(36): Magento\Framework\Image->open() #2 E:\xampp\htdocs\extendfeature\vendor\magento\framework\ObjectManager\Factory\AbstractFactory.php(121): Magento\Framework\Image->__construct(Object(Magento\Framework\Image\Adapter\Gd2), ‘E:/xampp/htdocs…’) #3 E:\xampp\htdocs\extendfeature\vendor\magento\framework\ObjectManager\Factory\Dynamic\Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject(‘Magento\Framewo…’, Array) #4 E:\xampp\htdocs\extendfeature\vendor\magento\framework\ObjectManager\ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create(‘Magento\Framewo…’, Array) #5 E:\xampp\htdocs\extendfeature\vendor\magento\framework\Image\Factory.php(47): Magento\Framework\ObjectManager\ObjectManager->create(‘Magento\Framewo…’, Array) #6 E:\xampp\htdocs\extendfeature\vendor\magento\framework\View\Design\Theme\Image.php(127): Magento\Framework\Image\Factory->create(‘E:/xampp/htdocs…’) #7 E:\xampp\htdocs\extendfeature\vendor\magento\module-theme\Model\Theme\Registration.php(135): Magento\Framework\View\Design\Theme\Image->createPreviewImage(‘E:/xampp/htdocs…’) #8 E:\xampp\htdocs\extendfeature\vendor\magento\module-theme\Model\Theme\Registration.php(114): Magento\Theme\Model\Theme\Registration->_savePreviewImage(Object(Magento\Theme\Model\Theme\Data)) #9 E:\xampp\htdocs\extendfeature\vendor\magento\module-theme\Model\Theme\Registration.php(73): Magento\Theme\Model\Theme\Registration->_registerThemeRecursively(Object(Magento\Theme\Model\Theme\Data)) #10 E:\xampp\htdocs\extendfeature\vendor\magento\module-theme\Setup\Patch\Data\RegisterThemes.php(47): Magento\Theme\Model\Theme\Registration->register() #11 E:\xampp\htdocs\extendfeature\vendor\magento\framework\Setup\Patch\PatchApplier.php(162): Magento\Theme\Setup\Patch\Data\RegisterThemes->apply() #12 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(1023): Magento\Framework\Setup\Patch\PatchApplier->applyDataPatch(‘Magento_Theme’) #13 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(890): Magento\Setup\Model\Installer->handleDBSchemaData(Object(Magento\Setup\Module\DataSetup), ‘data’, Array) #14 [internal function]: Magento\Setup\Model\Installer->installDataFixtures(Array) #15 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(371): call_user_func_array(Array, Array) #16 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Controller\Install.php(109): Magento\Setup\Model\Installer->install(Array) #17 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Controller\AbstractActionController.php(83): Magento\Setup\Controller\Install->startAction() #18 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent)) #19 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure)) #20 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Controller\AbstractController.php(115): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent)) #21 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\DispatchListener.php(117): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response)) #22 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent)) #23 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure)) #24 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Application.php(339): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent)) #25 E:\xampp\htdocs\extendfeature\setup\index.php(39): Laminas\Mvc\Application->run() #26 {main} Next Magento\Framework\Setup\Exception: Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original exception message: Wrong file in E:\xampp\htdocs\extendfeature\vendor\magento\framework\Setup\Patch\PatchApplier.php:170 Stack trace: #0 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(1023): Magento\Framework\Setup\Patch\PatchApplier->applyDataPatch(‘Magento_Theme’) #1 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(890): Magento\Setup\Model\Installer->handleDBSchemaData(Object(Magento\Setup\Module\DataSetup), ‘data’, Array) #2 [internal function]: Magento\Setup\Model\Installer->installDataFixtures(Array) #3 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Model\Installer.php(371): call_user_func_array(Array, Array) #4 E:\xampp\htdocs\extendfeature\setup\src\Magento\Setup\Controller\Install.php(109): Magento\Setup\Model\Installer->install(Array) #5 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Controller\AbstractActionController.php(83): Magento\Setup\Controller\Install->startAction() #6 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch(Object(Laminas\Mvc\MvcEvent)) #7 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure)) #8 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Controller\AbstractController.php(115): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent)) #9 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\DispatchListener.php(117): Laminas\Mvc\Controller\AbstractController->dispatch(Object(Laminas\Http\PhpEnvironment\Request), Object(Laminas\Http\PhpEnvironment\Response)) #10 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch(Object(Laminas\Mvc\MvcEvent)) #11 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-eventmanager\src\EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners(Object(Laminas\Mvc\MvcEvent), Object(Closure)) #12 E:\xampp\htdocs\extendfeature\vendor\laminas\laminas-mvc\src\Application.php(339): Laminas\EventManager\EventManager->triggerEventUntil(Object(Closure), Object(Laminas\Mvc\MvcEvent)) #13 E:\xampp\htdocs\extendfeature\setup\index.php(39): Laminas\Mvc\Application->run() #14 {main}

Solutions:

Finally Installation is complete 100% after done following changes:

Find validateURLScheme function in vendor\magento\framework\Image\Adapter\Gd2.php file. at line 96. Replace function with this: !file_exists($filename)

Please find and change validateURLScheme function like below code.

Thank you for carefully read my article If you have any query please Leave your query on following comment section or contact with us. Please LIKE and SHARE