Download the PHP package wwtg99/restful-helper without Composer

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

Restful query parser trait for Laravel eloquent model

Add helper traits for restful query.

Installation

Parse query

This trait parse url queries for eloquent model. Suppose you have a resource controller in route /users and connect to User model.

filters

Add filterableFields in your model.

Then use /users?role=admin to get user with role admin.

Supported operators:

sorts

Use /users?sort=-role,created_at to sort by role desc and created_at asc, comma(,) to separate.

select fields

Use /users?fields=name,role,created_at to show only name, role and created_at. Also can config $selectableFields to restrict selectable fields.

Then only name and role can be selected to show.

Use fields=count to count results /users?fields=count.

pagination

Use /users?limit=10&offset=10 to limit 10 and offset 10 records, offset can be omitted, default 0. Also can use page and page_size, /users?page=2&page_size=15, page_size can be omitted, default 15.

Usage

Eloquent model trait

  1. Add RestHelper trait in eloquent model.

  2. Use index method.

  3. Also combine with other methods.

Controller trait

  1. Add RestfulController trait in resource controller.

  2. Implement getModel method.

Model should use RestHelperTrait to have index function.

  1. Add controller to routes

  2. Each resource method (index, show, store, update, destroy) has three parts.
    1. parse requests
    2. handle action
    3. response

Override these template functions to change the default behaviors.

Add $creatableFields = ['field1', 'field2'] to restrict fields to store. Add $updateableFields = ['field1', 'field2'] to restrict fields to update.

Batch Process

Add new route for batch process. Batch process read content body as json object.

Use key GET and id array as value. Return data or error in the same sequence as query.

Use key CREATE and object array as value. Return data or error in the same sequence as query.

Use key UPDATE, id and data pairs as value. Return data or error in the same sequence as query.

Use key DELETE and id array as value. Return {"code": 204} or error in the same sequence as query.

Batch Usage

  1. Add RestfulControllerTrait in your Controller

  2. Add route

  3. Send batch query POST /test/batch {"GET":[1,2],"CREATE":[{"name":"aaa","email":"[email protected]"}],"UPDATE":{"1":{"name":"bb"},"2":{"email":"[email protected]"}},"DELETE":[5,6]}

Return { "GET": [{"id":1, "name":"a", "email": "[email protected]"}, {"id":1, "name":"a", "email": "[email protected]"}], "CREATE": [{"id": 3, "name":"aaa", "email":"[email protected]"}], "UPDATE": {"1": ["id":1, "name": "bb", "email": "[email protected]"], "2": ["id":2, "name":"a", "email":"[email protected]"], "DELETE": [{"code":204},{"code":204}] }


All versions of restful-helper with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
illuminate/database Version ~5.0
illuminate/http Version ~5.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 wwtg99/restful-helper contains the following files

Loading the files please wait ....