The method outlined here to create a dirty playground doesn't work in magento 2.1.6: https://magento.stackexchange.com/a/40848/55108

It generates the error:

Uncaught TypeError: Argument 2 passed to Magento\Framework\App\Http::__construct() must be an instance of Magento\Framework\Event\Manager, none given

The TestApp class in the example extends \Magento\Framework\App\Http. This is the Http classes constructor:

public function __construct(
    \Magento\Framework\ObjectManagerInterface $objectManager,
    Event\Manager $eventManager,
    AreaList $areaList,
    RequestHttp $request,
    ResponseHttp $response,
    ConfigLoaderInterface $configLoader,
    State $state,
    Filesystem $filesystem,
    \Magento\Framework\Registry $registry
) {
    $this->_objectManager = $objectManager;
    $this->_eventManager = $eventManager;
    $this->_areaList = $areaList;
    $this->_request = $request;
    $this->_response = $response;
    $this->_configLoader = $configLoader;
    $this->_state = $state;
    $this->_filesystem = $filesystem;
    $this->registry = $registry;

So I guess it is failing because $eventManager doesn't exist within the playgrounds context?

How does the code need to be updated to work with 2.1.6?

  • Seems to work straight away for me i'm testing on 2.1.7 however, what mode are you in i've seen this issue was fixed elsewhere when setting mode to developer? github.com/magento/magento2/issues/7151
    – harri
    Commented Aug 13, 2017 at 13:37

4 Answers 4


I don't know if it satisfies your needs but when I need to poke with Magento 2 runtime I use a shell script like this:

// set error verbosity
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

// require boostrap file
try {
    require __DIR__ . '/app/bootstrap.php';
} catch (\Exception $e) {
    echo $e->getMessage() . PHP_EOL;

// bootstrap framework
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */

// get the Object Manager
$objectManager = $bootstrap->getObjectManager();

// set application area
$state = $objectManager->get('Magento\Framework\App\State');


// e.g.: get the Event Manager
$eventManager = $objectManager->get('Magento\Framework\EntityManager\EventManager');

Hope it helps.




Just tested this in 2.1.6 and 2.1.8 and it works in both places.

I got the answer from the post you originally linked to: https://magento.stackexchange.com/a/96875/36487

File magento2_root/test.php


use Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';

$bootstrap = Bootstrap::create(BP, $_SERVER);

$objectManager = $bootstrap->getObjectManager();

// This is just an example showing that it gets through the bootstrap
// and works
echo get_class($objectManager->create('\Magento\Catalog\Model\Category'));

Console output

| => php test.php

Please set your Magento in Developer Mode using below command

php bin/magento deploy:mode:set developer

Then after delete var/generation folder. After refresh page Magento will create new generation folder in var/generation.

I face this type of error many times. When add or remove parameters in class __construct.

May be this will help you.


Do you have a correct path for Magento\Framework\EntityManager\EventManager with the namespace ?

You can try to recompile de code.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.