1. Go to this page and download the library: Download magedin/magento2-framework library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
magedin / magento2-framework example snippets
use MagedIn\Framework\Magento2\Profiler;
// Start profiling a section
$profileId = Profiler::start('my-operation');
// Your code here
// ...
// Stop profiling and get results
Profiler::stop($profileId);
$duration = Profiler::getDuration($profileId);
$memory = Profiler::getMemory($profileId, Profiler::MEMORY_FORMAT_MB);
echo "Operation took {$duration} seconds and used {$memory}MB of memory";
use MagedIn\Framework\Magento2\Module\ModuleMetadataProvider;
class MyClass
{
private ModuleMetadataProvider $metadataProvider;
public function __construct(ModuleMetadataProvider $metadataProvider)
{
$this->metadataProvider = $metadataProvider;
}
public function getModuleVersion(): string
{
return $this->metadataProvider->getVersion('MagedIn_MyModule');
}
}
use MagedIn\Framework\Magento2\DataObject\Copy;
use Magento\Framework\DataObject;
class DataTransfer
{
private Copy $copy;
public function __construct(Copy $copy)
{
$this->copy = $copy;
}
public function transferData(DataObject $source, DataObject $target): void
{
$this->copy->copy(
$source,
$target,
['name', 'email', 'customer_id']
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.