I'm using Laravel 5. In my Schedule method (in kernel.php), i used everyMinute function. Please take a look:
But its not working. It shows message "Call to undefined method". Please take a look:
I need to call scheduler every minute via call function. Please help me.
It doesn't appear to have that method in 5.0.
Use the manual cron expression for every minute.
$schedule->call(...)->cron('* * * * * *');
Well, Laravel is clearly saying you that there is no method defined as everyMinute in Schedule. Forget about the official documentation, it is not there in the API Documentation as well as Laravel 5.0.*.
If you really want that to run every minute, you can upgrade your app to Laravel 5.1.* or greater.
Related
It gives me this error
ArgumentCountError
Too few arguments to function Illuminate\Routing\Router::fallback(), 0 passed in C:\xampp\htdocs\gmvcc\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 338 and exactly 1 expected
im using laravel 9.
I suggest a combination of suggested places to check, based on the provided error response you pasted above:
First, check your web.php or api.php in routes folder and verify if you have unexpected additional parameters. For example, Route::post('/foo/{hello}/bar/{world}', [FallbackController::class, 'testFunction']); and we see that you'll next have to declared $hello and $world shortly.
Next, does your function looks like this? (following the example from #1) Such as public function testFunction($hello, $world, Request $request).
Third, based on the HTTP method used, and for the route defined using FallbackController, were you able to simplify it to test your HTTP method with the route again? For this, I still assume it is a route in api.php correct?
Lastly, if any of above fails to help, I recommend implementing a simple route to test with (GET or POST) first. This will help you trace back what you missed.
Using Docker (and a fresh Laravel 9) to help fill in other clues, like incorrect php or composer version and more - using a template like this might help, https://github.com/k90mirzaei/laravel9-docker.
Please note, I am answering based on the provided error first. Hope my checklist above helps.
New to Lavarel.
I am trying to debug a controller's method in Laravel, to do so I'm using Tinker (which is based on Psysh).
I added both of these versions to the breakpoint inside the method signup of my MySuperController:
extract(\Psy\Shell::debug(get_defined_vars()));
eval(\Psy\sh());
I've run php artisan tinker and done the following in the console:
$controller = app()->make('\App\Http\Controllers\Api\V1\MySuperController');
app()->call([$controller, 'signup'], ["param"=>"value"]);
When executing that, Tinker responds with: Illuminate\Validation\ValidationException with message 'The given data was invalid.'
But I never see the code stop on the breakpoint. Did I assume wrongly that I could debug step by step with Tinker?
This answer was based off of user #lagbox's comment. I asked them to make it an answer so I could choose it, but it's been 4 months, so I'm creating it myself so others can quickly see the question has been answered:
User #lagbox mentioned in a comment:
are you using a form request to validate? if so they are resolved and validated before your controller method is called
The comment was spot on. Tmethod was using a custom request class, which extended from api/application/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php . I added the eval() within that class and it finally got to the breakpoint.
I have the following code in Kernel.php. The purpose is to run the command between 23:000 and 04:00
$schedule->command('moving:vehicles -vvv')
->between('23:00', '04:00')
->everyTenMinutes();
However, the cron starts executing the command at 17H00. I have tried to replicate the same by send emails into mailtrap and I get different results.
https://github.com/laravel/framework/issues/28943
The link above explains why the schedule was not running as intended. It was a bug in Laravel 5.x and it was resolved in version 6. I changed direction to use https://crontab.guru/#*/10_0-4,23_*_* to solve the issue I faced.
I'm trying to set up a CRON job for my laravel 4.2 app and am strugglng to get things to work.
I've created a command which works successfully from the command line. I first tried created a CRON task with my service provider but was unable to get this to work. I tried:
/usr/bin/php /var/www/vhosts/mydomin.co.uk/subdomains/golfmanager/httpdocs/artisan reminder:week
This does not appear to work
I then tried:
/usr/bin/lynx -dump /var/www/vhosts/mydomain.co.uk/subdomains/golfmanager/httpdocs/artisan reminder:week
That failed to work either. My understanding is Lynx is a browser? but I assume because all the traffic is re-routed this approach won't work for a Laravel app?
So I then installed the package [liebig/cron][1] with a view to getting that up and running. I created a cron task with an external provider 'cronservice' which appears to be triggering but I'm not getting the expected results from the task.
I have configured the package as described and have current placed the following in bootstratp/start.php
Event::listen('cron.collectJobs', function() {
Cron::add('reminder-week', '*/15 * * * *', function() {
echo "Running Task";
Artisan::call('reminder:week');
return true;
});
});
The package logs activity to a database. I can see a log entry suggesting it's fired but can't see an entry that the job has worked. Laravel log files suggest there is an httpfoundexception
I've not created a route for CRON - the readme suggests it's using an internal one?
I'm quite confused. I'd like to stick with the package approach and the external provider but not sure if I now need to create a route and how I can test the set up is correct and the jobs will work.
I've tried running the script from the browser `http://mydomain.com/cron.php?key=xxxxx' but that also throws an httpnotfound exception
ANy help appreciated to get this to work
I changed the Event::listen code to app/start/glopal.php and all working now.
Re-read the readme more carefully!
I have an MVC architecture and since I already have an action that would be extra useful if automatically called every hour or so, I wondered if there's a way to set it up as a cron job?
Don't know how periodic web page request is related to mvc, but you can achieve this by adding following line to crontab (1 hour period):
0 0/1 * * * wget <web_page_url>
Which is translated to: use wget command to request <web_page_url> every hour at zero minutes.
You can use
curl http://example.com
Or if the language you're using has a CLI client like PHP you could just run the script like
php /var/www/example.com/index.php
Edit:
For an MCV app it's probably easiest to use curl