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

Only Laravel 5.6? #17

Closed
Nowi5 opened this issue Mar 6, 2018 · 4 comments
Closed

Only Laravel 5.6? #17

Nowi5 opened this issue Mar 6, 2018 · 4 comments

Comments

@Nowi5
Copy link

Nowi5 commented Mar 6, 2018

Hi guys,

great that you update this package and I like the progress very much.
Unfortunately I can update most of my projects to Laravel 5.6 as other packages need longer to be ready for 5.6. Maybe you can think about alternatives for keeping progress but not use 5.6 commands.

I know you Note: For Laravel version below 5.6 use 0.2.0 tag.
But 0.2.0 does not have the nice new separate class ScheduleList.php which is nice to use in a view.

The comment "dragonmantank/cron-expression does not support Laravel <5.6" on the composer.json is wrong. It does support Laravel 5.5 fine.

Thank you very much.

@hmazter
Copy link
Owner

hmazter commented Mar 7, 2018

Hi

Version 1.0.0 will only support Laravel 5.6 (and higher).
I could not get dragonmantank/cron-expression to work with Laravel 5.5 since the cron expression uses 6 positions https://github.com/laravel/framework/blob/5.5/src/Illuminate/Console/Scheduling/Event.php#L30
And that throws an Exception when using dragonmantank/cron-expression, it only supports 5 positions. https://github.com/dragonmantank/cron-expression/blob/master/src/Cron/FieldFactory.php#L46

Here is the PR from dragonmantank himself to make Laravel 5.6 work with version 2 of cron-expression laravel/framework#21637 which means dragonmantank/cron-expression is incompatible with Laravel 5.5.

If you have any other idea, please let me hear or make a PR.

@Nowi5
Copy link
Author

Nowi5 commented Mar 7, 2018

Okay, thank you very much for the prompt answer.

As I was somehow not able to quickly come up with a nice function to show the schedule within a view, I now miss used you command with version 0.2.0.

Quick and dirty, getting the schedule List within a controller index and hand over to view:

 public function index()
    {
				$command = 'schedule:list';
				$params = [ ];

				\Artisan::call($command, $params);
				$artisanOutput = \Artisan::output();
			  $artisanOutputLines = explode(PHP_EOL,$artisanOutput);

				$events = [];
				$now = Carbon::now();
			
				for($o = 3; $o < sizeof($artisanOutputLines)-2; $o++){
					$parts = explode("|", $artisanOutputLines[$o]);					
						
					if(isset($parts[1])){
						$event = [];
						
						$event['expression'] 	= trim($parts[1]);
						$event['next_run'] 		= trim($parts[2]);
						$event['command'] 		= trim($parts[3]);
						$event['description'] =trim($parts[4]);

						$next_run = new Carbon($event['next_run']);
						$event['overdue'] = $now->gt($next_run); //true or false
						
						array_push($events, $event);
					}
				}

        return view('admin.schedule.index', [
            'scheduleList' => $events
        ]);
    }	

@hmazter
Copy link
Owner

hmazter commented Mar 7, 2018

Will see if I can make a fix to truncate the cron expression if its to long (Laravel 5.5 is used) when parsing the next run date.

@hmazter
Copy link
Owner

hmazter commented Mar 7, 2018

See a quick solution in PR #18

@hmazter hmazter closed this as completed in f339fae Mar 8, 2018
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