Download the PHP package danielbragaalmeida/extdirect without Composer

On this page you can find all versions of the php package danielbragaalmeida/extdirect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package extdirect

extdirect

An PHP implementation of the Sencha Ext Direct Specification

This project has some code from J. Bruni (ExtDirect.php)

Install

composer require danielbragaalmeida/extdirect

How to Use

PHP

config.php

<?php
return [
    'discoverer' => [
        'paths' => [ // Directories of your classes
            __DIR__ . '/src', 
        ]
    ],
    'cache' => [
        'directory' => __DIR__ . '/cache',
        'lifetime' => 60,
    ],
    'api' => [
        'descriptor' => 'window.uERP_REMOTING_API',
        'declaration' => [
            'url' => 'http://api.myadomain.com/router.php', // Your router may be in another domain
            'type' => 'remoting',
            'id' => 'uERP', // it's required for the cache mechanism
            'namespace' => 'Ext.php',
            'timeout' => null,
        ]
    ]
];

Sample class src/Server.php

<?php
namespace Util;

/**
 * Class Server
 *
 * @ExtDirect
 * @ExtDirect\Alias UtilServer
 */
class Server
{
    /**
     * @param $format
     * @return bool|string
     * @ExtDirect
     */
    public function date($format)
    {
        return date($format);
    }

    /**
     *
     * @return string
     * @ExtDirect
     */
    public function hostname()
    {
        return gethostname();
    }
}

api.php

<?php
require_once __DIR__ . '/../vendor/autoload.php';

$config = new ExtDirect\Config(include 'config.php');

$discoverer = new ExtDirect\Discoverer($config);
$discoverer->start();

router.php

<?php
require_once __DIR__ . '/../vendor/autoload.php';

$config = new ExtDirect\Config(include 'config.php');

$discoverer = new ExtDirect\Router($config);
$discoverer->route();

HTML

<-- API in same domain -->
<script type="text/javascript" src="api.php"></script>

<-- API in another domain -->
<script type="text/javascript" src="http://api.mydomain.com/api.php"></script>

JavaScript:

Here, you can call actions/methods from your API. If you exposed the Util\Server (alias UtilServer) class and the date method, You must class the API as follows:

Ext.Direct.addProvider(window.uERP_REMOTING_API); // window.uERP_REMOTING_API is your descriptor
Ext.php.UtilServer.date('Y-m-d', function(result) {
    alert('Server date is ' + result); 
});

Features

  1. Configure once, work everywhere.

    You configure the path where your classes resides, not which classes you will expose.

  2. Use of Annotations to easily determine which classes and methods are exposed. All classes with @ExtDirect will be inspected for methods that can be exposed (only methods com @ExtDirect will be exposed).

  3. Cache mechanism. Your API classes/methods will be cached to avoid overloading the discovery process. You can configure the cache lifetime.

Configuration

An array with the following structure:

Discovery config

discovery.paths: An array with paths to your classes.

<?php
...
'discoverer' => [
    'paths' => [
        __DIR__ . '/../src',
        __DIR__ . '/../lib',
    ]
],
...

cache.directory: The directory that will be used to store the cached data.

cache.lifetime: The cache lifetime, in seconds.

<?php
...
'cache' => [
    'directory' => __DIR__ . '/../cache',
    'lifetime' => 60,
],
...

API config

api.descriptor: The JavaScript variable which will receive the API declaration.

api.declaration.url: The Service URI for this API.

api.declaration.type: MUST be either remoting for Remoting API, or polling for Polling API.

api.declaration.id: The identifier for the Remoting API Provider. This is useful when there are more than one API in use. Cache mechanism require it.

api.declaration.namespace: The Namespace for the given Remoting API.

api.declaration.timeout: The number of milliseconds to use as the timeout for every Method invocation in this Remoting API. (not implemented)


All versions of extdirect with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
nette/reflection Version ^2.4.2
zendframework/zend-diactoros Version ^1.4
doctrine/cache Version ^1.7
neomerx/cors-psr7 Version ^1.0
zendframework/zend-stratigility Version ^2.0.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package danielbragaalmeida/extdirect contains the following files

Loading the files please wait ....