Connect.php 574 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace common\logic\Amqp;
  3. /**
  4. * 连接配置
  5. * Class Config
  6. * @package common\logic\message
  7. * @author libingke
  8. */
  9. class Connect
  10. {
  11. CONST HOST = "127.0.0.1";
  12. CONST PORT = 5672;
  13. CONST USER = "guest";
  14. CONST PASS = "Guest";
  15. private static $_conn = null;
  16. private function __construct(){}
  17. private function __clone(){}
  18. public static function connect()
  19. {
  20. if (self::$_conn == null) {
  21. self::$_conn = new \PhpAmqpLib\Connection\AMQPStreamConnection(
  22. self::HOST,
  23. self::PORT,
  24. self::USER,
  25. self::PASS
  26. );
  27. }
  28. return self::$_conn;
  29. }
  30. }