laracasts/Commander

Sometimes $command is empty in handler

Closed this issue · 3 comments

One of my command DTOs are not getting passed through properly.

I don't know why. it is very weird... All of my other commands work fine...

# in controller
$this->execute(new ScrapeMovieReviewFeedCommand($url));

dd() in the controller gives me the expected value.

dd() in the Command gives the expected value.

dd() in the CommandHandler gives me:

object(Acme\MovieReviews\Commands\ScrapeMovieReviewFeedCommand)#339 (1) { ["url"]=> string(0) "" }

What could be the problem? I am drawing a blank...

You don't want to new up ScrapeMovieReviewFeedCommand. Just do $this->execute(ScrapeMovieReviewFeedCommand::class).

But Jeffrey. the ::class is PHP 5.5, isn't it? So, the package has a dependency of PHP 5.4.
I got myself in this situation because I need to stay with PHP 5.4 for now. So I'm writing the hole namespace.

Yes, that's 5.5. If you can't do that, then do: $this->execute('Path\To\ScrapeMovieReviewFeedCommand')