Adding variable to registration.php from different file [MAGENTO2]

Viewed 16

Im new to both PHP and Magento2 (I come from C++). I am simply trying to add a variable from a different file to the registration.php

But I can not seem to grab the other file. The other file is located in app/code/<vendor>/<module>/myCode/myFile.php.

And the registration is in app/code/<vendor>/<module>/registration.php.

So how would I acces this other file from within the registration.php?

1 Answers

I have that kind of approach, like this:

<?php
/**
 * Gateway Payloan integration module for Magento 2.
 * All rights reserved.
 *
 * @copyright  Copyright (c) 2020.
 */
use \Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
    ComponentRegistrar::MODULE,
    'Vendor_Payloan',
    __DIR__
);

require_once __DIR__ . "/Library/RequiredFile.php";

Note the last line, in your case, it may like:

require_once __DIR__ . "/myCode/myFile.php";
Related