Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

benaddirar's avatar

laravel cron job issue

Hy,

in a shared hosting the public folder is public_html so w need to add in index.php

/*
|--------------------------------------------------------------------------
| Set the public path to this directory
|--------------------------------------------------------------------------
|
*/
$app->bind('path.public', function() {
    return __DIR__;
});

but if we have a cron job that use public_path();

like sending mail in queue with attachment.

public_path() return public instead of public_html.

0 likes
1 reply
mushketer888's avatar

It seems that your "bind" is too late maybe. Try to put your code in AppServiceProvider register()

Please or to participate in this conversation.