Skip to content

Commit

Permalink
Merge branch 'v3.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
frost-nzcr4 committed Sep 13, 2016
2 parents dbdead5 + a636179 commit 27aa43c
Show file tree
Hide file tree
Showing 88 changed files with 1,271 additions and 1,022 deletions.
35 changes: 35 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Changes
=======

JAXL introduces changes that affects on backward compatibility:

v3.1.0

* JAXL now use autoloader from Composer, so no more `require_once 'jaxl.php'`.
* Sources moves to subfolder `src/JAXL`, class JAXLCtl goes from `jaxlctl`
to `src/JAXL/jaxlctl.php`, class HTTPDispathRule goes from `http_dispatcher.php`
to `src/JAXL/http_dispatch_rule.php`.
* Class names XEP_* drops underscores and changed to XEP* to conform PSR-2.
* All config parameters of JAXL sets on instantiation to their default values,
previously used code like `isset(JAXL->cfg['some-parameter'])` not need
`isset` anymore.
* Globally defined log functions drops their underscores and moves
to JAXLLogger, _colorize renamed to JAXLLogger::cliLog.
* JAXLXml->childrens fixed to children.
* Some methods now in camel case format (i.e. JAXL->require_xep => JAXL->requireXep).
* All constants now in upper case format (i.e. JAXL::version => JAXL::VERSION).
* Renaming of methods that starts with _ prefix, they only used in private API
and shouldn't affect you.
* JAXL_CWD not used anymore and changed to getcwd().
* Move JAXL_MULTI_CLIENT to "multi_client" config parameter.
* Globally defined NS_* now moves to XEPs constants. File xmpp_nss.php was
renamed to xmpp.php, so use XMPP::NS_*.
* JAXL_ERROR and other log levels goes to JAXLLogger::ERROR constant and so on.
* HTTP_CRLF and other HTTP_* codes goes to HTTPServer::HTTP_* constants.
* JAXLEvent->reg is not public property anymore, but you can get
it with JAXLEvent->getRegistry()
* In JAXLXml::construct first argument $name is required.
* JAXL->add_exception_handlers moves to JAXLException::addHandlers.
* If some of your applications watch for debug message that starts with
"active read fds: " then you've warned about new message format
"Watch: active read fds: " and "Unwatch: active read fds: ".
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Jaxl v3.0.3
Jaxl v3.1.0
-----------

Jaxl v3.x is a successor of v2.x (and is NOT backward compatible),
Expand All @@ -10,17 +10,17 @@ philosophies from my experience with erlang and python languages.
Jaxl is an asynchronous, non-blocking I/O, event based PHP library
for writing custom TCP/IP client and server implementations.
From it's previous versions, library inherits a full blown stable support
for [XMPP protocol stack](https://github.com/jaxl/JAXL/tree/v3.0.3/xmpp).
In v3.0, support for [HTTP protocol stack](https://github.com/jaxl/JAXL/tree/v3.0.3/http)
for [XMPP protocol stack](https://github.com/jaxl/JAXL/tree/v3.1.0/xmpp).
In v3.0, support for [HTTP protocol stack](https://github.com/jaxl/JAXL/tree/v3.1.0/http)
has also been added.

At the heart of every protocol stack sits the [Core stack](https://github.com/jaxl/JAXL/tree/v3.0.3/core).
At the heart of every protocol stack sits the [Core stack](https://github.com/jaxl/JAXL/tree/v3.1.0/core).
It contains all the building blocks for everything that we aim to do with Jaxl library.
Both XMPP and HTTP protocol stacks are written on top of the Core stack.
Infact the source code of protocol implementations knows nothing
about the standard (inbuilt) PHP socket and stream methods.

[Examples](https://github.com/jaxl/JAXL/tree/v3.0.3/examples/)
[Examples](https://github.com/jaxl/JAXL/tree/v3.1.0/examples/)

[Documentation](http://jaxl.readthedocs.org/)

Expand All @@ -30,6 +30,12 @@ about the standard (inbuilt) PHP socket and stream methods.

[Author](http://abhinavsingh.com/)

## Installation

```ShellSession
php composer.phar require "jaxl/jaxl=^3.1.0"
```

## Contributing

JAXL since v3.0.1 adopt [PSR-2](http://www.php-fig.org/psr/psr-2/).
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@
},
"autoload": {
"classmap": [
"core",
"http",
"xep",
"xmpp",
"jaxl.php"
"src/JAXL"
],
"exclude-from-classmap": [
"/tests/"
]
},
"bin": ["jaxlctl"]
"bin": ["jaxlctl"],
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
}
}
}
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
release = '3.0.3'
release = '3.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 1 addition & 2 deletions docs/users/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Install

Use `Composer <https://getcomposer.org>`_ to install:

php composer.phar require "jaxl/jaxl=^3.0.3"
php composer.phar update
php composer.phar require "jaxl/jaxl=^3.1.0"

Then use autoloader in your application:

Expand Down
6 changes: 1 addition & 5 deletions docs/users/http_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Intialize an ``HTTPServer`` instance

.. code-block:: ruby
require_once 'jaxl.php';
require_once JAXL_CWD.'/http/http_server.php';
$http = new HTTPServer();
By default ``HTTPServer`` will listen on port 9699. You can pass a port number as first parameter to change this.
Expand Down Expand Up @@ -46,8 +44,6 @@ Intialize an ``HTTPServer`` instance

.. code-block:: ruby
require_once 'jaxl.php';
require_once JAXL_CWD.'/http/http_server.php';
$http = new HTTPServer();
By default ``HTTPServer`` will listen on port 9699. You can pass a port number as first parameter to change this.
Expand Down Expand Up @@ -77,7 +73,7 @@ Define our REST resources callback methods:
$request->recv_body();
} else {
// got upload body, save it
_debug("file upload complete, got ".strlen($request->body)." bytes of data");
JAXLLogger::debug("file upload complete, got ".strlen($request->body)." bytes of data");
$request->close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/users/jaxl_instance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Constructor options
#. ``log_path``
#. ``log_level``

``JAXL_ERROR``, ``JAXL_WARNING``, ``JAXL_NOTICE``, ``JAXL_INFO`` (default), ``JAXL_DEBUG``
``ERROR``, ``WARNING``, ``NOTICE``, ``INFO`` (default), ``DEBUG``

#. ``force_tls``
#. ``stream_context``
#. ``priv_dir``

Jaxl creates 4 directories names ``log``, ``tmp``, ``run`` and ``sock`` inside a private directory
which defaults to ``JAXL_CWD.'/.jaxl'``. If this option is passed, it will overwrite default private
which defaults to ``getcwd().'/.jaxl'``. If this option is passed, it will overwrite default private
directory.

.. note::
Expand Down
22 changes: 11 additions & 11 deletions docs/users/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ rotation.
log levels
----------

* JAXL_ERROR (red)
* JAXL_WARNING (blue)
* JAXL_NOTICE (yellow)
* JAXL_INFO (green)
* JAXL_DEBUG (white)
* ERROR (red)
* WARNING (blue)
* NOTICE (yellow)
* INFO (green)
* DEBUG (white)

global logging methods
----------------------

Following global methods for logging are available:

* ``_error($msg)``
* ``_warning($msg)``
* ``_notice($msg)``
* ``_info($msg)``
* ``_debug($msg)``
* ``error($msg)``
* ``warning($msg)``
* ``notice($msg)``
* ``info($msg)``
* ``debug($msg)``

log/2
-----

All the above global logging methods internally use ``JAXLLogger::log($msg, $verbosity)``
All the above global logging methods internally use ``log($msg, $verbosity)``
to output colored log message on the terminal.
4 changes: 2 additions & 2 deletions docs/users/xml_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ developers can get lost in dirty XML manipulations spreaded all over the applica
XML structures are not only unreadable for humans but even for machine.

While an instance of ``JAXLXml`` provide direct access to XML ``name``, ``ns`` and ``text``, it can become painful and
time consuming when trying to retrieve or modify a particular ``attrs`` or ``childrens``. I was fed up of doing
time consuming when trying to retrieve or modify a particular ``attrs`` or ``children``. I was fed up of doing
``getAttributeByName``, ``setAttributeByName``, ``getChild`` etc everytime i had to access common XMPP Stanza attributes.

``XMPPStanza`` is a wrapper on top of ``JAXLXml`` objects. Preserving all the functionalities of base ``JAXLXml``
Expand All @@ -101,7 +101,7 @@ Here is a list of default access patterns:
#. ``ns``
#. ``text``
#. ``attrs``
#. ``childrens``
#. ``children``
#. ``to``
#. ``from``
#. ``id``
Expand Down
5 changes: 1 addition & 4 deletions docs/users/xmpp_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include ``jaxl.php`` and initialize a new ``JAXL`` instance:

.. code-block:: ruby
require 'jaxl.php';
$client = new JAXL(array(
'jid' => '[email protected]',
'pass' => 'password'
Expand Down Expand Up @@ -43,7 +42,7 @@ Next we need to register callbacks on events of interest using ``JAXL::add_cb/2`
function on_disconnect_callback()
{
_debug("got on_disconnect cb");
JAXLLogger::debug("got on_disconnect cb");
}
$client->add_cb('on_disconnect', 'on_disconnect_callback');
Expand Down Expand Up @@ -85,7 +84,6 @@ pass additional parameters to ``JAXL`` constructor:

.. code-block:: ruby
require 'jaxl.php';
$client = new JAXL(array(
'jid' => '[email protected]',
'pass' => 'password',
Expand All @@ -103,7 +101,6 @@ parameter as shown below:

.. code-block:: ruby
require_once 'jaxl.php';
$comp = new JAXL(array(
// (required) component host and secret
'jid' => $argv[1],
Expand Down
26 changes: 26 additions & 0 deletions examples/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Bootstrap for examples.
*/

error_reporting(E_ALL | E_STRICT);

if (PHP_SAPI !== 'cli') {
echo 'Warning: script should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
}

if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}

foreach (array(
dirname(__FILE__) . '/../../autoload.php',
dirname(__FILE__) . '/../vendor/autoload.php',
dirname(__FILE__) . '/vendor/autoload.php'
) as $file) {
if (file_exists($file)) {
require $file;
break;
}
}
unset($file);
8 changes: 4 additions & 4 deletions examples/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
*
*/

require dirname(__FILE__) . '/_bootstrap.php';

if ($argc < 2) {
echo "Usage: $argv[0] url\n";
echo "Usage: $argv[0] url".PHP_EOL;
exit;
}

require_once 'jaxl.php';
JAXLLogger::$level = JAXL_DEBUG;
require_once JAXL_CWD.'/http/http_client.php';
JAXLLogger::$level = JAXLLogger::DEBUG;

$request = new HTTPClient($argv[1]);
$request->start();
15 changes: 8 additions & 7 deletions examples/echo_bosh_bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@
*
*/

require dirname(__FILE__) . '/_bootstrap.php';

if ($argc < 3) {
echo "Usage: $argv[0] jid pass\n";
echo "Usage: $argv[0] jid pass".PHP_EOL;
exit;
}

//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array(
// (required) credentials
'jid' => $argv[1],
Expand All @@ -67,7 +68,7 @@
// (optional) defaults to PLAIN if supported, else other methods will be automatically tried
'auth_type' => isset($argv[3]) ? $argv[3] : 'PLAIN',

'log_level' => JAXL_INFO
'log_level' => JAXLLogger::INFO
));

//
Expand All @@ -77,7 +78,7 @@
function on_auth_success_callback()
{
global $client;
_info("got on_auth_success cb, jid ".$client->full_jid->to_string());
JAXLLogger::info("got on_auth_success cb, jid ".$client->full_jid->to_string());
$client->set_status("available!", "dnd", 10);
}
$client->add_cb('on_auth_success', 'on_auth_success_callback');
Expand All @@ -86,7 +87,7 @@ function on_auth_failure_callback($reason)
{
global $client;
$client->send_end_stream();
_info("got on_auth_failure cb with reason $reason");
JAXLLogger::info("got on_auth_failure cb with reason $reason");
}
$client->add_cb('on_auth_failure', 'on_auth_failure_callback');

Expand All @@ -103,12 +104,12 @@ function on_chat_message_callback($stanza)

function on_disconnect_callback()
{
_info("got on_disconnect cb");
JAXLLogger::info("got on_disconnect cb");
}
$client->add_cb('on_disconnect', 'on_disconnect_callback');

//
// finally start configured xmpp stream
//
$client->start();
echo "done\n";
echo "done".PHP_EOL;
Loading

0 comments on commit 27aa43c

Please sign in to comment.