Download the PHP package lucaj/php-rhino without Composer

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

Find this project on packagist: [[https://packagist.org/packages/lucaj/php-rhino][php-rhino]]

** Contents

  1. Quick Start
  2. Feature Tutorials
  3. Installation
  4. API Documentation

** Quick Start To get started quickly simply require or include one of the =rhino.php= files located in the base or lib/ folder of this framework in the =index.php= file of your application.

You can then call the exported =rhino()= function to instantiate this framework's main application and assign the return to a variable - conventionally named =$app=.

Next use instance methods of the application object to register middleware and routehandler. =use()= registers a middleware with this application while methods like =get()=, =post()= and =delete()= register route handlers which result in a final http response to the client.

Finally a call to the =start()= method must be made after all components have been registered on the application object.

+BEGIN_SRC php

+END_SRC

*** Secondary Routers Additional routers can be instantiated from the original Application =$app= instance. These routers hold most of the same methods that the Application instance has. Secondary routers can be mounted on a custom path on other routers or the main application.

Secondary routers are used to segment different resources into their own files and to later mount them on a common url resouce path.

+BEGIN_SRC php

// in users.php $router = $app->router();

$router->get('/', function($req, $res) { // do stuff });

$router->get('/:id', function($req, $res) { // do stuff });

// in index.php require_once (dirname(file) . '/routes/users.php');

$app->use('/api/users/', $router);

// routes registered on $router are now available on /api/users/...

+END_SRC

*** Middleware Middleware is functionality that is executed as part of the request-response cycle. The =use()= method registers middleware functions on a given path. Those middleware functions are defined like regular route handlers but do not automatically terminate the request response cycle after they are finished executing.

+BEGIN_SRC php

<?php // this middleware is used to check whether the client has the required // authentication and is executed on all routes of the 'users' resource.

$app->use('/api/users/*', function($req, $res) { if (!$req->get('X-Token')) { $res->status(401)->send('Access denied. No token provided.'); $res->end(); }

// authenticate some more });

+END_SRC

*** Built-In Request Validation To use the built-in validator you must import =/lib/addons/validation.php= in your main /index.php/ file.

** Installation The recommended way of installing this framework is placing the =lib/= folder in the root or =vendor/= folder of your project and then requiring the main =rhino.php= file in your app's main index.php file. That's it - you are ready to go.

+BEGIN_SRC php

<?php

require_once (dirname(FILE) . "/lib/rhino.php");

+END_SRC

** API Documentation

$jsonparse

*** rhino() Generate the request and response objects used throughout the application and return a new instance of this framework's main Application class.

+BEGIN_SRC php

@param $options Array - optional parameter mapping of settings (see api docs)
@return Application

+END_SRC

*** Application Application is a router that can register middleware and route handlers and mount other routers. It inherits all methods and properties from the =Router= class.

The Application class inherits two additional methods. One to start the application by iterating over this applications route $queue and one to generate a new router.

**** start(): void Start this application.

Iterate over all registered route queue collections, match routes and execute middleware and response callback functions.

**** router(): Router Return a new router.

+BEGIN_SRC php

@return {Router} new router instance generated using this application.

+END_SRC

*** Router The Router serves as a collection to which route handlers, middleware and other routers can be registered to.

The objects registered to this router are stored in the $queue collection.

This collection is traversed by the main collection until all matching routes have been found or the request response cycle has been terminated.

Numerous functions to register routes to this router are available as instance methods on this class.

Use the .use(), .get(), .post(), .put(), .delete(), and .all() methods to register routes with a router. See the api documentation for examples.

**** use(...$args): void Register the provided arguments with this router's routing $queue either as middleware or as a router according to their data type.

Optionally a url string may be provided to specify the target route or resource direction. If no url string is provided the root location will be assumed as the default route.

+BEGIN_SRC php

@param $args Array - Array of a url string, closure functions or Router.

+END_SRC

**** post, get, put, delete(...$args): void Register provided arguments as middleware by calling the registerRouteHandler() function with the appropriate http method.

+BEGIN_SRC php

@param $args Array - Array of a url string and closure functions.

+END_SRC

**** all(...$args): void Register provided arguments as middleware by calling the registerRouteHandler() function with the appropriate http method.

+BEGIN_SRC php

@param $args Array - Array of a url string and closure functions.

+END_SRC

*** Request The Request class holds all relevant information about a received http request and a method to conveniently retrieve http header values.

**** $app A reference to the Application instance this Request belongs to.

**** $headers ArrayMap of all http headers sent with this request.

**** get($header): string Returns the specified HTTP request header field. Argument header names and stored header keys are case-insensitive.

+BEGIN_SRC php

@param $header {string} - name of a http header. @return {string} return the value of a specific header or null if not set.

+END_SRC

**** $body The raw content of this request's payload or request body represented as a string. The request body can be automatically parsed as JSON by registering the built-in =$jsonparse= middleware on the desired routes.

**** $params A map of route parameters to parameter values.

**** $queryString Holds the query string sent with this request.

**** $query A map of query string parameters to query string parameter values.

**** $originalUrl The entire original recipient url used with this Request. Do not modify this url.

**** $url A copy of the original url. This field may be modified and used for app internal routing by the programmer or third party middleware / plugins.

**** $method The http method used to send this request.

**** $hostname Name of the host that this Request is addressed to.

**** $port The Port number that this Request is addressed to.

*** Response The Response class provides useful methods to set http response codes, write to the http response stream, and to break out of the request response cycle by ending the http response.

**** $app A reference to the Application instance this Request belongs to.

**** set($header, $value): Response Set an http response header to a given value. This function can not be used after the http response body has been written to.

+BEGIN_SRC php

@param $header {string} http header @param $value {string} http header value @return Response - a reference to this response object to allow chaining.

+END_SRC

**** send($body): Response Write a given string to the http response stream.

+BEGIN_SRC php

@param $body {string} text to write to the http response body. @return Response - a reference to this response object to allow chaining.

+END_SRC

**** json($body): Response Automatically convert an object, array or map to a json formatted string, set the 'Content-Type' http header to 'application/json' and write the string to the http response stream.

+BEGIN_SRC php

@param $body object - object, array or map @return Response - a reference to this Response object to allow chaining.

+END_SRC

**** end(): void End the http response by throwing a new EndResponse Exception. The http output stream closes when this function is called.

**** status($code): Response Set the http status code to the given value.

+BEGIN_SRC php

@param $code {int} http status code @return Response - a reference to this response object to allow chaining.

+END_SRC

**** sendStatus($code): Response Set the http status code to the given value and write the conventional status message to the response body.

+BEGIN_SRC php

@param $code {int} http status code @return Response - a reference to this response object to allow chaining.

+END_SRC


All versions of php-rhino with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.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 lucaj/php-rhino contains the following files

Loading the files please wait ....