frm
Well-known member
I'm creating a simple "Happy birthday" add on that replies to the thread owned by the user whose birthday it is (to try and learn cron jobs mainly). I'm able to make replies, etc., using unconventional methods (directly starting XF.php and running queries to post replies), but trying to put it into an add on with the appropriate structure to run it as an installable add on using XF's native cron job system.
I could keep it all in 1 file and use *nix cron jobs to call it, but I'm trying to build an add on and not a separate file that XF doesn't recognize in any way.
The file structure is:
As I get this error on installation:
cron.xml:
Setup.php
Birthday.php
It installs fine once
So, I've tried adding it as a manual cron in the ACP linking it to the add on.

And it just stays on the same page with the loading bar with this in the console:
I'm at a loss for what to do as I'm following add ons that do create cron jobs.
Does it require a function to create a cron job? Does it require putting it directly into the database (
I can't seem to reverse engineer any add on that creates a cron job that doesn't make use of
Thanks in advance.
I could keep it all in 1 file and use *nix cron jobs to call it, but I'm trying to build an add on and not a separate file that XF doesn't recognize in any way.
The file structure is:
Code:
/
└── upload
└── src
└── addons
└── FRM
└── BirthdayPost
├── Setup.php
├── addon.json
├── Cron
│ └── Birthday.php
└── _data
└── cron.xml
As I get this error on installation:
Exception: Callback FRM\BirthdayPost\Cron\Birthday::postBirthday is invalid (error_invalid_class).
cron.xml:
XML:
<?xml version="1.0" encoding="utf-8"?>
<cron>
<entry entry_id="frm_birthday_post" cron_class="FRM\BirthdayPost\Cron\Birthday" cron_method="postBirthday" active="1">
<![CDATA[ {"day_type":"dom","dom":[-1],"hours":[3],"minutes":[0]} ]]>
</entry>
</cron>
Setup.php
PHP:
<?php
namespace FRM\BirthdayPost;
Birthday.php
PHP:
<?
namespace FRM\BirthdayPost\Cron;
class Birthday
{
public static function postBirthday()
{
}
}
It installs fine once
cron.xml
is removed.So, I've tried adding it as a manual cron in the ACP linking it to the add on.

And it just stays on the same page with the loading bar with this in the console:
Code:
Uncaught (in promise) SyntaxError: Unexpected token '<', "<?
namesp"... is not valid JSON
I'm at a loss for what to do as I'm following add ons that do create cron jobs.
Does it require a function to create a cron job? Does it require putting it directly into the database (
xf_cron_entry
) over cron.xml
?I can't seem to reverse engineer any add on that creates a cron job that doesn't make use of
/_data/cron.xml
.Thanks in advance.