Download the PHP package napkinware/presto without Composer

On this page you can find all versions of the php package napkinware/presto. 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 presto

Presto 1.1

Frugal PHP + REST toolkit

Presto is a library for building RESTful APIs in PHP 5.3+. It's lightweight, decoupled, and focused on making web apps the right way; using APIs and clean URLs to produce output in standard formats like JSON, HTML, and XML. It encourages separating views completely from your model and controller code, and to animate your user interfaces in HTML, CSS, and JavaScript. It also uses existing tools and libraries for what they're good at, like letting Apache deal with routing, and letting PHP load and execute a minimal amount of dynamic code.

How is Presto different?

Presto flattens standard MVC to fit REST requests better. It focuses on APIs built from simple classes, relying on the web server for routing and on PHP autoloading for delegating requests to class member calls. User interfaces are left to other toolkits, though Presto can serve up fragments of HTML with ease. Presto focuses on APIs.

A quick example

An API is a class with members named for each resource (or tree of resources). For example, an apple is a resource. You can request an apple over HTTP:

GET fruit/apples/spartan.json?tags=large+red

Presto maps the request to a file, class, and class member automatically. It loads the file, creates an instance of the class, and executes the member that best fits:

/* Loaded from 'fruit/apples.php' */

class apples extends API {

    public function get($params, $options, $body, $type) {

        if (count($params) === 0)
            throw new Exception('Missing required parameter', 400);

        /* Exceptions are returned as valid HTTP/content type 
                responses */

        $thing = (object) array(
            'name' => $params[0],
            'tags' => $options['tags']
        );

        return $thing; // to client in requested format
    }
}

The $thing is automatically converted by Presto to the requested Content-Type, either implied by the request or the appropriate HTTP header. For formats not supported by default, Output Adapters can be defined and registered, or the type can be passed through for resources that are not based DOM style data.

Any HTTP request type is mapped automatically. For example, you can request a list of apple types available from the API:

LIST apples.json?colour=red

A LIST request is mapped to a function of the same name:

public function list(/* … */) { return array(); }

More complex resources are possible by either delegating (based on regex patterns), or by adding specific handlers. For example, you could add a seeds branch to the apple resource. Getting a list of seeds would map to:

public function list_seeds(/* … */) { array(); }

What about errors?

Errors are handled by the toolkit as standard PHP exceptions and standard PHP errors are remapped (where possible) to exceptions to ensure that logic and code errors are returned to clients as valid API returns. This means that individual APIs do not need to check return values, nor do they need to try and catch unless they need to do something special. Presto maps the standard exceptions to HTTP statuses and output in whatever format was requested where possible.

For example, if you encounter a parameter error you can simply throw an exception:

if (empty($param))
    throw new Exception('Missing required parameter', 400);

Presto translates the exception into a 400 with an appropriately encoded body.

The resulting API code is much more focused on carefully testing parameters, retrieving appropriate resources, and building rich DOMs instead of boilerplate code, managing responses, excessive error checking, routing, and other complex output generation.

Other interesting features

You can also:

Note that PHP 5.3 or better is required, as Presto relies on anonymous functions and other newer PHP features. This makes it possible to write very clean, simple web services.


All versions of presto with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.15
ext-curl Version >=0
ext-fileinfo Version >=1.0.0
ext-date Version >=5.3.0
ext-json Version >=1.2.1
lib-openssl Version >=0.9
lib-curl Version >=7.24.0
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 napkinware/presto contains the following files

Loading the files please wait ...