Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception raised when added a crontab entry #61

Closed
andreabrega74 opened this issue May 3, 2020 · 2 comments
Closed

Exception raised when added a crontab entry #61

andreabrega74 opened this issue May 3, 2020 · 2 comments

Comments

@andreabrega74
Copy link

andreabrega74 commented May 3, 2020

Hallo everyone,
OSx catalina 10.15.4,
PHP 7.4.4,
Laravel (framework 7.9.2) fresh installation, only laravel-webhook-client package installed,
crontab entry: * * * * * cd /Library/WebServer/Documents/Foo/Bar && php artisan schedule:run >> /dev/null 2>&1

Adding the previous line to crontab to let the scheduler run, even if there is no instruction in the function schedule in the file Console/Kernel.php, the following error is raised anytime cron launches the schedule (in this case every minute, two tries and then i stopped cron).
No errors if php artisan schedule:run is launched directly from terminal, and no problems at all with the package functionalities (i can receive webhooks properly).

[2020-05-03 07:23:01] local.ERROR: syntax error, unexpected '$url' (T_VARIABLE), expecting ')' {"exception":"[object] (ParseError(code: 0): syntax error, unexpected '$url' (T_VARIABLE), expecting ')' at /Library/WebServer/Documents/IIC/FakeWebhook/vendor/spatie/laravel-webhook-client/src/WebhookClientServiceProvider.php:28)
[stacktrace]
#0 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Library/WebSer...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Spatie\\WebhookC...')
#2 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(690): spl_autoload_call('Spatie\\WebhookC...')
#3 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(624): Illuminate\Foundation\Application->resolveProvider('Spatie\\WebhookC...')
#4 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\Foundation\Application->register('Spatie\\WebhookC...')
#5 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(604): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 /Library/WebServer/Documents/IIC/FakeWebhook/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}
"}
[2020-05-03 07:24:00] local.ERROR: syntax error, unexpected '$url' (T_VARIABLE), expecting ')' {"exception":"[object] (ParseError(code: 0): syntax error, unexpected '$url' (T_VARIABLE), expecting ')' at /Library/WebServer/Documents/IIC/FakeWebhook/vendor/spatie/laravel-webhook-client/src/WebhookClientServiceProvider.php:28)
[stacktrace]
#0 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/Library/WebSer...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Spatie\\WebhookC...')
#2 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(690): spl_autoload_call('Spatie\\WebhookC...')
#3 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(624): Illuminate\Foundation\Application->resolveProvider('Spatie\\WebhookC...')
#4 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\Foundation\Application->register('Spatie\\WebhookC...')
#5 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(604): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /Library/WebServer/Documents/IIC/FakeWebhook/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 /Library/WebServer/Documents/IIC/FakeWebhook/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}
"}

I think it's worth an investigation :)

Thank you All,
Andrea

@freekmurze
Copy link
Member

It seems like you are not running PHP 7.4 on the CLI.

@andreabrega74
Copy link
Author

andreabrega74 commented Nov 18, 2020

Yes, you were right.
After a while I figured out that php launched in the terminal was not the one launched by cron.

To verify it, I simply added a crontab entry that writes to a file the result of the command 'which php' and I discovered the difference.

In case some other people run into this problem, it's enough to change the crontab entry
from: * * * * * cd /Library/WebServer/Documents/Foo/Bar && php artisan schedule:run >> /dev/null 2>&1
to: * * * * * cd /Library/WebServer/Documents/Foo/Bar && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1

Thanks again,
Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants