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

PHP Fatal error: Class 'App\Providers\Cron' not found in C:\xampp\htdocs\isend\blog\app\Providers\AppServiceProvider.php on line 33 #89

Closed
avishake opened this issue Feb 24, 2017 · 3 comments
Labels

Comments

@avishake
Copy link

avishake commented Feb 24, 2017

Hi,
I am trying to use the cron. I am using Laravel 5.3. I have installed the vendor as per the documentation. But I am not using mysql database. So, I had not run 'php artisan migrate --path=vendor/liebig/cron/src/migrations' comment. But when I run 'php artisan cron:run' comment I have this error. 'PHP Fatal error: Class 'App\Providers\Cron' not found in C:\xampp\htdocs\isend\blog\app\Providers\AppServiceProvider.php on line 17'.

I have attached one image. One is the error. I have also attached the 'AppServiceProvider' code. Please help me.

`<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
/
public function boot()
{
// Sendmail Cron
Cron::add('sendmail', '
/1 * * * ', function() {
shell_exec('php -q /opt/lampp/htdocs/isend/blog/cron/sendMail.php > /dev/null 2>&1 &');
return null;
});
// Test Cron
Cron::add('test_cron', '
/1 * * * *', function() {
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
fclose($myfile);
return null;
});

	Cron::setDatabaseLogging(false);
	$report = Cron::run();
	print_r ($report);
}

/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    //
}

}
`
2

@liebig
Copy link
Owner

liebig commented Feb 24, 2017

Hi, please try to use \Cron instead of Cron. Have a look at the PHP namespaces manual.

@avishake
Copy link
Author

Thanks it's working. I have already made all cron in laravel. There are all have a url. Can you tell me how to call those urls?

@liebig
Copy link
Owner

liebig commented Feb 24, 2017

You can configure crontab on your server to call the artisan cron:run command or you need an online cronjob web service, which call the url. Google is your friend for this cronjob web service.

@liebig liebig closed this as completed Feb 24, 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