Download the PHP package grabmy/laravel-api-builder without Composer

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

Laravel API Builder

A Laravel database and API generator.

Author: Thierry DE LAPEYRE

Features

Requires

Install

Additional artisan commands must appear when you type:

The artisan command is "make:api" and you must give the path of a JSON configuration file as a parameter. The optional verbose -v parameter can show more logs.

Quick start

Create a configuration file "api.json" in the root folder of your Laravel project:

In this example, we define a simple table and API behavior. A table will be created with an integer incrementing "id", a string "name", a string "description" with length 200 and a boolean "published" with default false (0).

To boostrap your table migration and create all the files for the API in your project, you must run a command.

WARNING: If you already have a model, controller or migration file with the same filenames, the files will be overwritten.

If everything works, you can see the files generated in green. You still have to run the migration that creates the table in your database.

WARNING: the basic migrate command will also destroy and recreate other tables you have in the migration of your project

Assuming your project is accessible at "http://127.0.0.1:8000/", you can now:

Configuration file

The configuration file contains the definition of the tables and the behavior of the API. Each tables have their fields definition.

Multiple tables:

Multiple fields for each table:

You can have multiple options for a field. Each options are separated by the character pipe "|". The main option is the type of the field, which I usually put first (it's easier to find).

Multiple options:

An option can have some additional parameters. Each parameters are separated by the character semicolon ":".

Options with multiple parameters:

The available requests

Getting the record list

Url: GET /api/endpoint

In our example if we have two articles, GET http://127.0.0.1:8000/api/article will result:

Status code: 200

Body:

Getting one record

Url: GET /endpoint/{id}

In our example, GET http://127.0.0.1:8000/api/article/1 will result:

Status code: 200

Body:

Creating a record

@TODO

Updating a record

@TODO

Deleting a record

@TODO

Errors

@TODO

Field types

Type Description Parameters
string Just a string optional length
text Long text
int Integer
bool Boolean
float A float number
uuid An UUID
increments An incrementing integer
one-to-many A list of records from another table Table, field
many-to-many A list of records from another table Table, field

UUID

If the field has an UUID type and is primary, the API will generate an UUID on POST creation. If the UUID field is not primary, on POST creation and PUT update, the API will automatically check if the passed string is a valid UUID.

Increments

@TODO

List

@TODO

Other options

Option Description Parameters
max Check the maximum length Length
min Check the minimum length Length
type Check the type Type
required Check if a value exists
nullable Field value can be null and optional
default Set the default value Value
primary Set the field as primary key
omit Don't return the field value in API
one-to-one Link the foreign key to another table table, field
as Return this field value with another name
cascade Delete record if foreign record is deleted type

Type option

Return an error if the JSON don't have the correct type on POST creation and PUT update. List of types:

One to many

@TODO

Cascade

The cascade option must be puts in one-to-one or one-to-many fields.

If a record from table order is deleted, the previous API config will:

API configuration

Endpoint

@TODO

Fetch

The fetch feature is a powerfull feature that allows you to tell the API to fetch records or array of records from other tables.

In the fetchable parameter:

The default value for the fetchable parameter is true.

For example with this configuration:

Here, we have a link to a record of the "category" table and a list of records of the "website" table. Setting "fetchable" to true will fetch all fields linked to our table (type "list" or option "link").

The "as" option is mandatory with the "link" option. It means the category record will be placed in a field with the name "category" instead of "category_id". The "websites" field is a list, so it will get an array of records from the "website" table where article_id is set to the value of the id of the article.

Now, when we are getting one article record:

If we set the fetchable parameter to false, we get the article record without fetching any linked record in it.

Our article from the API becomes flat:

We don't see the "websites" field because it is not saved field in the database, so it will be available only if the websites records are fetched. We see now the "category_id" field which is not filtered out.

You can also set the fetchable parameter to just fetch "category" in our article and fetch everything in it but not fetching "websites". So the "tag_id" the category record becomes a record as we can imagine it's a link to a tag table.

The category is fetched and every field that can be fetched in it:

You can set the API result as you want and go as deep as you like without creating an infinite loop. Be aware that the more you fetch records from other tables, the slower your API will be, especially if you fetch in an array.

Fetch POST and PUT option

@TODO

Methods

@TODO

What this API generator doesn't do

TODO

DONE

PENDING


All versions of laravel-api-builder with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
webpatser/laravel-uuid Version ^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 grabmy/laravel-api-builder contains the following files

Loading the files please wait ....