Skip to content

Instantly share code, notes, and snippets.

@kelvysmoura
Created September 5, 2024 13:37
Show Gist options
  • Save kelvysmoura/4352a9ff0d02ddc48de2d757ffee2e4c to your computer and use it in GitHub Desktop.
Save kelvysmoura/4352a9ff0d02ddc48de2d757ffee2e4c to your computer and use it in GitHub Desktop.
Magento 2 POC File
<?php
require __DIR__ . '/app/bootstrap.php';
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\State;
use Magento\Framework\Registry;
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$execute = function (array $nsList, callable $callable) use ($objectManager) {
$objects = array_map(fn($ns) => $objectManager->get($ns), $nsList);
$callable(...$objects);
};
$execute([
State::class,
Registy::class
], function($state, $registry){
// your code here...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment