Execute Class with method from Terminal

Hi guys,

I am trying to execute method from class via terminal and when I will be achieve that, to set-up it as cron job.

Here is the file: script.php:

class CronJobModule_Controller_Admin_TransferControlPanel extends ModuleName_Controller_Admin_Abstract

class Module_Controller_Admin_Abstract is in file Abstract.php

And when I am trying to execute in a terminal with the command:
php -r ‘include “script.php”; CronJobModule_Controller_Admin_TransferControlPanel::run();’
Fatal Error is thrown:

Class ‘ModuleName_Controller_Admin_Abstract’ not found in the script.php.

And when I am adding the class with requiring once, I am getting error that some other class is missed but class that is used in Abstract.php and all the time I am in a loop with the errros.

So, I want to ask if there is a way to autoload all the classes in the script.php file to execute method from class successfully.

Thank you.

I’m not absolutely sure, but you should try composer’s autoload

Any idea or suggestion how to do that.

Because version of the shop is 4.10. And I’ve used composer only for OXID 6.
Also, I read the article from this link:https://oxidforge.org/en/composer-integration-for-projects-from-oxid-eshop-4-9-6-on.html but the module from which is the class that I want to execute is not made by me, there is no files like vendormetadata.php, autoloader.php …

oh ok, i thought you had v6.
then you need to require_once the bootstrap.php file from shop root

Still the same error appear…
I tried to requiring once using different ways:

require_once SHOP_DIR_ROOT . ‘/bootstrap.php’;
require_once SHOP_DIR_ROOT . ‘bootstrap.php’;
require_once ‘/home/shop-name/bootstrap.php’;

Put your file in /bin directory of your shop and take the existing file cron.php as a starting point for your own cron jobs.