把下面代码命名为 test.php 然后放在Magento2的目录下面: <?php // File MAGE_ROOT/test.php require __DIR__ . '/app/bootstrap.php'; class TestApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface { public function launch() { echo get_class($this->_objectManager->create('\Magento\Catalog\Model\Category')); return $this->_response; } public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception) { return false; } } $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); $app = $bootstrap->createApplication('TestApp'); $bootstrap->run($app); 然后在浏览器中访问 test.php。 我们只需要把测试代码放入 lunch() 中就可以了。 http://magento.stackexchange.com/questions/39981/how-can-i-create-my-dirty-playground-file-in-magento-2

分类: web

标签: