Download the PHP package jeanisahakyan/motion-dots without Composer

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

MotionDots Documentation

MotionDots is a PHP framework designed to simplify API development by providing tools for dynamic method invocation, input validation, structured responses, and more. It streamlines the process of building APIs by handling common tasks such as parameter validation, response formatting, error handling, and supports the use of native PHP 8.1 enums for robust type definitions.


What is MotionDots?

MotionDots is a lightweight PHP framework that aids in developing APIs by providing:

Purpose and Use Cases

MotionDots is ideal for:


Getting Started with MotionDots

Installation via Composer

Ensure your PHP version is 8.1 or higher.

Install MotionDots via Composer by adding it to your composer.json or running:

Recommended Project Structure

Organize your project as follows:

Creating the API Processor

The API processor handles incoming requests and routes them to the appropriate methods. Place it in src/YourProcessor.php.

Example YourProcessor.php:

Explanation:

Then, in your index.php, you can instantiate and use this processor:

Example index.php:

Creating a New API Method

API methods are organized into classes extending AbstractMethod. Each public method in the class becomes an API endpoint.

Defining the Method Class

Create a new class in src/API/Methods/.

Example:

Implementing API Methods

Define public methods in your class using camelCase. The method's name, combined with the class name, forms the API endpoint.

Method: registerUser

Definition:

Usage of Context in Method:

Request Example:

Response Example:

Method: loginUser

Definition:

Request Example:

Response Example:

Method: updateUserStatus

Definition:

Request Example:

Response Example:

Creating a New Response

Responses extend AbstractResponse and define the structure of the data returned to the client. The AbstractResponse class automatically handles JSON serialization of public properties.

Example:

Note: The AbstractResponse class provides default implementations for JSON serialization by automatically including public properties.

Creating a New Parameter Type

Custom parameter types extend AbstractType and handle validation and parsing of input parameters. They have access to the context via $this->context.

Example:

Using Enums

Enums provide a way to define a set of named constants, which can be used for parameter validation and response fields. With PHP 8.1, you can use native enums.

Defining an Enum

Example:

Using Enums in Parameters

Enums can be used as parameter types to ensure that only valid values are passed.

Usage in Method:

Handling API Requests

Requests are handled by the Processor, which invokes the appropriate method based on the request URI.

Error Handling

Throwing Errors

To throw errors in your methods, use the ErrorException class.

Example:

Common Error Codes:

Handling Errors in the Processor

Errors thrown in your methods are caught in the YourProcessor.php and returned as structured error responses. Example Error Response:

Typescript schema generation

Conventions

If you are going to use typescript api schema generation you have to follow these principles:

Structure

Generation

Run php script with content below in you project directory


All versions of motion-dots with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
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 jeanisahakyan/motion-dots contains the following files

Loading the files please wait ....