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

Have Undefined index while run the cron job!!! #92

Closed
avishake opened this issue Jun 26, 2017 · 3 comments
Closed

Have Undefined index while run the cron job!!! #92

avishake opened this issue Jun 26, 2017 · 3 comments
Labels

Comments

@avishake
Copy link

avishake commented Jun 26, 2017

Hi,
I have a strange error in my cron job. At the beginning while I am running the cron job its working fine. At that time I am define the variables normally. Like, $ck_host='abc';. But now I change the code and access the same variable from the .env file of laravel. Like, $ck_host=$_ENV['CK_HOST'];. When I am running in my browser it works fine. But in the cron job, it says undefined index: CK_HOST. I have attach the image of the log.
Note: I am using vlucas/phpdotenv for access env file.

imgpsh_fullsize

Thanks in advance for help.

@liebig
Copy link
Owner

liebig commented Jun 26, 2017

Do you use Artisan to call Cron? Then you should add the environment option when calling artisan commands. You can try to use Cron's integrated route instead.

@avishake
Copy link
Author

The some of corn file code written in Core PHP others in Laravel. So I for the core PHP files for access env file I added that vendor. I am using Artisan to call. When I am using static variable its fine, when I try to access env file of laravel then problem comes. I didn't able to understand why the error is coming? If I run that url in my browser there is no problem only happens in cron.

@liebig
Copy link
Owner

liebig commented Jun 27, 2017

If you call a Artisan command, not alle features are available. For further information about Artisan and Laravel please have a look at the source code or open a question on Stack Overflow or the Laravel GitHub repository. If you want to use the envoironment option with Artisan please have a look at my last reply and use one of the two options (add the environment option when calling artisan commands or use Cron's integrated route).

@liebig liebig closed this as completed Jun 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants