Home > Download >  Library download

  • edis is a key-value storage system. Similar to Memcached, it supports relatively more stored value types, including string (string), list (linked list), set (set), zset (sorted set - ordered set) and hash (hash type). These data types all support push/pop, add/remove, intersection, union, difference, and richer operations, and these operations are all atomic. On this basis, redis supports various different ways of sorting. Like memcached, data is cached in memory to ensure efficiency. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave (master-slave) synchronization is achieved. Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Java, C/C, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, which is very convenient to use. <?php require __DIR__.'/shared.php'; use Predis\Command\CommandInterface; use Predis\Connection\StreamConnection; class SimpleDebuggableConnection extends StreamConnection {     private $tstart = 0;     private $debugBuffer = array();     public function connect()     {         $this->tstart = microtime(true);         parent::connect();     }

    Other libraries16612017-12-12
  • Using the database abstraction layer means that there is almost no need to change too much program code when migrating from one database system to another, such as migrating MS SQL Server to MySQL. First of all, the code planning must be standardized, that is, the entire system uses the same data object instance and the same good database abstraction layer. If one day the user requires switching Oracle to MySQL, all he needs to do is change the system configuration file. In today's industrial field, each database developer such as Microsoft, Oracle, and MySQL has its own set of SQL standards. They claim to add their own features in accordance with the ANSI SQL92 standard in order to monopolize or occupy the market. The excellent database abstraction layer will automatically adjust some SQL performance based on the database we are currently using. When you are not using specific features of the database itself, you don't have to change too many database connections and database SQL queries. Other benefits of using a database abstraction layer are that its nature and concepts simplify complex tasks. Therefore, we do not have to learn completely new features of a database system, but only use the code features of a standard abstraction layer. <?php use Bernard\Message\PlainMessage; class EchoTimeService {     public function echoTime(PlainMessage $message)     {         if (rand(0, 10) == 7) {             throw new \RuntimeException('I failed because rand was 7');         }         usleep(100);     } }

    Other libraries11712017-12-12
  • AMQP, Advanced Message Queuing Protocol, is an application layer standard advanced message queuing protocol that provides unified message services. It is an open standard for application layer protocols and is designed for message-oriented middleware. Clients and message middleware based on this protocol can transmit messages and are not restricted by different client/middleware products, different development languages, etc. Implementations in Erlang include RabbitMQ, etc. abstract class AbstractChannel {     const PROTOCOL_080 = '0.8';     const PROTOCOL_091 = '0.9.1';     public static $PROTOCOL_CONSTANTS_CLASS;     public function __construct(AbstractConnection $connection, $channel_id)     {         $this->connection = $connection;         $this->channel_id = $channel_id;         $connection->channels[$channel_id] = $this;         $this->frame_queue = array(); // Lower level queue for frames         $this->method_queue = array(); // Higher level queue for methods         $this->auto_decode = false;         $this->msg_property_reader = new AMQPReader(null);         $this->wait_content_reader = new AMQPReader(null);         $this->dispatch_reader = new AMQPReader(null);         $this->protocolVersion = self::getProtocolVersion();         switch ($this->protocolVersion) {             case self::PROTOCOL_091:                 self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\Wire\Constants091';                 $c = self::$PROTOCOL_CONSTANTS_CLASS;                 $this->debug = new DebugHelper($c);                 $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;                 $this->protocolWriter = new Protocol091();                 $this->waitHelper = new Wait091();                 $this->methodMap = new MethodMap091();                 break;             case self::PROTOCOL_080:                 self::$PROTOCOL_CONSTANTS_CLASS = 'PhpAmqpLib\Wire\Constants080';                 $c = self::$PROTOCOL_CONSTANTS_CLASS;                 $this->debug = new DebugHelper($c);                 $this->amqp_protocol_header = $c::$AMQP_PROTOCOL_HEADER;                 $this->protocolWriter = new Protocol080();                 $this->waitHelper = new Wait080();                 $this->methodMap = new MethodMap080();                 break;             default:                 throw new AMQPRuntimeException(sprintf(                     'Protocol: %s not implemented.',                     $this->protocolVersion                 ));         }     }

    Other libraries15462017-12-12
  • The OAUTH protocol provides a secure, open and simple standard for the authorization of user resources. At the same time, any third party can use the OAUTH authentication service, and any service provider can implement its own OAUTH authentication service, so OAUTH is open. The industry provides multiple implementations of OAUTH, such as PHP, JavaScript, Java, Ruby and other language development kits, which greatly saves programmers' time, so OAUTH is simple. Many Internet services such as Open API, and many large companies such as Google, Yahoo, Microsoft, etc. provide OAUTH authentication services. These are enough to show that the OAUTH standard has gradually become the standard for open resource authorization. <?php namespace OAuth; use OAuth\Common\Service\ServiceInterface; use OAuth\Common\Consumer\CredentialsInterface; use OAuth\Common\Storage\TokenStorageInterface; use OAuth\Common\Http\Client\ClientInterface; use OAuth\Common\Http\Client\StreamClient; use OAuth\Common\Http\Uri\UriInterface; use OAuth\Common\Exception\Exception; use OAuth\OAuth1\Signature\Signature; class ServiceFactory {     protected $httpClient;     protected $serviceClassMap = array(         'OAuth1' => array(),         'OAuth2' => array()     );     protected $serviceBuilders = array(         'OAuth2' => 'buildV2Service',         'OAuth1' => 'buildV1Service',     );     public function setHttpClient(ClientInterface $httpClient)     {         $this->httpClient = $httpClient;         return $this;     }

    Other libraries11862017-12-12
  • rabbitmq (MQ) stands for Message Queue. Message Queue is an application-to-application communication method. Applications communicate by reading and writing messages to and from queues without requiring a dedicated connection to link them. Message passing refers to programs communicating with each other by sending data in messages, rather than by making direct calls to each other, which is typically used for techniques such as remote procedure calls. Queuing refers to applications communicating through queues. The use of queues removes the requirement that receiving and sending applications execute simultaneously. Among the more mature MQ products are IBM WEBSPHERE MQ and so on. <?php require __DIR__ . '/../vendor/autoload.php'; use PhpAmqpLib\Connection\AMQPLazyConnection; use Thumper\ConnectionRegistry; $connections = array(     'default' => new AMQPLazyConnection('localhost', 5672, 'guest', 'guest', '/') ); $registry = new ConnectionRegistry($connections, 'default');

    Other libraries17212017-12-12
  • rabbitmq (MQ) stands for Message Queue. Message Queue is an application-to-application communication method. Applications communicate by reading and writing messages to and from queues without requiring a dedicated connection to link them. Message passing refers to programs communicating with each other by sending data in messages, rather than by making direct calls to each other, which is typically used for techniques such as remote procedure calls. Queuing refers to applications communicating through queues. The use of queues removes the requirement that receiving and sending applications execute simultaneously. Among the more mature MQ products are IBM WEBSPHERE MQ and so on. <?php namespace PhpAmqpLib\Connection; class AMQPLazyConnection extends AMQPStreamConnection {     /**      * Gets socket from current connection      *      * @deprecated      */     public function getSocket()     {         $this->connect();         return parent::getSocket();     }     /**      * {@inheritdoc}      */     public function channel($channel_id = null)     {         $this->connect();         return parent::channel($channel_id);     }     /**      * @return null|\PhpAmqpLib\Wire\IO\AbstractIO      */     protected function getIO()     {         if (empty($this->io)) {             $this->connect();         }         return $this->io;     }     /**      * Should the connection be attempted during construction?      *      * @return bool      */     public function connectOnConstruct()     {         return false;     } }

    Other libraries15402017-12-12
  • Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action streaming data in consumer-scale websites. Such actions (web browsing, searches and other user actions) are a key factor in many social functions on the modern web. This data is typically addressed by processing logs and log aggregation due to throughput requirements. For log data and offline analysis systems like Hadoop, but requiring real-time processing constraints, this is a feasible solution. The purpose of Kafka is to unify online and offline message processing through Hadoop's parallel loading mechanism, and to provide real-time consumption through clusters. <?php $rk = new RdKafka\Consumer(); $rk->setLogLevel(LOG_DEBUG); $rk->addBrokers("127.0.0.1"); $topic = $rk->newTopic("test"); $topic->consumeStart(0, RD_KAFKA_OFFSET_BEGINNING); while (true) {     $msg = $topic->consume(0, 1000);     if ($msg->err) {         echo $msg->errstr(), "\n";         break;     } else {         echo $msg->payload, "\n";     } }

    Other libraries16472017-12-12
  • The OAUTH protocol provides a secure, open and simple standard for the authorization of user resources. At the same time, any third party can use the OAUTH authentication service, and any service provider can implement its own OAUTH authentication service, so OAUTH is open. The industry provides multiple implementations of OAUTH, such as PHP, JavaScript, Java, Ruby and other language development kits, which greatly saves programmers' time, so OAUTH is simple. Many Internet services such as Open API, and many large companies such as Google, Yahoo, Microsoft, etc. provide OAUTH authentication services. These are enough to show that the OAUTH standard has gradually become the standard for open resource authorization. class ServiceFactory {     protected $httpClient;     protected $serviceClassMap = array(         'OAuth1' => array(),         'OAuth2' => array()     );     protected $serviceBuilders = array(         'OAuth2' => 'buildV2Service',         'OAuth1' => 'buildV1Service',     );     public function setHttpClient(ClientInterface $httpClient)     {         $this->httpClient = $httpClient;         return $this;     }     public function registerService($serviceName, $className)     {         if (!class_exists($className)) {             throw new Exception(sprintf('Service class %s does not exist.', $className));         }         $reflClass = new \ReflectionClass($className);         foreach (array('OAuth2', 'OAuth1') as $version) {             if ($reflClass->implementsInterface('OAuth\' . $version . '\Service\ServiceInterface')) {                 $this->serviceClassMap[$version][ucfirst($serviceName)] = $className;                 return $this;             }         }         throw new Exception(sprintf('Service class %s must implement ServiceInterface.', $className));     }

    Other libraries16182017-12-12
  • MongoDB is a product between a relational database and a non-relational database. It is the most feature-rich among non-relational databases and is most like a relational database. The data structure it supports is very loose and is a bson format similar to json, so it can store more complex data types. The biggest feature of Mongo is that the query language it supports is very powerful. Its syntax is somewhat similar to an object-oriented query language. It can almost implement most functions similar to single-table queries in relational databases, and it also supports indexing of data. <?php include 'src/MongoQB/Builder.php'; class QBtest extends PHPUnit_Framework_TestCase { function defaultConnect($connect = true) { return new \MongoQB\Builder(array( 'dsn'=>'mongodb://localhost:27017/mongoqbtest', 'query_safety'=>null ), $connect); }

    Other libraries12272017-12-12
  • MongoDB is a product between a relational database and a non-relational database. It is the most feature-rich among non-relational databases and is most like a relational database. The data structure it supports is very loose and is a bson format similar to json, so it can store more complex data types. The biggest feature of Mongo is that the query language it supports is very powerful. Its syntax is somewhat similar to an object-oriented query language. It can almost implement most functions similar to single-table queries in relational databases, and it also supports indexing of data. <?php namespace League; use League\Monga\Connection; use MongoBinData; use MongoCode; use MongoConnectionException; use MongoDate; use MongoId; use MongoRegex; class Monga {     public static function data($data, $type = null)     {         $type === null && $type = MongoBinData::BYTE_ARRAY;         return new MongoBinData($data, $type);     }     public static function id($id)     {         return new MongoId($id);     }     public static function code($code, array $scope = [])     {         return new MongoCode($code, $scope);     }     public static function date($sec = null, $usec = 0)     {         $sec === null && $sec = time();         return new MongoDate($sec, $usec);     }     public static function regex($regex)     {         return new MongoRegex($regex);     }     public static function connection($server = null, array $options = [], array $driverOptions = [])     {         return new Connection($server, $options, $driverOptions);     } }

    Other libraries11312017-12-12
  • Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action streaming data in consumer-scale websites. Such actions (web browsing, searches and other user actions) are a key factor in many social functions on the modern web. This data is typically addressed by processing logs and log aggregation due to throughput requirements. For log data and offline analysis systems like Hadoop, but requiring real-time processing constraints, this is a feasible solution. The purpose of Kafka is to unify online and offline message processing through Hadoop's parallel loading mechanism, and to provide real-time consumption through clusters. <?php namespace Kafka; class Broker {     use SingletonTrait;     private $groupBrokerId = null;     private $topics = [];     private $brokers = [];     private $metaSockets = [];     private $dataSockets = [];     private $process;     private $socket;     private $config;     public function setProcess(callable $process)     {         $this->process = $process;     }

    Other libraries18952017-12-12
  • There are many situations that involve data exchange between php and java. Generally, it is exchanged through json data format. But for example: the mall is developed using PHP, and the management system is developed using Java language, which will involve data interaction, and PHP has serialized the data and stored it in the database, and Java must also parse it, so it will There is this PHP library for HTML5 parsing and serialization. Help everyone easily achieve this effect<?php require "vendor/autoload.php"; use Masterminds\HTML5; $html = <<< 'HERE'   <html>   <head>   <title>TEST</title>   <script language="javascript">   if (2 > 1) { alert("Math wins."); }   </script>   </head>   <body id='foo'>   <!-- This space intentionally left blank. -->   <section class="section-a pretty" id="bar1">   <h1>Hello World</h1><p>This is a test of the HTML5 parser.</p>   <hr>   &amp; Nobody nowhere.   </section>   <test xmlns:foo="http://example.com/foo">TEST</test>   <![CDATA[Because we can.]]>   &copy;   </body></html> HERE; $html5 = new HTML5(); $dom = $html5->loadHTML($html); print "Converting to HTML 5\n"; $html5->save($dom, fopen("php://stdin", 'w')); ##

    Other libraries12122017-12-12