Download the PHP package nexus-rest-api/nexus without Composer

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

Nexus

Nexus php is a lightweight and fast PHP framework for building RESTful APIs.

Installation

Easy installation via Composer:

Getting started

APP

Nexus rest api uses an app decorator to handle all the functionality. There is also a possibility to pass config to the app while creating it. The order of values in config does not matter but the key names do.

ENVIRONMENTS

The framework allows for two different environments namely development and production. The difference being that in development if there is an error the stacktrace will be shown in the response. environment is part of the config of the app. By default development is set as the env.

HTACCESS

A .htaccess file is required for the router to work.

SERVING THE APP

If your using composer the following script in the composer.json file will launch the app on port 9000 when typing the command composer start in the terminal.

ROUTER AND REQUESTS

All request are handled by the router, the requests use a string as name and a callback for the logic of the request. The router returns the data in json format. The order and format of the parameters in the request is not important. The following requests are supported in this framework:

examples:

Important request object parameters

Parameter code example info
totalRequestTime $request->totalRequestTime returns in milliseconds how long the request took to complete
requestUri $request->requestUri returns the uri of the request
requestMethod $request->requestMethod returns the http method used in the request
httpAuthorization $request->httpAuthorization returns the bearer token given with the request
params $request->params() returns the params of the request
body $request->body() returns the body of the request

ROUTER GROUPS

The router can group routes together and set a prefix for all routes in that group. Note nesting groups is not supported yet.

example:

MIDDLEWARE

Middleware is an extra function passed on to a request that is executed before the request is handled. The middleware can also stop a route from being executed, this by not calling the $next() function.

example:

DATABASE CONNECTION

in the config of the app, you can configure the database for the app to use. The app allows you to open and close the connection on demand with the functions dbConnect() and dbDisconnect(). The example below uses a prepared statement to combat sql injections. A normal statement can also be used.

MODULES

If you want to add extra functionality to the app eg. a logger. This can be done use the append module method. This takes a key (string) and a value (object or closure).

ERROR HANDLING

The router has build in error handling, this framework comes with some exceptions that can be thrown throughout the application. These exceptions will be caught by the router and an error message wil be send to the end user.

Different exceptions

HTTP status code Name Exception
400 Bad Request throw new BadRequestException(String)
401 Unauthorized throw new UnauthorizedException(String)
403 Forbidden throw new ForbiddenException(String)
404 Not Found Handled by the router
413 Payload Too Large throw new PayloadTooLargeException(String)
429 Too Many Requests throw new TooManyRequestsException(String)
500 Internal Server Error Fallback for exceptions not in this list and other errors
501 Not Implemented throw new NotImplementedException(String)
502 Bad Gateway throw new BadGatewayException(String)

OPTIMIZING THE APP

Once done with developing you app. You can add this script and config option to you composer.json file to optimize the composer autoloader. Note using the build command during development can cause issues!

Suggested packages to use with this framework


All versions of nexus with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.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 nexus-rest-api/nexus contains the following files

Loading the files please wait ....