Running Laravel's artisan schedule:run as a timer

I’ve attempted to solve this with this code:

$_SERVER['argv'] = ['artisan', 'schedule:run']; include('artisan');

But this doesn’t seem to work, I’ve then proceeded to switch schedule:run with a test command which just uses the touch function to create a file in storage every minute but that still doesn’t do anything.

Is there any way to get an error output or log of what’s happening with the timer so I can debug this?

I also updated the onStartMainWindow HEScript with a raw php script and had it dump a file to see if it was actually working and it was, but Artisan doesn’t and with no error logging it’s really difficult to debug.

If like me you’re using Laravel, you will run into the issue of $_SERVER[‘argv’] not being set, however that’s easily fixed in the timer by doing

$_SERVER['argv'] = ['artisan', 'myCommand', '--option=something']; include('artisan');

However if you’re really trying to make it production ready by deleting all the unnecessary files then you’ll realise that Application.php requires composer.json (just the autoload section) to get the command namespaces, personally I think this terrible so I’ve wiped out all information that can compromise the app in the composer.json leaving just this:

    "name": "dearnex/desktop-application",
    "type": "project",
    "autoload": {
        "psr-4": {
            "App\\": "app/"

In my artisan file I have changed nothing.

Note: I have an automated script that recompile’s Laravel and deletes all the files that are not required, it will now also rewrite the composer.json to have only the absolutely necessary data.

1 Like

Thanks for the great help article!

1 Like