Laravel: what does schedule:finish do? - laravel

I discovered for an incident that Laravel 6 schedule:run has a brother, called schedule:finish
But using artisan list it's not documented.
What does this console command do?

This hidden command added on Laravel 5.4 to handle the after callbacks of a given command.
Check Taylor Otwell's explanations on this PR:
This PR adds improvements to the scheduler. Previously, when
->runInBackground() was used "after" hooks were not run, meaning
output was not e-mailed to the developer (when using emailOutputTo.)
This change provides a new, hidden schedule:finish command that is
used to fire the after callbacks for a given command by its mutex
name. This command will not show in the Artisan console command list
since it uses the hidden command feature which is new in Symfony 3.2.

schedule:finish is used to setup actions for a process after its finishes execution,
if you have two or three level of processes that you want them to be executed one after another and depending on each other you use the schedule:finish command

Related

How to override one function in multiple commands?

We are in the process of migrating an old application to Laravel. The old application manages different projects and has an "admin" database for the main application and creates a new database for each project. We would prefer to keep this structure but it creates some problems for things such as migrations.
Initially we created our own base command that implements the handle() function so that any command that extends this command will loop through all the project databases. This means we have changed the structure so that migrations are separated into two directories since we have "admin" and "project" migrations for the different types of databases. We also duplicate each Laravel command that is already there if it doesn't work with our implementation out of the box.
However this creates a lot of duplicate code as we made our own implementation of the migrate command that simply passes calls to Laravels own migrate command. I now find myself having to implement the --force option into our new command for example.
So what I would like to do is override the handle() function in all the Laravel console commands in some way. Is there a better way of implementing this?
You can create your own base class for your artisan classes and extends your commands from it.

Laravel - How to start artisan automatically only once?

If I have some artisan command and want to fire an event only once, is it possible run only if HTTP started first time?
Note: There are while-loop so it should be maybe good run as shell sh script (not via browser), like exec() command without return data.
I found solution using posix_getpgrp() and compare with cache::forever var. If is not same than call event and remove forever cache. Forever cache remember even if restart apache service.
You can call artisan commands from your app using
Artisan::call('your-command',array());
For example to create schema I would have route /create-schema then in the method I would have something like this
public function createSchema()
{
Artisan::call('migrate:install');
Artisan::call('migrate');
}
Find a solution. Use event listener and check is stored data into session then if not set, call script once, store cache data that is called. If you restart apache or want to force call script change your cache data.
What you need is to combine:
Cache
Events

Executing a Route (Controller/Action) using PHP CLI and Detecting a CLI Request

Is there a way in Laravel 4 to run my controller/action using PHP-CLI? I have a controller/action that I would like to extend to perform an alternative action if the request comes from the CLI, so is there a way to identify the request as a CLI request?
The Laravel documentation on this site seems to suggest that there is a method Request::cli() for determining if the current request is via the Artisan CLI but when I used the method in Laravel 4, it throws an error:
Call to undefined method Illuminate\Http\Request::cli()
Basically, I have just moved from CakePHP to Laravel and would like to accomplish something similar to as what's described in this article (for CakePHP) : Calling controller actions from cron and the command line
I understand that I can work with Laravel 4 Artisan Commands, but is the approach I would like to use possible? And if so, how?
As Rob already said, to determine if the current script is being run in the console use App::runningInConsole() or simple plain PHP php_sapi_name() == 'cli'.
As for running controller#action from console, you could use curl or wget to request one of your routes but I think the proper way of doing it would be to use a custom artisan command. Your controllers are classes so you can instantiate them and use as you please from within your artisan command:
$controller = new SomeController;
$controller->someAction();
Watch this video for an introduction to easily developing your own artisan commands.

CakePhp2 defined CAKE_CORE_INCLUDE_PATH, now DS and CORE_PATH undefined in ShellDispatcher

In order to share CakePhp2 core between many sites I edited CAKE_CORE_INCLUDE_PATH in webroot/index.php to point to the cake directory. That works and I can reach my welcome page.
However, when I attempted to run the Cake Console, I ran into issues with ShellDispatcher.php not defining DS and CORE_PATH because they were only defined if CAKE_CORE_INCLUDE_PATH was NOT defined. Once I defined them out of the if statement which checks if CAKE_CORE_INCLUDE_PATH was not defined, I was good to go. However, I would prefer not to "hack" this file because I want to keep the cake core files clean. Are there any better and cleaner options?
I also had to defined CAKE_CORE_INCLUDE_PATH and use it to set $dispatcher in Console/cake.php which is part of the app of course.
Yes there are. As a start never define application-wide variables in Webroot/index.php. As a matter of fact you shouldn't be touching this file at all. You can define variables in
Config/bootstrap.php.
You were getting the error because when in a Shell you're not firing Webroot/index.php at all - you're actually running PHP's CLI and CakePHP fires off in a different manner.
It will go through the bootstrap.php file of course.
You should also use this file to define any global vars, but there is a little bottleneck
here when using PHP's $_SERVER variable's web server related members - e.g. HTTP_HOST and the definition: $myHost = $_SERVER['HTTP_HOST'];. If you start a shell Cake will try to set this variable and it will fail throwing an error. This is because as mentioned before PHP will be running in CLI mode when the CakeShell is envoked. There is a way to detect this of course - you can use $_SERVER['SCRIPT_FILENAME'] or $_SERVER['SCRIPT_NAME'] in bootstrap.php to identify if you're in CLI or not. :)

How to debug symfony in Netbeans? I cannot call specific pages

I've already read posts like Passing PHP arguments into NetBeans into a page that features symfony url-routing
but I cannot make things work.
I would like to run the following page:
http://localhost/s/web/frontend_dev.php/travel
So I tried first the "Local Website Configuration" with Netbeans 6.9.1. As stated in the linked thread there is an issue here since I can point to the project url and to the "web/frontend_dev.php" index file but I am not able to have "/travel" as an argument since Netbeans always prefixes it with ? for parameter passing which I don't want.
I the mentioned thread the solution is supposed to be using the Script Config option. Fine
I can point to php.exe and I can point to the index file again at web/frontend_dev.php but although I can pass arguments like /travel there it still does not work since it creates a whitespace in the call:
php.exe ./web/frontend_dev.php /travel
which does not work either.
It is easier to use the following:
Set the Debug URL to "Do not open Webbrowser" (Project->Properties->Run Configuration->Advanced)
Start the debugging session with Netbeans (Netbeans doesn't start a browser but waits for a XDebug connection)
Use the easy XDebug-Firefox-Plugin to start XDebug for you Symfony App (easy XDebug)
Thats it. This is working perfectly for my Symfony apps
As far as I undersand you, this is a std-situation when there is no 101-path-mapping from file-path to URL-path.
In Eclipse you can either define a completely new path-mapping or make Eclipse request a certain URL-path. In your case you would just define localhost as your server and '/s/web/frontend_dev.php/travel' as the path to attach.
I'm pretty sure there is a similar option in NetBeans as this is in times of mod-rewrite and Zend FW a very common situation.

Resources