Comments (13)
Thank you for using Cron. It seems that the ServiceProvider architecture changed in Laravel 5. I will check this next week.
from cron.
I tried to update my app from Laravel4 to Laravel5 and had the same issue as AlbertoRico. Can you help?
Robert
from cron.
I am working on this. I will give you an update in a few hours. By the way, I think this is not a bug but a feature request because Laravel 5 breaks nearly every package...
from cron.
I agree. Thanks for your support. Robert
from cron.
Okay, this is much work. I cannot get Cron running in one day. Laravel 5 changed so much. I will work on this and give you feedback in the next days.
from cron.
@liebig You can probably use this for an easier migration to L5.
from cron.
Thank you, @dcelasun. But I am working on a native L5 solution. The biggest problem at the moment is, that the Laravel 5 Config
works different. I hope I can push a first update later this day.
from cron.
Work is done! Please test for Laravel 5:
- Add "
liebig/cron": "dev-master"
to your /path/to/laravel/composer.json file at the"require":
section - Run the
composer update liebig/cron --no-dev
command in your shell from your /path/to/laravel/ directory - Add
'Liebig\Cron\Laravel5ServiceProvider'
to your'providers'
array in the /path/to/laravel/config/app.php file - Migrate the database with running the command
php artisan migrate --path=vendor/liebig/cron/src/migrations
- Publish the configuration file with running the command
php artisan vendor:publish
- now you find the Cron configuration file at /path/to/laravel/app/config/liebigCron.php and this file won't be overwritten at any update - Now you can use
Cron
everywhere for free
Please give me a short feedback. Thank you for your support :)
from cron.
Tomorrow I can test and confirm. Thanks for solving it so quickly!!
Robert
On Feb 24, 2015 7:13 PM, "liebig" [email protected] wrote:
Work is done! Please test for Laravel 5:
- Add "liebig/cron": "dev-master" to your /path/to/laravel/composer.json
file at the "require": section- Run the composer update liebig/cron --no-dev command in your shell
from your /path/to/laravel/ directory- Add 'Liebig\Cron\Laravel5ServiceProvider' to your 'providers' array in
the /path/to/laravel/config/app.php file- Migrate the database with running the command php artisan migrate
--path=vendor/liebig/cron/src/migrations- Publish the configuration file with running the command php artisan
vendor:publish - now you find the Cron configuration file at
/path/to/laravel/app/config/liebigCron.php and this file won't be
overwritten at any update- Now you can use Cron everywhere for free
Please give me a short feedback. Thank you for your support :)
—
Reply to this email directly or view it on GitHub
#55 (comment).
from cron.
Hi,
Works fine now. Just one short question ... I used to place my jobs in global.php like this :
/* Cron type entries for scheduled tasks */
Event::listen('cron.collectJobs', function() {
Cron::setLaravelLogging(false);
// Read and verify temp every minute
Cron::add('Read server room temperature', '* * * * *', function() {
Log::debug('Running read temperature cron task.');
App::make('ServersController')->readTemp();
Log::debug('Running verifytemp cron task.');
App::make('ServersController')->verifytemp();
return null;
});
...... + other
- Can you tell me if I'm doing it correctly? The outcome seems as desired.
- Where would I put that in Laravel5?
Robert
from cron.
Hi Robert,
Thank you for testing. Your code looks good, but I think you have to enter the full namespace in the App:make
method. For example App::make('App\Http\Controllers\ServersController')->readTemp();
.
Laravel 5 has no global.php
file, so please use the /path/to/laravel5/app/Providers/AppServiceProvider.php
at the boot
method. If you are using this file, please note the different namespace and please add a \
in front of your Event
, Cron
, Log
and App
objects or you get a class not found exception.
<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot() {
//
\Event::listen('cron.collectJobs', function() {
\Cron::setLaravelLogging(false);
// Read and verify temp every minute
\Cron::add('Read server room temperature', '* * * * *', function() {
\Log::debug('Running read temperature cron task.');
\App::make('App\Http\Controllers\ServersController')->readTemp();
\Log::debug('Running verifytemp cron task.');
\App::make('App\Http\Controllers\ServersController')->verifytemp();
return null;
});
});
}
}
Please let me know if this works for you.
I will polish my code a little bit, edit the README and after that, close this ticket.
Thanks,
Marc
from cron.
Hi Marc,
Yes, your points are all valid .. I copy/pasted the L4 code .. as I'm in the process of moving it to L5 ...
Thanks for pointing me to /path/to/laravel5/app/Providers/AppServiceProvider.php
.. I'm still learning Laravel .. and that part was not clear.
All works now .. thanks!
Regards,
Robert
from cron.
Work is done with commit cd0ba32
Thank you for your support.
from cron.
Related Issues (20)
- Are tests working? HOT 2
- Incompatibility with Laravel 8, 9 HOT 1
- Exception with two closures on the same line of code HOT 3
- Symfony\Component\Console\Helper\HelperSet->get('table') HOT 3
- usage question: loading jobs from database HOT 3
- command cron:run/list error HOT 1
- stop cronjob run during beforeRun event HOT 3
- Cron job running only one time HOT 3
- Pull request #80 not in composer package HOT 3
- trying to understand why I should use this over Laravel's built-in scheduler HOT 2
- Which user should run cron HOT 2
- Laravel 5.4 support HOT 3
- PHP Fatal error: Class 'App\Providers\Cron' not found in C:\xampp\htdocs\isend\blog\app\Providers\AppServiceProvider.php on line 33 HOT 3
- laravel5.2.45 install failed HOT 2
- passing variable to the function parameter before adding a cron HOT 5
- Have Undefined index while run the cron job!!! HOT 3
- Php artisan cron:run Not working HOT 13
- Can't use `artisan route:cache` because the built-in cron route uses a closure HOT 5
- [Laravel 5.6] Ambiguous class resolution warning HOT 10
- doesn't work with Laravel 5.8 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cron.