i have an error in my code. I want to call the get_mail() function in the index function. This code is rabbitmq with phpcodeigniter consumer code, error message is:
Type: Error
Message: Class 'get_mail' not found
Filename: C:\xampp\htdocs\mail\application\controllers\Consumer.php
Line Number: 45
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH.'../vendor/autoload.php';
use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Exchange\AMQPExchangeType;
class Consumer extends CI_Controller {
public function index(){
$host = "secret";
$port = 5672;
$user = "secret";
$pass = "secret";
$vhost = "secret";
$exchange = 'router';
$queue = 'mail';
$consumerTag = 'consumer';
$connection = new AMQPStreamConnection($host, $port, $user, $pass, $vhost);
$channel = $connection->channel();
$channel->queue_declare($queue, false, true, false, false);
$channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false);
$channel->queue_bind($queue, $exchange);
function process_message($message)
{
$pesan = json_decode($message->body);
$isi = $pesan->email;
$this->get_mail();
$message->ack();
}
$channel->basic_consume($queue, $consumerTag, false, false, false, false, 'process_message');
function shutdown($channel, $connection)
{
$channel->close();
$connection->close();
}
register_shutdown_function('shutdown', $channel, $connection);
while ($channel ->is_consuming()) {
$channel->wait();
}
}
public function get_mail($isi){
//this is function for send mail in codeigniter
}
// Loop as long as the channel has callbacks registered
}
/* End of file Consumer.php */
?>
this is error message from php: Type: Error
Message: Using $this when not in object context
Filename: C:\xampp\htdocs\mail\application\controllers\Consumer.php
Line Number: 45