Download the PHP package justso/justapi without Composer

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

JustAPI

Simple REST API based on plain PHP.

It works as a front controller to call an appropriate service class for the requested API call.

Installation

Composer

composer require justso/justapi

git

git clone git://github.com/JustsoSoftware/JustAPI.git vendor/justso/justapi

Setup

Create a config.json file in your root folder containing at least the following attributes:

The service locator is either a PHP class name or begins with the keyword 'file:', saying that service calls matching this pattern are handled by another list of services, located in the 'vendor' folder. The name after 'file:' is the location of the service.

Each environment you specify, should contain at least the AppRoot which is the local path on the server where your code is checked out, e.g. '/var/www/'. Additionally, it should specify the URLs for the application and optionally the API.

Here is a complete example for such a config.json file:

If using Apache, you should configure it to have

In NginX, you could work with rewriting:

This should invoke the front controller whenever a service is called on the sub directory '/api'. It is possible to use JustAPI in a subdomain, e.g. 'api.example.com' as well.

Autoloader

JustAPI contains a PSR-0 compliant autoloader. It is recommended to use it for your custom classes as well. You only have to specify them in your config.json file in the 'packages' list with its path.

SystemEnvironment

A key element of all classes in JustAPI is SystemEnvironment class and its SystemEnvironmentInterface. It is the connection to all operating system functions, contains information about the installation, given parameters and the file system.

Dependency Injection Container

The package contains a simple Dependency Injection Container which can be configured in /conf/dependencies.php file. It should contain only a return statement with a list of definitions with an identifier each. It is a good practice to use the class name for the definition as the identifier, though it is possible to use other names.

If you use this convention and simply want to create new objects, then no definition is needed for that. You can instantiate new objects then by calling $object = $dic->get('\MyNameSpace\MyClassName');.

It is possible to give an array of parameters to the get() call as a second parameter. If you don't specify any parameters, at least the SystemEnvironment of the DependencyContainer is used as a parameter to the constructor.

If you want a class to be a singleton, place an entry in your dependencies.php file using the singleton() function:

This makes sure that every call to get() will return the same object. This object is instantiated the first time get() is called for that object with the SystemEnvironment and a scalar value of 123 as constructor parameters.

Specifying controller classes

To actually handle API requests, you must implement classes and derive from RestService to handle these requests and specify them in config.json. So, if your service class 'My\Cool\RestService' should handle requests on '/api/my/service', your 'services' entry should look like this:

If your class should handle calls like '/api/my/service/77' as well, the entry may contain a wildcard (*):

All requests matching the pattern are given to the service class then. It is possible to use wildcards in the middle of a service specification as well, e.g.

The service class can implement one or more of the following methods:

Output is placed in $this->environment and never be printed or echoed.

Upgrading from version 2

If you upgrade from version 2, you should change a few things in your config.json file.

Support & More

If you need support, please contact us: http://justso.de


All versions of justapi with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.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 justso/justapi contains the following files

Loading the files please wait ....