Git Product home page Git Product logo

Comments (13)

liebig avatar liebig commented on July 24, 2024

Thank you for using Cron. It seems that the ServiceProvider architecture changed in Laravel 5. I will check this next week.

from cron.

robert83ft avatar robert83ft commented on July 24, 2024

I tried to update my app from Laravel4 to Laravel5 and had the same issue as AlbertoRico. Can you help?

Robert

from cron.

liebig avatar liebig commented on July 24, 2024

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.

robert83ft avatar robert83ft commented on July 24, 2024

I agree. Thanks for your support. Robert

from cron.

liebig avatar liebig commented on July 24, 2024

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.

dcelasun avatar dcelasun commented on July 24, 2024

@liebig You can probably use this for an easier migration to L5.

from cron.

liebig avatar liebig commented on July 24, 2024

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.

liebig avatar liebig commented on July 24, 2024

Work is done! Please test for Laravel 5:

  1. Add "liebig/cron": "dev-master" to your /path/to/laravel/composer.json file at the "require": section
  2. Run the composer update liebig/cron --no-dev command in your shell from your /path/to/laravel/ directory
  3. Add 'Liebig\Cron\Laravel5ServiceProvider' to your 'providers' array in the /path/to/laravel/config/app.php file
  4. Migrate the database with running the command php artisan migrate --path=vendor/liebig/cron/src/migrations
  5. 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
  6. Now you can use Cron everywhere for free

Please give me a short feedback. Thank you for your support :)

from cron.

robert83ft avatar robert83ft commented on July 24, 2024

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:

  1. Add "liebig/cron": "dev-master" to your /path/to/laravel/composer.json
    file at the "require": section
  2. Run the composer update liebig/cron --no-dev command in your shell
    from your /path/to/laravel/ directory
  3. Add 'Liebig\Cron\Laravel5ServiceProvider' to your 'providers' array in
    the /path/to/laravel/config/app.php file
  4. Migrate the database with running the command php artisan migrate
    --path=vendor/liebig/cron/src/migrations
  5. 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
  6. 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.

robert83ft avatar robert83ft commented on July 24, 2024

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

  1. Can you tell me if I'm doing it correctly? The outcome seems as desired.
  2. Where would I put that in Laravel5?

Robert

from cron.

liebig avatar liebig commented on July 24, 2024

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.

robert83ft avatar robert83ft commented on July 24, 2024

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.

liebig avatar liebig commented on July 24, 2024

Work is done with commit cd0ba32
Thank you for your support.

from cron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.