Download the PHP package vogon101/dynamic-endpoints without Composer

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

DynamicEndpoints

A super-simple PHP library for creating nice APIs. It allows you to have urls like api.foo.com/my/endpoint/2

The Idea

When writing an HTTP API in PHP it is much nicer to have a url like this: api.foo.com/books/2 instead of this api.foo.com/books.php?id=2. This is simple enough to do, use a custom apache 404 page, then parse the URL, but that can be a pain. So I made a tiny library for it.

Usage

For a working example, see the test directory.

.htaccess

In the root folder you have to have a .htaccess file that defines a main page, perhaps index.php as the 404 ErrorDoucument. It could look like this:

PHP

First, import the sources:

or use composer and just require your autoload.php:

Next, create an API object. $base is the path that you want all the APIs to come off of. For example for something like this: http://foo.com/my-thing/api/ the $base would be /my-thing/api. Base can be blank, for something at the root url.

Now, you have to register the endpoints. These define what URLs can be accessed through the API. The keys are the endpoint strings and the values are the files to be run if the endpoint is accessed. They can contain named variables and wildcards:

So /api/book/%id will match this /api/book/2 and it will pass $id with value 2. However because /api/book/name/%name is very similar to the %id one, if a user were to navigate to /api/book/name/ then the algorithm will match it to the %id endpoint, loading it with $id = "name"

Now we simply run the API. This will include the file specified if the enpoint matches. The variables will be set as specified in the scope of the file. If no endpoint is found, and array will be returned with an key of "Error".

License

The software is avaliable under the Creative Commons Attribution 4.0 International. It can be found here: http://creativecommons.org/licenses/by/4.0/


All versions of dynamic-endpoints with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 vogon101/dynamic-endpoints contains the following files

Loading the files please wait ....