Below url throwing Class customScript does not exist error. my test.php and customScript.php are in test folder. Once i run http://127.0.0.1/magento2/test.php, getting "Class customScript does not exist error" .
Here is my test.php code.
<?php
require __DIR__ . '../../app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication('customScript');
$bootstrap->run($app);
And in customScript.php
<?php
class customScript extends \Magento\Framework\App\Http implements
\Magento\Framework\AppInterface {
public function launch()
{
$this->_state->setAreaCode('frontend'); //Set area code 'frontend' or 'adminhtml
$id = 11588;
$_product = $this->_objectManager->create('\Magento\Catalog\Model\Product')->load($id);
echo $_product->getName();
return $this->_response;
}
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
{
return false;
}
}
How do I run php custom script on magento2
Please anyone able to achieve this?