Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created March 15, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mttjohnson/328bce9362fda1abe03f6e4f979d08b0 to your computer and use it in GitHub Desktop.
Save mttjohnson/328bce9362fda1abe03f6e4f979d08b0 to your computer and use it in GitHub Desktop.
Magento 2 Sandbox Snippet
# Magento 2 Sandbox Snippet - You can copy and paste into any shell in a Magento root directory
# Extended: https://docs.classyllama.net/disciplines/engineering/magento/sandbox-file-m2
set +H # disable history expansion
PHP_CODE=$(cat <<'PHP_CODE'
<?php
header('Content-type: text/plain');
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
class TeamClassyLlama
extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
//sandbox code goes here
$exampleMagentoClassInstance = $this->_objectManager->create('\Magento\Catalog\Api\ProductRepositoryInterface');
echo get_class($exampleMagentoClassInstance) . "\n";
//the method must end with this line
return $this->_response;
}
public function catchException(\Magento\Framework\App\Bootstrap $bootstrap, \Exception $exception)
{
return false;
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('TeamClassyLlama');
$bootstrap->run($app);
PHP_CODE
)
set -H # re-enable history expansion
echo "${PHP_CODE}" | php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment