Download the PHP package appkr/api without Composer

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

RESTful HTTP API component for Laravel or Lumen based project

Latest Stable Version Total Downloads Latest Unstable Version License

한국어 매뉴얼

INDEX


1. ABOUT

A lightweight RESTful API builder for Laravel or/and Lumen project.

2. FEATURE

  1. Provides Laravel/Lumen Service Provider for the league/fractal.
  2. Provides configuration capability for the library.
  3. Provides easy way of making transformed/serialized API response.
  4. Provides make:transformer artisan command.
  5. Provides examples, so that users can quickly copy & paste into his/her project.

3. LARAVEL/LUMEN IMPLEMENTATION EXAMPLE(How to use)

3.1. API Endpoint

Define RESTful resource route in Laravel way.

Lumen doesn't support RESTful resource route. You have to define them one by one.

3.2. Controller

The subsequent code block is the controller logic for /v1/books/{id} endpoint. Note the use cases of json() helper and transformer on the following code block.

4. HOW TO INSTALL

4.1. Composer.

4.2. Add the service provider.

4.3. [OPTIONAL] Publish assets.

The configuration file is located at config/api.php.

In Lumen we can manually create config/api.php file, and then activate the configuration at bootstrap/app.php like the following.

Done !

5. CONFIG

Skim through the config/api.php, which is inline documented.

6. TRANSFORMER

6.1. What?

For more about what the transformer is, what you can do with this, and why it is required, see this page. 1 transformer for 1 model is a best practice(e.g. BookTransformer for Book model).

6.2. Transformer Boilerplate Generator

Luckily this package ships with an artisan command that conveniently generates a transformer class.

Note

We should always use double back slashes (\\), when passing a namespace in artisan command WITHOUT quotation marks.

A generated file will look like this:

7. NESTING SUB-RESOURCES

An API client can request a resource with its sub-resource. The following example is requesting authors list. At the same time, it requests each author's books list. It also has additional parameters, which reads as 'I need total of 3 books for this author when ordered by recency without any skipping'.

When including multiple sub resources,

In case of deep recursive nesting, use dot (.). In the following example, we assume the publisher model has relationship with somethingelse model.

8. APIs

The following is the full list of response methods that Appkr\Api\Http\Response provides. Really handy when making a json response in a controller.

8.1. Appkr\Api\Response - Available Methods

8.2. Appkr\Api\TransformerAbstract - Available Methods

8.3. helpers.php - Available Functions

9. BUNDLED EXAMPLE

The package is bundled with a set of example that follows the best practices. It includes:

Follow the guide to activate and test the example.

9.1. Activate examples

Uncomment the line.

9.2. Migrate and seed tables

Do the following to make test table and seed test data. Highly recommend to use SQLite, to avoid polluting the main database of yours.

9.3. See it works

Boot up a server.

Head on to GET /v1/books, and you should see a well formatted json response. Try each route to get accustomed to, such as /v1/books=include=authors, /v1/authors=include=books:limit(2|0):order(id|desc).

9.4. [OPTIONAL] Run integration test

Note

If you finished evaluating the example, don't forget to rollback the migration and re-comment the unnecessary lines at ApiServiceProvider.

10. LICENSE & CONTRIBUTION

MIT License. Issues and PRs are always welcomed.

11. CHANGELOG

v3.0.1

v3.0.0

v2.3.4

v2.3.3

v2.3.0

v2.2.0

v2.1.0

v2.0.0

v1.1.0 [buggy]

12. SPONSORS


All versions of api with dependencies

PHP Build Version
Package Version
Requires league/fractal Version 0.16.*
shrikeh/teapot Version 2.3.*
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 appkr/api contains the following files

Loading the files please wait ....