PHP code example of upingli / hofan
1. Go to this page and download the library: Download upingli/hofan 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/ */
upingli / hofan example snippets
'default' => env('QUEUE_CONNECTION', 'sync'),
//Not
'connections' => [
// ...
'rabbitmq' => [
'driver' => 'rabbitmq',
'queue' => env('RABBITMQ_QUEUE', 'default'),
'connection' => PhpAmqpLib\Connection\AMQPLazyConnection::class,
'hosts' => [
[
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
'port' => env('RABBITMQ_PORT', 5672),
'user' => env('RABBITMQ_USER', 'guest'),
'password' => env('RABBITMQ_PASSWORD', 'guest'),
'vhost' => env('RABBITMQ_VHOST', '/'),
],
],
'options' => [
'ssl_options' => [
'cafile' => env('RABBITMQ_SSL_CAFILE', null),
'local_cert' => env('RABBITMQ_SSL_LOCALCERT', null),
'local_key' => env('RABBITMQ_SSL_LOCALKEY', null),
'verify_peer' => env('RABBITMQ_SSL_VERIFY_PEER', true),
'passphrase' => env('RABBITMQ_SSL_PASSPHRASE', null),
],
],
/*
* Set to "horizon" if you wish to use Laravel Horizon.
*/
'worker' => env('RABBITMQ_WORKER', 'default'),
],
// ...
],
class TestController extends \Illuminate\Routing\Controller
{
$order = new OrderTransit();
OrderQueueCall::createOrder($order);
}
class MyJob extends JsonJob
{
protected function handle(string $command, $result)
{
if($command = "CREATE_ORDER_RESULT")
{
//Handle result for createOrder
}
return true;
}
}
class TestController extends \Illuminate\Routing\Controller
{
$order = new OrderTransit();
OrderQueueCall::createOrder($order, MyJob::class);
}