1. Go to this page and download the library: Download bmitch/consoleevents library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bmitch / consoleevents example snippets
namespace App\Listeners;
use Log;
use Bmitch\ConsoleEvents\Events\CommandStarting;
class CommandStartingListener
{
/**
* Handle the event.
*
* @param CommandStarting $commandStartingEvent
* @return void
*/
public function handle(CommandStarting $commandStartingEvent)
{
$name = $commandStartingEvent->command->getName();
Log::info("Command {$name} starting");
}
}
namespace App\Listeners;
use Log;
use Bmitch\ConsoleEvents\Events\CommandTerminating;
class CommandTerminatingListener
{
/**
* Handle the event.
*
* @param CommandTerminating $commandTerminatingEvent
* @return void
*/
public function handle(CommandTerminating $commandTerminatingEvent)
{
$command = $commandTerminatingEvent->command;
$name = $command->getName();
Log::info("Command {$name} stopping", [
'commandName' => $name,
'executionTime' => $command->getExecutionTime(),
'exitCode' => $commandTerminatingEvent->exitCode,
]);
}
}
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'Bmitch\ConsoleEvents\Events\CommandStarting' => [
'App\Listeners\CommandStartingListener',
],
'Bmitch\ConsoleEvents\Events\CommandTerminating' => [
'App\Listeners\CommandTerminatingListener',
],
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.